Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

yarn self-update throws OAuth2 Authentication error

I am trying out the yarn self-update command to see how it works, but instead of updating the Yarn version, it throws an OAuth error like so

yarn self-update
yarn self-update v0.15.1
error OAuth2 authentication requires a token or key & secret to be set
    at __dirname.authenticate (/Users/nikjohn/.nvm/versions/node/v6.4.0/lib/node_modules/yarn/node_modules/github/lib/index.js:334:23)
    at Object.<anonymous> (/Users/nikjohn/.nvm/versions/node/v6.4.0/lib/node_modules/yarn/lib/cli/commands/self-update.js:30:12)
    at next (native)
    at step (/Users/nikjohn/.nvm/versions/node/v6.4.0/lib/node_modules/yarn/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
    at /Users/nikjohn/.nvm/versions/node/v6.4.0/lib/node_modules/yarn/node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14
    at new Promise (/Users/nikjohn/.nvm/versions/node/v6.4.0/lib/node_modules/yarn/node_modules/core-js/library/modules/es6.promise.js:191:7)
    at Object.<anonymous> (/Users/nikjohn/.nvm/versions/node/v6.4.0/lib/node_modules/yarn/node_modules/babel-runtime/helpers/asyncToGenerator.js:14:12)
    at Object.run (/Users/nikjohn/.nvm/versions/node/v6.4.0/lib/node_modules/yarn/lib/cli/commands/self-update.js:99:17)
    at run (/Users/nikjohn/.nvm/versions/node/v6.4.0/lib/node_modules/yarn/lib/cli/index.js:237:18)
    at config.init.then (/Users/nikjohn/.nvm/versions/node/v6.4.0/lib/node_modules/yarn/lib/cli/index.js:345:12)
info Visit http://yarnpkg.com/en/docs/cli/self-update for documentation about this command.

Does anybody know why this is and what needs to be done to resolve this? According to the docs here, this command does not have any such OAuth dependency and IMHO it shouldn't either.

Looks like there's a PR for this already here

Edit: Further research shows this is a known bug with Yarn. But a resolution is still not available. It would be a weird catch22 if the fix is pushed out as a new version, but users can't update because the command fails. One possible solution is yarn self-update [tag] instead of yarn self-update, but this remains a bug.*

Edit: I realized there's another workaround

yarn version
yarn version <version-number>
like image 354
nikjohn Avatar asked Oct 13 '16 20:10

nikjohn


3 Answers

Use npm -g install yarn to update it. I got upgreaded to yarn v0.16.0 and now yarn self-update seems to work.

like image 83
omittones Avatar answered Nov 18 '22 01:11

omittones


First remove Yarn with this command:

rm -rf ~/.yarn

And then install it again, using this command (for example):

curl -o- -L https://yarnpkg.com/install.sh | bash
like image 27
Michaël Perrin Avatar answered Nov 18 '22 02:11

Michaël Perrin


TL;DR

Update to ≥0.16.0:

Ubuntu

apt-get update ; apt-get install yarn

MacOS

brew update ; brew upgrade

NPM

npm install -g yarn --update

Explanation

Had the issue on 0.15.0, and looking into it lots of people add the same issue.

$ yarn --version
0.15.0

Reading the release notes for v0.16.0

Fix self-update (#676)

So simply update :

yarn self-update
yarn self-update v0.16.0
success Yarn is already using the latest version.
Done in 0.69s.
like image 1
Édouard Lopez Avatar answered Nov 18 '22 00:11

Édouard Lopez