-
Notifications
You must be signed in to change notification settings - Fork 895
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
error: rustup is not installed at '/home/user/.cargo' when $RUSTUP_HOME is set to something other than the former #2886
Comments
Our test suite sets those variables in order to operate, so I'm not sure how this could be happening to you. Can you confirm that |
A month with no response - @bbros-dev please reply or we'll need to close this with insufficient information |
This happens on my end too — but only if run from a script. Works perfectly fine if run from the shell of any user — and this is if I put Again, perfectly fine if run from a shell, but if I write something like Re: @bbros-dev — it would help to add “when $RUSTUP_HOME is set to something other than the former” to the end of this bug report’s title to make this report more clear. @rbtcollins — might want to remove the “inactive” label per this reproduction. |
Thanks for taking the time to look at this. The following is a complete log of a new shell - @kinnison full setup details follow. You'll note that ~$ ls ~/.rustup
ls: cannot access '/home/<user>/.rustup': No such file or directory
~$ echo $RUSTUP_HOME
/home/<user>/.local/share/rustup
~$ echo $CARGO_HOME
/home/<user>/.local/share/cargo
~$ rustup show
Default host: x86_64-unknown-linux-gnu
rustup home: /home/<user>/.rustup
no active toolchain
~$ ls ~/.rustup
settings.toml
~$ RUSTUP_HOME=$RUSTUP_HOME rustup show
Default host: x86_64-unknown-linux-musl
rustup home: /home/<user>/.local/share/rustup
stable-x86_64-unknown-linux-musl (default)
(error reading rustc version)
~$ ls ~/.local/share/rustup
downloads settings.toml tmp toolchains update-hashes
Yes, I believe so - see the above details from new bash shell. Setup details follow.
Setup is using Chef recipes:
#!/usr/bin/env bash
[ -f /etc/skel/.bashrc ] && source /etc/skel/.bashrc
for file in ~/.config/bash/bashrc.d/*.bashrc
do
test -f "$file" || continue
test -x "$file" || continue
# shellcheck source=/dev/null
source "$file"
done
CARGO_HOME=${XDG_DATA_HOME}/cargo
RUSTUP_HOME=${XDG_DATA_HOME}/rustup
PATH="${CARGO_HOME}/bin:${RUSTUP_HOME}/bin:$PATH"
# frozen_string_literal: true
pkgs = %w[
musl-dev
musl-tools
musl
]
pkgs.each do |pkg|
package pkg do
action :install
end
end
node['developer']['users'].each do |usr|
bash "Create #{usr} Rust install" do
code <<-EOCODE
curl https://sh.rustup.rs -sSf | \
sh -s -- \
-y \
--verbose \
--default-host x86_64-unknown-linux-musl \
--default-toolchain stable \
--profile default \
--no-modify-path
EOCODE
creates "/home/#{usr}/.local/share/rustup"
environment ({ 'CARGO_HOME': "/home/#{usr}/.local/share/cargo",
'DISPLAY': ':0',
'HOME': "/home/#{usr}",
'RUSTUP_HOME': "/home/#{usr}/.local/share/rustup",
'USER': usr })
user usr
not_if %([ -d "/home/#{usr}/.local/share/rustup" ])
end
link "/home/#{usr}/.local/bin/rustup" do
to "/home/#{usr}/.local/share/cargo/bin/rustup"
end
execute "/home/#{usr}/.local/bin/rustup update --no-self-update stable" do
environment ({ 'DISPLAY': ':0',
'HOME': "/home/#{usr}",
'USER': usr,
'CARGO_HOME': "/home/#{usr}/.local/share/cargo",
'RUSTUP_HOME': "/home/#{usr}/.local/share/rustup" })
user usr
end
## Install components
#
%w[
clippy
rustfmt
rust-src
].each do |c|
execute "/home/#{usr}/.local/bin/rustup component add #{c}" do
environment ({ 'DISPLAY': ':0',
'HOME': "/home/#{usr}",
'USER': usr,
'CARGO_HOME': "/home/#{usr}/.local/share/cargo",
'RUSTUP_HOME': "/home/#{usr}/.local/share/rustup" })
user usr
end
end
end |
To further corroborate what @bbros-dev is saying, here's the full text of
When I went on to create something like "rustup-update.sh" with the following content:
It would fail with this error when I tried to run it. This, however, seems to have begun working fine a month later on my end for some reason ― not sure why I was able to reproduce this on December 28 but not now. |
@bbros-dev I think your issue might be in the file
Bash doesn't export these variables to subshells, which is resulting in your problem where rustup isn't seeing
|
@krishnachittur, thank you that does appear to have resolved the error. IIUC then the issue is as follows: Given the folder `~/.rustup` does not exist
And the environment variable RUSTUP_HOME is not set
When a user runs `rustup self update`
Then the stderr output does not contain:
"""
error: rustup is not installed at '/home/<snip>/.cargo'
"""
And the stderr output does contain:
"""
error: rustup is not installed at '/home/<snip>/.rustup' and RUSTUP_HOME is not set. One is required.
""" Does that sound correct? |
@bbros-dev In other words, you think the current error message is unclear? That seems like a reasonable complaint to me. Might be an easy PR as well. |
i'm running into this trying to get caching to work properly in gitlab CI. A quick search shows i'm not the only one getting stumped here default:
image: "rust:latest"
variables:
CARGO_HOME: ${CI_PROJECT_DIR}/.cargo # Move cargo data into the project directory so it can be cached
cache:
key: ${CI_COMMIT_REF_SLUG} # Share cache between all jobs on one branch/tag
paths:
- .cargo/bin
- .cargo/registry/index
- .cargo/registry/cache
- target/debug/deps
- target/debug/build
policy: pull-push
before_script:
- rustup update
- rustup install stable
# ...
|
@danieleades I suggest you try out https://gitlab.com/rust-ci/rust-ci - I know the authors of that and they're pretty helpful. |
Also ran into this problem in my gitlab pipeline. Cause is definitely the self update. Resolved by running |
Reminds me we should probably disable self updates when |
Relevant issue: #3824 |
@Xenira thanks for the resolution. |
remove rustfmt download step cargo fmt Changelog-None: ci changes for cache handling disable rustup auto update as it fails: rust-lang/rustup#2886 (comment) Signed-off-by: Lakshya Singh <[email protected]>
If I understand correctly, there hasn't been a release since rustup 1.27.1 (54dd3d0 2024-04-24), 9 months ago. In particular, this problem still exists in the latest stable rustup? Can we reopen this issue until there is a rustup release? Generally if I see an issue has been closed for 7 months, I figure that it is resolved in the latest stable release. |
@hoodmane I understand your confusion. Unfortunately, GitHub's auto-closing feature is linked to PRs, so keeping resolved issues open makes it difficult to track which ones are already addressed on our side. Currently the best way to find out is probably looking at the "milestone" field to know which fixes belong to which releases... Sorry again for my not adding the milestone for this particular issue previously. |
If rustup doesn't have any timeline for releasing 1.28, could you backport this fix and release a |
I think it's pretty common practice in both open source and proprietary projects to close an issue once resolved on the development branch. |
Indeed, apologies for the whining. And thanks for contributing the fix! |
Problem
CARGO_HOME
is not the Linux default~/.cargo
rustup self uninstall
fails to workrustup
.Steps
Possible Solution(s)
No idea. We seem to be in a Mexican-standoff.
Notes
Output of
rustup --version
:Output of
rustup show
:The text was updated successfully, but these errors were encountered: