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

Your current version of Yarn is out of date "npm upgrade --global yarn" should be "npm install --global yarn" #3042

Closed
crucialfelix opened this issue Apr 5, 2017 · 25 comments

Comments

@crucialfelix
Copy link

crucialfelix commented Apr 5, 2017

Current yarn: 0.19.1

bug

What is the current behavior?

The "yarn is out of date" message posts an npm command. This command doesn't succeed in updating yarn.

warning Your current version of Yarn is out of date. The latest version is "0.21.3" while you're on "0.19.1".
info To upgrade, run the following command:
$ npm upgrade --global yarn

But this command doesn't do it. yarn remains at 0.19.1

If the current behavior is a bug, please provide the steps to reproduce.

data-projector ❯ which yarn
/Users/crucial/.nvm/versions/node/v6.9.1/bin/yarn
data-projector ❯ npm upgrade --global yarn
data-projector ❯ yarn --version
0.19.1

data-projector ❯ npm --version
3.10.8

The npm command that works is install:

npm install --global yarn

yarn --version
0.21.3
data-projector ❯ npm install --global yarn
/Users/crucial/.nvm/versions/node/v6.9.1/bin/yarn -> /Users/crucial/.nvm/versions/node/v6.9.1/lib/node_modules/yarn/bin/yarn.js
/Users/crucial/.nvm/versions/node/v6.9.1/bin/yarnpkg -> /Users/crucial/.nvm/versions/node/v6.9.1/lib/node_modules/yarn/bin/yarn.js
- once@1.3.3 node_modules/yarn/node_modules/end-of-stream/node_modules/once
- exit-hook@1.1.1 node_modules/yarn/node_modules/exit-hook
- supports-color@0.2.0 node_modules/yarn/node_modules/gauge/node_modules/supports-color
- generate-function@2.0.0 node_modules/yarn/node_modules/generate-function
- is-finite@1.0.2 node_modules/yarn/node_modules/is-finite
- is-property@1.0.2 node_modules/yarn/node_modules/is-property
- generate-object-property@1.2.0 node_modules/yarn/node_modules/generate-object-property
- is-utf8@0.2.1 node_modules/yarn/node_modules/is-utf8
- jsonpointer@4.0.1 node_modules/yarn/node_modules/jsonpointer
- is-my-json-valid@2.15.0 node_modules/yarn/node_modules/is-my-json-valid
- os-shim@0.1.3 node_modules/yarn/node_modules/os-shim
- pinkie@2.0.4 node_modules/yarn/node_modules/pinkie
- pinkie-promise@2.0.1 node_modules/yarn/node_modules/pinkie-promise
- repeating@2.0.1 node_modules/yarn/node_modules/repeating
- typedarray@0.0.6 node_modules/yarn/node_modules/typedarray
- concat-stream@1.6.0 node_modules/yarn/node_modules/concat-stream
- spawn-sync@1.0.15 node_modules/yarn/node_modules/spawn-sync
- diff@2.2.3 node_modules/yarn/node_modules/diff
- user-home@2.0.0 node_modules/yarn/node_modules/user-home
/Users/crucial/.nvm/versions/node/v6.9.1/lib
└─┬ yarn@0.21.3

...

data-projector ❯ yarn --version
0.21.3

Now I know this sounds like an npm bug, certainly not a yarn bug.
According to npm docs it should be upgrade.

What is the expected behavior?

This:

