Skip to content

rustup show should not force-install the default toolchain if it is not installed. #1397

Closed

Description

@johnthagen

This behavior confused me:

$ rustup uninstall nightly-2018-04-01-x86_64-apple-darwin
info: uninstalling toolchain 'nightly-2018-04-01-x86_64-apple-darwin'
info: toolchain 'nightly-2018-04-01-x86_64-apple-darwin' uninstalled
$ rustup show
Default host: x86_64-apple-darwin

info: syncing channel updates for 'nightly-2018-04-01-x86_64-apple-darwin'
info: latest update on 2018-04-01, rust version 1.26.0-nightly (517f24025 2018-03-31)
info: downloading component 'rustc'
 57.3 MiB /  57.3 MiB (100 %)   7.8 MiB/s ETA:   0 s                
info: downloading component 'rust-std'
 46.2 MiB /  46.2 MiB (100 %)   7.4 MiB/s ETA:   0 s                
info: downloading component 'cargo'
  3.0 MiB /   3.0 MiB (100 %)   1.5 MiB/s ETA:   0 s                
info: downloading component 'rust-docs'
  6.8 MiB /   6.8 MiB (100 %)   3.1 MiB/s ETA:   0 s                
info: installing component 'rustc'
info: installing component 'rust-std'
info: installing component 'cargo'
info: installing component 'rust-docs'
installed toolchains
--------------------

stable-x86_64-apple-darwin
nightly-i686-apple-darwin
nightly-x86_64-apple-darwin (default)

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

nightly-2018-04-01-x86_64-apple-darwin (directory override for '/Users/user/GitHub/unrust')
rustc 1.26.0-nightly (517f24025 2018-03-31)

Is rustup show supposed to actually start installing components? I was under the impression that it was just for listing out what you have installed.

I'm on a macOS 10.12.6 host.

Activity

  1. kinnison commented on Nov 10, 2019

    @kinnison
    Contributor

    The behaviour here comes from the fact that the default toolchain was uninstalled. Rustup forces the default toolchain to exist in many places semi-automatically. This is done to reduce surprise in a number of places, but has the side-effect of being surprising here. Perhaps we need an info: Default toolchain not installed, attempting to install... which would make it clear why it's happening?

  2. johnthagen commented on Nov 16, 2019

    @johnthagen
    ContributorAuthor

    @kinnison Personally I think a command like show should never actually install something and change the user's environment. That just seems very odd to me and I can't think of another example of a tool that does something like that.

  3. changed the title [-]Should `rustup show` update toolchains?[/-] [+]`rustup show` should not force-install the default toolchain if it is not installed.[/+] on Nov 17, 2019
  4. kinnison commented on Nov 17, 2019

    @kinnison
    Contributor

    @johnthagen That's fair, I have retitled the issue and I'm happy to mentor yourself or anyone else through the process of determining why this happens, and what we can do to improve the UX and ensure it doesn't happen in future. This is nominally a breaking change in how rustup show works, but frankly I think it's right to do it.

    If anyone wants help with working this one through to a PR, please comment here or find me on #wg-rustup on our Discord.

  5. SummerGram commented on Mar 21, 2020

    @SummerGram

    @kinnison
    anyone doing this?

  6. kinnison commented on Mar 21, 2020

    @kinnison
    Contributor

    @SummerGram I think that noone is working on this per-se. It should be fairly easy to work out what's going on after recent refactoring done by Robert.

  7. kellda commented on Feb 11, 2021

    @kellda
    Contributor

    What about rustup --version or rustup +toolchain --version ?

  8. kinnison commented on Feb 12, 2021

    @kinnison
    Contributor

    I think if you explicitly say +toolchain then you're saying you want that to be installed.

  9. kellda commented on Feb 13, 2021

    @kellda
    Contributor

    I'm still unsure what is the right behaviour: which commands of the following should install a toolchain ?

    • rustup --version
    • rustup +toolchain --version
    • rustup show
    • rustup +toolchain show
    • rustup show active-toolchain
    • rustup +toolchain show active-toolchain

    What about healing damaged toolchains ?

    Furthermore, there are actually tests (*_not_installed in cli-rustup.rs) that check that rustup show installs the toolchain.

  10. kellda commented on Feb 13, 2021

    @kellda
    Contributor

    cc #1250 for the tests
    cc #2252 for always installing toolchains

  11. kinnison commented on Feb 16, 2021

    @kinnison
    Contributor

    I think, for each case we need to think about whether or not having the toolchain absent would cause confusion or breakage in scripting which may already exist and rely on behaviour. I'm prepared to introduce some breaking change so long as it's very well thought out.

    In my view, if you are explicitly stating a toolchain via +toolchain or via a rust-toolchain file then we should always install that since I know some people rely on that behaviour in CI (i.e. running rustup show as part of their CI to both ensure the toolchain is present, and to display the toolchain information in the CI logs, but IIRC the projects I know doing this all have rust-toolchain files).

    I also think if you're explicitly asking questions of the toolchain then it should be installed if absent (rustup show active-toolchain).

    Of the examples you gave, I think that means a plain rustup --version and a plain rustup show (plain in the sense of no +toolchain and no rust-toolchain override file) are the only ones I'd entertain not force-installing the toolchain for. And they should emit a warning if the toolchain is absent.

    All in all this is a somewhat confusing situation to be in, made worse because people are relying on the theoretically 'odd' behaviour.

  12. rbtcollins commented on Feb 16, 2021

    @rbtcollins
    Contributor

    I think we should break things. Not cavalierly, but carefully, perhaps even with an RFC. But we have 'install', and we can make that idempotent. We can make a version of install that honours toolchain files etc. But (ab)using show to trigger an install is just counter intuitive and will be an ongoing source of WTFs forever.

  13. 22 remaining items

  14. rami3l commented on Jul 15, 2024

    @rami3l
    Member

    This issue will only track the rustup show case, which is already addressed by #3225. For other cases, let's continue the discussion at #3635.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions