Skip to content
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

rustup show: Can, instead, configure your system (silently) #2957

Closed
bbros-dev opened this issue Mar 10, 2022 · 3 comments
Closed

rustup show: Can, instead, configure your system (silently) #2957

bbros-dev opened this issue Mar 10, 2022 · 3 comments

Comments

@bbros-dev
Copy link

bbros-dev commented Mar 10, 2022

Problem

When ~/.rustup does not exist and RUSTUP_HOME and CARGO_HOME are not set. Running rustup show, silently creates the folder ~/.rustup and the file ~/.rustup/settings.toml.

This

Steps

~$ 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
~$ ls ~/.rustup
settings.toml

Possible Solution(s)

Given the folder `~/.rustup` does not exist
  And the environment variable RUSTUP_HOME is not set
  And the environment variable CARGO_HOME is not set
 When a user runs `rustup show`
 Then the folder `~/.rustup` is not created
  And the stderr output does contain:
"""
error: rustup is not installed at '/home/<snip>/.rustup' and RUSTUP_HOME is not set.  One is required.
"""

Another foreseeable scenario

Given the folder `~/.rustup` does not exist
  And the environment variable RUSTUP_HOME is set
  And the environment variable CARGO_HOME is not set
  And the folder pointed to by RUSTUP_HOME does not exist
 When a user runs `rustup show`
 Then the folder `~/.rustup` is not created
  And the folder pointed to by RUSTUP_HOME is not created
  And the stderr output does contain:
"""
error: RUSTUP_HOME points to the folder /some/path, that does not exist. The file RUSTUP_HOME/settngs.toml is also required. See http://some/doc/url.html
"""

Notes

This was observed in the course of issue #2886

Rustup version

$ rustup --version
rustup 1.24.3 (ce5817a94 2021-05-31)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.59.0 (9d1b2106e 2022-02-23)`

Installed toolchains

$ rustup show                                                                               
Default host: x86_64-unknown-linux-gnu                                                            
rustup home:  /home/hedge/.local/share/rustup

installed toolchains
--------------------

stable-x86_64-unknown-linux-gnu (default)
nightly-2021-09-01-x86_64-unknown-linux-gnu
nightly-x86_64-unknown-linux-gnu
1.45.2-x86_64-unknown-linux-gnu
1.52.1-x86_64-unknown-linux-gnu
1.53.0-x86_64-unknown-linux-gnu
1.54.0-x86_64-unknown-linux-gnu
1.56.1-x86_64-unknown-linux-gnu

active toolchain
----------------

stable-x86_64-unknown-linux-gnu (default)
rustc 1.59.0 (9d1b2106e 2022-02-23)
@bbros-dev bbros-dev added the bug label Mar 10, 2022
@bbros-dev bbros-dev changed the title rustup show: Can silently create ~/.rustup rustup show: Can silently create ~/.rustup and ~/.rustup/settings.toml Mar 10, 2022
@jyn514
Copy link
Member

jyn514 commented Mar 10, 2022

Why is this a bug? Rustup needs to manage these directories, it's an implementation detail when they're created.

@bbros-dev
Copy link
Author

bbros-dev commented Mar 10, 2022

Why is this a bug?

To my mind: because it is not showing it is initializing.

I referred to the issue where this was uncovered.
Under the conditions set out I'd expect something like what was set out above - the error text above could be improved, no argument here. In fact I've added another scenario to the OP.

If the behavior was as set out above, rustup show would have indicated there is an issue with how the env var RUSTUP_HOME is being set, because rustup ... doesn't have access to it.

I'm strongly opposed to a command called show making any changes to my system - I don't believe that is a reasonable thing to do to users.

As a tactical workaround pending a fix it would be courteous to print a warning that rustup show is about to change the configuration of your system, maybe something like:

Warning: 
Unable to find RUSTUP_HOME, nor the folder ~/.rustup nor the file ~/.rustup/settings.toml.  
We know you asked to show the current configuration details.  
Instead we've decided to take it upon ourselves to configure your system for you by creating that folder and file.

Hopefully that makes the objection clear.

@bbros-dev bbros-dev changed the title rustup show: Can silently create ~/.rustup and ~/.rustup/settings.toml rustup show: Can, instead, configure your system (silently) Mar 10, 2022
@rbtcollins
Copy link
Contributor

Dup of #1397

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants