Swift package edit does not work with docker

i’m having a lot of issues with the swift package edit command when using it in a project that builds in docker.

if i run the command from outside the docker container, i get

error: invalid access to .build/workspace-state.json

if i run it from within the container, all the checkout files have root permissions, and cannot be modified in a text editor without entering the root password.

has anyone got a workaround? (that doesn’t involve chowning everything on every checkout?)

I can't tell from what you've said if this is exactly the issue you're facing, but COPY in your Dockerfile supports a --chown flag. Combine that with the USER directive to run commands as non-root and you should be able to get all your source files in the container as non-root.

1 Like

i’m not using COPY though, i am mounting the project directory with -v $PWD:/home/ec2-user/example-project, so i can edit the files from outside the container

Hmm, -v should mount things as non-root in most situations. Can you share your Dockerfile and docker run command? I'd be happy to take a look and see if there's an easy fix.