if (YARN_INSTALL_METHOD === 'npm') {

should say:

return 'npm install --global yarn';

But honestly I'm not sure.

Please mention your node.js, yarn and operating system version.

Node 6.9.1
npm 3.10.8
OS X el capitain

@crucialfelix
Copy link
Author

I'm closing this because it must be an npm bug. The command posted should be what npm documentation suggests.

@wsfuller
Copy link

There's a bit of a discussion on this on #1139 that ties into other issues.

npm install -g yarn solved the issue for me when nothing happened running npm update --global yarn.

Curious as to why there is a prompt for npm update --global yarn when the command doesn't do anything. And Yarn self-update is currently not available. Feels like there aren't any viable options other than doing an install.

@adamreisnz
Copy link

npm install -g yarn is the only thing that works. The message should be updated, even though upgrade should work, it clearly doesn't.

@XaserAcheron
Copy link

+1 for changing the help text to npm install -g yarn. Some thoughts on why:

Though this indeed is technically an npm bug, the relevant GitHub issue ( npm/npm#11534 ) has fallen victim to their new auto-close policy. Even if this was sneakily fixed at some point anyway, yarn users are now dependent on npm being up to date in order to ensure yarn's suggestion works, which is a weird pseudo-dependency.

In an ideal world, this would be fixed npm-side and the point would be moot, but I'd rather see yarn give consistently helpful documentation rather than rely on behavior of the tool it's meant to replace.

@crucialfelix crucialfelix reopened this Jun 26, 2017
@adamreisnz
Copy link

Is there a particular reason by the way why we can't use yarn to upgrade yarn?

@crucialfelix
Copy link
Author

I've installed yarn with brew now (OS X). Then it is available with any version of node I have active (I use nvm). Otherwise you have to install yarn in each node version global.

brew upgrade yarn

@adamreisnz
Copy link

adamreisnz commented Jun 27, 2017 via email

@M-ZubairAhmed
Copy link

I too faced the same warning.
I looked into api docs for upgrading the issue. But i ended up following the tutorial for installing yarn and installed it again. It upgraded my yarn and the above warning didnt show up when i ran the command(which was yarn install for my repo) again.

@BirkhoffLee
Copy link

I encountered the same thing today, but the command is quite different :

warning Your current version of Yarn is out of date. The latest version is "1.0.2" while you're on "0.19.1".
info To upgrade, run the following command:
$ curl -o- -L https://yarnpkg.com/install.sh | bash

The command doesn't work either, unfortunately.

@adamreisnz
Copy link

adamreisnz commented Sep 21, 2017 via email

@BYK
Copy link
Member

BYK commented Sep 21, 2017

@BirkhoffLee that should work actually. What's the error you are getting?

BYK added a commit that referenced this issue Sep 21, 2017
**Summary**

Fixes #3042.

**Test plan**

Manual verification.
@BirkhoffLee
Copy link

BirkhoffLee commented Sep 21, 2017 via email

@arcanis
Copy link
Member

arcanis commented Sep 22, 2017

@BirkhoffLee The command displayed changes depending on how you've installed Yarn, so a different command isn't unusual.

@BYK BYK closed this as completed in #4511 Sep 22, 2017
BYK added a commit that referenced this issue Sep 22, 2017
**Summary**

Fixes #3042.

**Test plan**

Manual verification.
joaolucasl pushed a commit to joaolucasl/yarn that referenced this issue Oct 27, 2017
**Summary**

Fixes yarnpkg#3042.

**Test plan**

Manual verification.
@timhc22
Copy link

timhc22 commented Nov 1, 2017

On Mac npm install -g yarn didn't upgrade yarn for me, but then I noticed that I already had it installed with homebrew so uninstalled from there and then ln -s ~/.nvm/versions/node/v6.11.0/bin/yarn /usr/local/bin/yarn. I had stopped using it, but needed to reuse for a library which was using it.

@konekoya
Copy link

konekoya commented Nov 9, 2017

Not sure if this will help anyone? I'm on macOS.
For people who have installed yarn with shell script like mentioning in here
And wanted to upgrade yarn with npm. You first need to rm -rf .yarn/ dir and then install yarn again with npm install -g yarn. Otherwise, you won't be able to use the newly installed yarn in your CLI. It will keep using the old one that you've installed with shell script.

@vijaychouhan-rails
Copy link

When I did run npm install -g yarn
then I got the deprecated warning and it did nothing

npm WARN deprecated yarn@1.3.2: It is recommended to install Yarn using the native installation method for your environment.

So I fixed it for:
1) On Debian or Ubuntu Linux, you can install Yarn via our Debian package repository. You will first need to configure the repository:


curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

2) sudo apt-get update && sudo apt-get install yarn

Now my installed yarn version is updated

@rmariuzzo
Copy link

rmariuzzo commented Jan 22, 2018

What helped me was:

  1. brew uninstall --force yarn.
  2. rm -rf ~/.yarn.
  3. npm install --global yarn

😎

@javadoug
Copy link

javadoug commented Feb 6, 2018

brew uninstall --force yarn
rm -rf ~/.yarn
# follow instructions here https://yarnpkg.com/en/docs/install
# on macOS --without-node bc I use nvm
brew install yarn --without-node

@Mark-A-A
Copy link

For those with Homebrew: brew upgrade yarn worked just fine

@s-h-a-d-o-w
Copy link

It's nice and all that there are so many workarounds for Mac users but... surely, I'm not the only Windows user? curl doesn't exactly do anything there...

What's the problem with npm install -g yarn? Why was that not used for the warning instead of curl?

@pstanton
Copy link

pstanton commented May 23, 2018

I can't update yarn by npm update --global yarn or npm install --global yarn

When I run the above it says 1.6.0 installed, however if i then run yarn --version it is stuck on 1.3.2.

I can't remember how I installed yarn to begin with.

(windows)

** UPDATE **

i had used choco, so choco upgrade yarn in an elevated shell worked for me

@Rolando-Barbella
Copy link

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

@gabrielguita
Copy link

What helped me was:

  1. brew uninstall --force yarn.
  2. rm -rf ~/.yarn.
  3. npm install --global yarn

😎

This worked like a charm, cheers man!

@brandonros
Copy link

Somebody needs to publish 1.15.2 to npm. https://www.npmjs.com/package/yarn It's showing 1.13.0 while stable on http://yarnpkg.com is 1.15.2

@nhustak
Copy link

nhustak commented Jun 30, 2019

Just an FYI for anyone else running into this issue. It ended up I had apparently installed Yarn through a windows installer. It was finding this one first. I uninstalled it windows via Programs and Features and it then picked up the new one.

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