Skip to content

Permission denied errors when building with custom user:group #439

@zvolin

Description

@zvolin

Hey, I'm trying to use this image to test some swift package without hard dependency on swift itself. Ideally I'd like to use it by mounting a directory into a container and running swift test inside the docker, but I set the --user "$(id -u):$(id -g)" to not end up with files owned by root inside my repository. It works fine on my linux machine where this evaluates to 1000:100 however on both CI and macos it does hit a permission denied errors as user / group there is different.

I think it'd be cool to allow such use case by setting relaxed ownership for /.cache and /.swiftpm directories.

sudo docker run --rm --user 501:20 --volume ~/lumina/node-uniffi/tests/swift:/app --workdir /app swift:6.0.3 swift test
Unable to find image 'swift:6.0.3' locally
6.0.3: Pulling from library/swift
5b17151e9710: Pull complete 
9c86af143950: Pull complete 
2d71b9490344: Pull complete 
0df45399d30e: Pull complete 
Digest: sha256:21ec2ef4572c5989ca7c0113ee9286931715f0a2f8e216df63b8af059c9b25c3
Status: Downloaded newer image for swift:6.0.3
warning: /.swiftpm/configuration is not accessible or not writable, disabling user-level cache features.
warning: /.swiftpm/security is not accessible or not writable, disabling user-level cache features.
warning: /.cache/org.swift.swiftpm is not accessible or not writable, disabling user-level cache features.
warning: 'app': failed loading cached manifest for 'app': Error Domain=NSCocoaErrorDomain Code=4 "The file doesn’t exist."
warning: 'app': failed closing manifest db cache: Error Domain=NSCocoaErrorDomain Code=4 "The file doesn’t exist."
error: 'app': Invalid manifest (compiled with: ["/usr/bin/swiftc", "-vfsoverlay", "/tmp/TemporaryDirectory.CzVcrh/vfs.yaml", "-L", "/usr/lib/swift/pm/ManifestAPI", "-lPackageDescription", "-Xlinker"
, "-rpath", "-Xlinker", "/usr/lib/swift/pm/ManifestAPI", "-swift-version", "5", "-I", "/usr/lib/swift/pm/ManifestAPI", "-package-description-version", "5.10.0", "/app/Package.swift", "-o", "/tmp/Tem
poraryDirectory.CfkEx1/app-manifest"])
<unknown>:0: error: unable to open output file '/.cache/clang/ModuleCache/OXJJCGK251FM/SwiftShims-KL4KQ8XX75N7.pcm': 'Permission denied'
<unknown>:0: error: could not build C module 'SwiftShims'
warning: 'app': failed loading cached manifest for 'app': Error Domain=NSCocoaErrorDomain Code=4 "The file doesn’t exist."
warning: 'app': failed closing manifest db cache: Error Domain=NSCocoaErrorDomain Code=4 "The file doesn’t exist."
error: 'app': Invalid manifest (compiled with: ["/usr/bin/swiftc", "-vfsoverlay", "/tmp/TemporaryDirectory.aNExBp/vfs.yaml", "-L", "/usr/lib/swift/pm/ManifestAPI", "-lPackageDescription", "-Xlinker"
, "-rpath", "-Xlinker", "/usr/lib/swift/pm/ManifestAPI", "-swift-version", "5", "-I", "/usr/lib/swift/pm/ManifestAPI", "-package-description-version", "5.10.0", "/app/Package.swift", "-o", "/tmp/Tem
poraryDirectory.ZTiXVZ/app-manifest"])
<unknown>:0: error: unable to open output file '/.cache/clang/ModuleCache/OXJJCGK251FM/SwiftShims-KL4KQ8XX75N7.pcm': 'Permission denied'
<unknown>:0: error: could not build C module 'SwiftShims'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions