-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cargo in WSL prefers windows user config #11677
Comments
My guess is that cargo/crates/home/src/windows.rs Lines 9 to 30 in 82c3bb7
I don't really have my Windows close by though. I believe @epage is more helpful. @epage, do you have any experience in WSL with home directory setup? |
It works when copying the project to a "native" WSL directory, it's only when the project is in some way under a symlink to |
Yes, this is correct (it's unrelated to WSL). |
Can confirm, this resolved for me after creating a USERPROFILE environment variable in WSL that pointed to the right location. |
this issue makes me struggled for a very very long time. Actually, all I wanted is just very simple: but currently in WSL2:
|
Forgot to say, |
What's the status of this? I tried to add Update: If I use |
@CGMossa what your encountering sounds like a different problem. If you can create a minimal reproduceable example, please create a new issue with details. |
Problem
Cargo in WSL uses the windows host cargo config in
%UserProfile%/.cargo/config.toml
, and it looks like values there are preferred over the WSL~/.cargo/config.toml
.When there is either
rustc-wrapper
ortarget-dir
configured, cargo in WSL fails because it does not have access to those paths.edit: The project I am trying to compile is in a folder symlinked to
/c/Users/<user>/projects
. It looks like cargo unwraps the symlink, then it's pretty clear why it finds the windows config first. But I am not sure this behavior is preferrable./edit
I have a
~/.cargo/config.toml
in WSL with the following content:But cargo prefers the host values.
Error when
rustc-wrapper
is set on windows:Error when
target-dir
is set on windows:which { rustup cargo rustc }
shows WSL binaries, so there is no issue with accidentally invoking host binaries.When I delete the contents of the windows
cargo.toml
, the WSL config is applied correctly.Steps
%UserProfile%/projects/<name>
config.toml
in%UserProfile%/.cargo
with eitherrustc-wrapper
ortarget-dir
~/
to/mnt/c/Users/<user>/projects
cargo run
in~/projects/<name>
Possible Solution(s)
Change cargo so it doesn't "unwrap" symlinks when looking for configs.
If
pwd
prints~/projects/
, cargo should not behave like it's in/mnt/c/Users/<user>/projects
.Notes
wsl -v -l
Version
The text was updated successfully, but these errors were encountered: