microsoft / vscode-dev-containers

NOTE: Most of the contents of this repository have been migrated to the new devcontainers GitHub org (https://github.com/devcontainers). See https://github.com/devcontainers/template-starter and https://github.com/devcontainers/feature-starter for information on creating your own!
https://aka.ms/vscode-remote
MIT License
4.72k stars 1.41k forks source link

Rust Remote Container /usr/local/cargo Ownership Issue #1606

Closed andar1an closed 1 year ago

andar1an commented 2 years ago

/usr/local/cargo may require recursive vscode user ownership to be able to save new crates into the directory. I get a Spurious Network Error if vscode is not the user. I just manually ran chown -R vscode:rustlang /usr/local/cargo to bypass issue.

Steps to Reproduce:

  1. Set up a Remote Container using available scripts and dockerfiles: https://github.com/microsoft/vscode-dev-containers/tree/v0.195.0/containers/rust
  2. Use a project that requires a crate such as rand: https://crates.io/crates/rand
  3. Build project. Spurious Network Error may result due to a lack of ownership of /usr/local/cargo
bamurtaugh commented 2 years ago

Thanks for opening an issue!

Our team has been actively working on an updated plan for community contributions and this repo moving forward, which we've now outlined in this issue: https://github.com/microsoft/vscode-dev-containers/issues/1589. This includes moving to new repos for images (https://github.com/devcontainers/images) and Features (https://github.com/devcontainers/features), and we anticipate to have a similar repo and process for templates/definitions.

Do you have a fix in mind? If so, please feel free to open a PR on the new Rust image or Rust Feature, or you can open an issue on this topic in either repo. Let me know if you have any questions, thank you!

andar1an commented 2 years ago

I do have a fix in mind, and it would just be to run a post create command in docker or docker-compose file to have the vscode user take recursive ownership of /usr/local/cargo. However, I have not had time to play around to see if there are better options yet (I have noticed an image on Docker Hub which I have not seen before). I am also not sure if it was by design that the root user was meant to remain as the owner (potentially for hardening reasons?). I imagine it depends on the use case (e.g. dev vs prod).

bamurtaugh commented 2 years ago

cc @joshspicer @edgonmsft @samruddhikhandale if you have any thoughts on the ownership topic for the Rust image or template.

andar1an commented 1 year ago

The rust image that you shared is awesome! It even adds target for wasm, and compiles trunk and hyper, etc. I have had to add wasm stuff myself in the past. Just need to test to see if the issue I had still exists (hopeful it does not). I will close this issue if it works. To automatically format on save, I believe nightly build of Rust is needed still. Is that possible here?

andar1an commented 1 year ago

All seems to be good now! Thank you!