setup-rust-action icon indicating copy to clipboard operation
setup-rust-action copied to clipboard

Honor `RUSTUP_HOME` on windows

Open akiross opened this issue 3 years ago • 0 comments

Hello, I tried using this action to build on a self-hosted windows runner: even if rustup was installed, the runner couldn't function properly and ended with this error:

##[debug]Evaluating condition for step: 'Setup Rust environment'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: Setup Rust environment
##[debug]Loading inputs
##[debug]Loading env
Run hecrj/setup-rust-action@v1
  with:
    rust-version: stable
  
"C:\Program Files (x86)\Rust\cargo\bin\rustup.exe" self update
info: checking for self-updates
  rustup unchanged - 1.24.3
"C:\Program Files (x86)\Rust\cargo\bin\rustup.exe" set profile minimal
info: profile set to 'minimal'
C:\Windows\System32\where.exe rustup.exe
C:\Program Files (x86)\Rust\cargo\bin\rustup.exe
Error: ENOENT: no such file or directory, rename 'C:\Program Files (x86)\Rust\.rustup\toolchains' -> 'C:\Program Files (x86)\Rust\.rustup\_toolchains'
##[debug]Node Action run completed with exit code 1
##[debug]Finishing: Setup Rust environment

looking at rustup.ts line 36, it seems that it will try to search rustup by looking at where cargo is and using a relative path, but in my case RUSTUP_HOME and CARGO_HOME are set, so maybe those could be used instead?

If for some reason these envvars will be ignored, I think it might be useful to document that, on windows (or in general for any platforms), rustup is assumed to be somewhere specific relatively to where cargo is - this might be useful for people self-hosting the GHA runners.

Thank you!

EDIT: Just for information to anyone stumbling here, the workaround to this is to install rustup in RUSTUP_HOME=C:\Program Files (x86)\Rust\.rustup and cargo in CARGO_HOME=C:\Program Files (x86)\Rust\.cargo.

akiross avatar Jun 22 '22 13:06 akiross