I am creating a devcontainer for my rust+postgres project. It worked well on wsl2. But when I cloned the project to a ubuntu system and tried to open it in devcontainer, it eventually failed, at the final steps.
here is the last few lines of output.
Compiling shell-escape v0.1.5
Compiling dotenvy v0.15.7
Compiling cargo-watch v8.5.2
Finished `release` profile [optimized] target(s) in 3m 37s
Installing /usr/local/cargo/bin/cargo-watch
Installed package `cargo-watch v8.5.2` (executable `cargo-watch`)
Running the postStartCommand from devcontainer.json...
[241247 ms] Start: Run in container: /bin/sh -c RUST_LOG=trace cargo watch -x run
[Running 'cargo run']
error: failed to create directory `/workspaces/workflow_cruder/target/debug/.fingerprint/workflow_cruder-dc7b213ea6c8169e`
Caused by:
Permission denied (os error 13)
[Finished running. Exit status: 101]
To find out what is happening, I opened another terminal within vscode inside the devcontainer and chekced the directory structure.
vscode ➜ /workspaces/workflow_cruder $ ll -a
total 128K
drwxrwxr-x 11 root root 4.0K Jul 30 14:10 .
drwxrwxr-x 8 root root 4.0K Jul 30 14:06 ..
drwxrwxr-x 2 root root 4.0K Jul 30 14:06 .cargo
-rw-rw-r-- 1 root root 65K Jul 30 14:06 Cargo.lock
-rw-rw-r-- 1 root root 625 Jul 30 14:06 Cargo.toml
drwxrwxr-x 2 root root 4.0K Jul 30 14:06 db
drwxrwxr-x 2 root root 4.0K Jul 30 14:06 .devcontainer
-rw-rw-r-- 1 root root 65 Jul 30 14:06 .env.sample
drwxrwxr-x 8 root root 4.0K Jul 30 14:06 .git
drwxrwxr-x 2 root root 4.0K Jul 30 14:06 .github
-rw-rw-r-- 1 root root 414 Jul 30 14:06 .gitignore
-rw-rw-r-- 1 root root 479 Jul 30 14:06 README.md
drwxrwxr-x 4 root root 4.0K Jul 30 14:06 src
drwxrwxr-x 3 root root 4.0K Jul 30 14:06 target
drwxr-xr-x 2 root root 4.0K Jul 30 14:10 .thunderclient
drwxrwxr-x 2 root root 4.0K Jul 30 14:06 .vscode
vscode ➜ /workspaces/workflow_cruder $
All files and folders in this project are now owned by a root user. My current user name as vscode. So, it looks like this is causing the permission error.
Is this a known issue, and/or is there a fix for this?
Thanks in advance.