I have created a new rust hello world project. From vscode, I load the project and ‘open in remote container’. After I do this step, the project works on the remote container, but no longer works on a regular unix terminal outside of vscode.
The files listing shows that the user of the project is some unknown user id as below.
ll
total 16K
-rw-rw-r-- 1 100999 100999 159 Jul 20 17:19 Cargo.lock
-rw-rw-r-- 1 100999 100999 86 Jul 20 17:19 Cargo.toml
drwxrwxr-x 2 100999 100999 4.0K Jul 20 17:19 src
drwxrwxr-x 3 100999 100999 4.0K Jul 20 17:19 target
Also, running the command cargo run
gives an error.
cargo run
error: failed to open: /.../target/debug/.cargo-lock
Caused by:
Permission denied (os error 13)
Is this the expected behavior for a project that gets opened in a devcontainer, that it no longer works the old way on a regular terminal?
Has anyone else faced this issue? If so, how is this to be resolved?
Note:
Both github copilot and chatgpt have no proper answer to this. They throw up a few suggestions for modifying the docker-composer file to play around with user ids. But I am not convinced.
FROM mcr.microsoft.com/devcontainers/rust:1-1-bullseye
# Include lld linker to improve build times
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive
&& apt-get -y install clang lld
&& apt-get autoremove -y && apt-get clean -y
# Get the host UID and GID from build arguments
ARG USERNAME=vscode
ARG USER_UID
ARG USER_GID
# Switch to root to modify user
USER root
# Update the UID and GID of the user
RUN if [ "$USER_GID" ]; then groupmod -g $USER_GID $USERNAME; fi
&& if [ "$USER_UID" ]; then usermod -u $USER_UID -g $USER_GID $USERNAME; fi
&& chown -R $USERNAME:$USERNAME /home/$USERNAME /workspaces
# Switch back to the vscode user
USER $USERNAME
# Set the working directory
WORKDIR /workspaces/${localWorkspaceFolderBasename}
I believe that creating a simple hello world project, should not have ended up messing the old way of working.
1