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

yarn self-update should update using the same installation method originally used #1139

Closed
Daniel15 opened this issue Oct 17, 2016 · 64 comments

Comments

@Daniel15
Copy link
Member

Daniel15 commented Oct 17, 2016

Do you want to request a feature or report a bug?
Feature

What is the current behavior?
yarn self-update always downloads a tarball.

What is the expected behavior?
yarn self-update should update using the same installation method used by the user. For example, if Yarn was installed via the Debian/Ubuntu package, yarn self-update should run sudo apt-get update && sudo apt-get install yarn. On Windows when installed via the installer, it should download https://yarnpkg.com/latest.msi and execute it.

This is closely related to #1138 ("add yarn version check on startup") in that both issues need some way of determining the installation method used by the user.

@busches
Copy link
Contributor

busches commented Dec 6, 2016

Do you want to close this since self-update was removed with #1429?

@Daniel15
Copy link
Member Author

Daniel15 commented Dec 6, 2016 via email

@jakearchibald
Copy link

https://yarnpkg.com/en/docs/cli/self-update should probably be removed/updated

@meta-meta
Copy link

If I'm on 0.18.1, how do I update to the next version?

@Daniel15
Copy link
Member Author

@meta-meta Currently, you need to manually upgrade.

@octopitus
Copy link

how about yarn global add yarn?

@dancoates
Copy link

I'm a big fan of Yarn but am a little concerned at how self-update was removed with no deprecation notice, no mention in the release notes, and that it was bundled in with a PR that is largely unrelated and where there was no discussion about removing self-update.

I understand that it is early days for Yarn and that API changes are to be expected but it would be good if there was a process for removing core functionality.

(sorry if this isn't the right place to discuss, but this PR is where the docs link to)

@Daniel15
Copy link
Member Author

how about yarn global add yarn?

Installing Yarn via Yarn is not a supported use case at the moment, and can cause several issues. We don't recommend it at the moment.

@dancoates - The self-update command never really worked 100% correctly, that PR just removed the remnants of the existing command while adding some framework stuff for the new self-update (which will come in the future, as per this issue)

@CatinhoCR
Copy link

How can I manually update yarn? Not sure about that one, I used brew on my mac to get it working but not sure what "manual" means here... any tips appreciated.

@Daniel15
Copy link
Member Author

Daniel15 commented Jan 26, 2017 via email

@andreafalzetti
Copy link

@CatinhoCR I initially installed yarn using npm, so I did npm uninstall -g yarn and then brew install yarn - And now I've got the latest version. It would also work using the brew upgrade command as @Daniel15 mentioned.

@slootzky
Copy link

npm update yarn -g

@BeHappyF
Copy link

BeHappyF commented Feb 9, 2017

You might install yarn width homebrew.So brew uninstall yarn.And it's not a good choose to install yarn with homebrew when you need to across the wall.Everytime you need to brew update.It's always time out.....

@wardbell
Copy link

wardbell commented Mar 2, 2017

Sadly, npm update yarn -g does not always do the trick. For example, it did not update from v.0.20.3 to v.0.21.3 on my OS/X machine. But the following did work:

npm uninstall yarn -g
npm install yarn -g

@Daniel15
Copy link
Member Author

Daniel15 commented Mar 2, 2017

npm sometimes has weird issues which is why we don't recommend using it to install Yarn.

@jeff-kilbride
Copy link

@wardbell Simply running install works, too:

npm install yarn -g

No need to uninstall first.

@SMotaal
Copy link

SMotaal commented Mar 6, 2018

Sorry to interrupt 😉

Have you considered simply delegating this to npm (assuming of course yarn runs if npm exists in the first place).

» npm update -g yarn

The nice thing is that if it does not work out you can always:

So we tried to get npm to handle the update...

Here are your options:
…

Now, aren't u glad to be using yarn for your other packages!

@Daniel15
Copy link
Member Author

Daniel15 commented Mar 6, 2018

@SMotaal There's a few issues with that:

  • If you installed Yarn via another method, you'll now have two versions of Yarn installed (one via the system package manager, and one via npm)
  • Not everyone has npm installed. Yarn does not require npm installed to run

@Resen4983
Copy link

if your system is Windows and had installed npm ,you can use npm install yarn@latest -g to update to top version.

@SMotaal
Copy link

SMotaal commented Mar 7, 2018

I can't remember how I set it up on this mac roughly a year ago, I know I was using something other than NPM at one point, but when I lost my thread I simply NPMed and I have no issues other than yarn complaining when I'm fairly behind which reminds me to update and I simply npm update -g yarn and forget about it till next reminder.

From a user's perspective, I think yarn can recommend "supported" and maybe mention "unofficial" where if "unofficial" and it does not "work as intended" please use "supported" to install and here is "recommended" if you need to undo "unofficial"

Honestly, it is important for a package manager to have a clear path for itself to be well-managed.

@Stanzilla
Copy link

@onurtemizkan are you still working on this?

@WhoAteDaCake
Copy link

WhoAteDaCake commented Apr 18, 2018

Are there any updates?
My current approach is: yarn global add yarn@latest which doesn't seem like ideal way

@GabeDuarteM
Copy link

For those just wanting to update yarn automatically on windows, without having to download the binary, I've been using choco for a while to do that, and it is doing this job flawlessly. It's a cmd line tool to install programs (just like apt-get). You just run choco install yarn, and yarn is installed. To update, the command is choco upgrade yarn.

@Stanzilla
Copy link

No sorry, chocolatey is just horrible.

@Daniel15
Copy link
Member Author

Daniel15 commented Apr 19, 2018 via email

@begin-again
Copy link

begin-again commented May 8, 2018

Scoop is an alternative to Chocolatey and works a lot like brew.

@tchalvak
Copy link

tchalvak commented Oct 15, 2018

Yarn just told me my yarn version was out of date and asked me to update to the latest yarn version. However, it’s recommendation - a curl & bash command - makes me a little uncomfortable. Wouldn’t this command be effectively the replacement for the need to curl & pipe to bash to upgrade yarn? Would this command act as yarn’s main & frequent upgrade method?

@pikeas
Copy link

pikeas commented Oct 30, 2018

This is a pretty poor experience for new users:

  1. Pull the official and current LTS Docker image (10.12.1) for node, which includes Yarn 1.10.1.
  2. yarn import
  3. yarn install says the version of yarn is out-of-date and recommends a curl | bash command, which is generally considered a bad idea by sysadmins and devops teams.
  4. Find and run yarn self-update at https://yarnpkg.com/en/docs/cli/self-update, which links to this Github issue.
  5. Forget which problem with npm made me try yarn in the first place.

@adrianmcli
Copy link

It's kinda crazy how this still isn't fixed. After more than a year, I think my solution (here) is still the cleanest there is (even though it's tedious and annoying).

@tchalvak
Copy link

We should collaborate to get a command in place for this! The hard work of the installer is already done, it's a matter of packaging up the replace and run into a yarn command.

@Alecto
Copy link

Alecto commented Nov 1, 2018

still not working?!

@adrianmcli
Copy link

I'll summarize my solution above again here:

  1. Remove Yarn manually

    # remove binaries
    rm -f /usr/local/bin/yarnpkg
    rm -f /usr/local/bin/yarn
    
    # remove cache
    rm -rf ${HOME}/.yarn

    If you have the following in your .zshrc or .bash_profile, remove it:

    export PATH="$PATH:`yarn global bin`"
  2. Install latest Yarn (via curl)

    curl -o- -L https://yarnpkg.com/install.sh | bash

    Make sure there is the following line in your .zshrc or .bash_profile:

    export PATH="$HOME/.yarn/bin:$PATH"
    

Finally, run yarn -v to check your new version number.

@Daniel15
Copy link
Member Author

If anyone wants to work on this... We actually already have code that determines the command that needs to be ran to upgrade Yarn:
https://github.com/yarnpkg/yarn/blob/master/src/cli/commands/install.js#L86-L129

You'd just need to add a "self-upgrade" command that runs the correct command.

@rafael-vitor
Copy link

@Daniel15 I've submitted a pull request for this, looking forward for some feedback. Thanks.

@jose920405
Copy link

This works for me:

brew upgrade yarn
npm update yarn -g

@crmpicco
Copy link

Any news on this? npm update yarn -g works in the meantime I suppose.

@Daniel15
Copy link
Member Author

Any news on this?

@crmpicco For now, you still need to update manually.

@olingern
Copy link
Contributor

olingern commented Jan 30, 2019

It seems that yarn policies set-version [range] was implemented by @arcanis and can grab and set the latest version. Though, the ergonomics of the command don't suggest it installs a new version of Yarn -- it still works.

So, yarn policies set-version nightly will get you on the latest build. PR:
#6673

I'm not sure what that would mean if you want to uninstall yarn, though. 🤔

@ilias-t
Copy link

ilias-t commented Feb 6, 2019

There is an Upgrade Yarn section in the docs: https://yarnpkg.com/en/docs/install

@olingern
Copy link
Contributor

olingern commented Feb 7, 2019

@ilias-t this is not about updating, but rather using the same installation method to update.

@MiroslavPetrik
Copy link

This issue is over 2yrs old, seems like you don't care. Just remove the command, it's not working & misleading.

@arcanis
Copy link
Member

arcanis commented Feb 7, 2019

This command doesn't exist so it'll be hard to remove 🙂

As far as I'm concerned, I believe the original intent of this issue is fixed with yarn policies set-version. In case it doesn't work as expected, please feel free to open a new issue.

@arcanis arcanis closed this as completed Feb 7, 2019
@yarnpkg yarnpkg locked as resolved and limited conversation to collaborators Feb 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.