Unable to upgrade yarn (macOS 10.13.6) - macos

I have a mac with yarn 1.10.1 installed (i don't remember how i installed it probably with brew)
And i'm trying to upgrade to the latest version
brew upgrade yarn
returns: Error: yarn 1.15.2 already installed
brew list --versions yarn
returns: yarn 1.15.2
brew switch yarn 1.15.2
returns: Cleaning /usr/local/Cellar/yarn/1.15.2
2 links created for /usr/local/Cellar/yarn/1.15.2
yarn -v
returns: 1.10.1

Related

Command not found: corepack when installing Yarn on Node v17.0.1

I'm following the Yarn installation instructions on Yarn's website (https://yarnpkg.com/getting-started/install). Those instructions say that on Node version 16.10.0 and higher you can install Yarn by enabling corepack with the following command:
corepack enable
However, running that command returns:
zsh: command not found: corepack
I installed Node via Homebrew and node -v returns v17.0.1. I'm on an M1 Mac running Big Sur.
Because I had installed node via nvm (and I had installed nvm using Homebrew), the corepack command wasn't available. The fix that worked for me was to install corepack via homebrew by running:
brew install corepack
After installing corepack via homebrew, I was able to run the corepack enable command from the terminal and the yarn command became available as well.
Was facing a similar issue with node installed using asdf. Also using zsh and zsh asdf plugin.
Node version: 16.13.1
Ran corepack enable - and got
zsh: command not found: yarn
What solved for me:
asdf reshim nodejs
Also try to run
corepack prepare yarn#3.1.1 --activate
before reshim
I solved it like this:
From the https://github.com/nodejs/corepack docs
npm uninstall -g yarn pnpm
npm install -g corepack
Use with 'sudo' if you're using OSX

How do I change the version of yarn used by my system?

I am running Mac OS X 10.14.6 and I am trying to get the latest version of yarn installed and working on my system.
So I installed it with Homebrew, it tells me that I already have it installed on my system:
$ brew install yarn
Warning: yarn 1.21.1 is already installed and up-to-date
But when I do yarn --version, I get this:
$ yarn --version
[DEPRECATION] The trollop gem has been renamed to optimist and will no longer be supported. Please switch to optimist as soon as possible.
Yarn v0.1.1 2011 Jesper Kjeldgaard
So I try to reinstall it and the following happens:
To reinstall 1.21.1, run `brew reinstall yarn`
Transmit-Live $ yarn --version
[DEPRECATION] The trollop gem has been renamed to optimist and will no longer be supported. Please switch to optimist as soon as possible.
Yarn v0.1.1 2011 Jesper Kjeldgaard
Transmit-Live $ brew reinstall yarn
==> Reinstalling yarn
==> Downloading https://yarnpkg.com/downloads/1.21.1/yarn-v1.21.1.tar.gz
Already downloaded: /Library/Caches/Homebrew/downloads/784c559ca8d97--yarn-v1.21.1.tar.gz
🍺 /usr/local/Cellar/yarn/1.21.1: 14 files, 5MB, built in 8 seconds
Transmit-Live $ yarn --version
[DEPRECATION] The trollop gem has been renamed to optimist and will no longer be supported. Please switch to optimist as soon as possible.
Yarn v0.1.1 2011 Jesper Kjeldgaard
I have also tried brew switch and that doesn't work:
$ brew switch yarn 1.21.1
Cleaning /usr/local/Cellar/yarn/1.21.1
2 links created for /usr/local/Cellar/yarn/1.21.1
Transmit-Live $ yarn --version
[DEPRECATION] The trollop gem has been renamed to optimist and will no longer be supported. Please switch to optimist as soon as possible.
Yarn v0.1.1 2011 Jesper Kjeldgaard
Edit 1
I even tried to do brew upgrade yarn and it is the same issue:
$ brew upgrade yarn
Warning: yarn 1.21.1 already installed
Transmit-Live $ yarn --version
[DEPRECATION] The trollop gem has been renamed to optimist and will no longer be supported. Please switch to optimist as soon as possible.
Yarn v0.1.1 2011 Jesper Kjeldgaard
Edit 2
Output of which yarn:
$ which yarn
/.rvm/gems/ruby-2.7.0#myapp/bin/yarn
How do I fix this?
Thanks.
I figured it out.
Basically what was happening is that I had two versions of yarn installed. One was a gem, and the other was the yarn executable.
So I simply ran gem uninstall yarn and it fixed it.
$ gem uninstall yarn
Remove executables:
yarn
in addition to the gem? [Yn] Y
Removing yarn
Successfully uninstalled yarn-0.1.1
Now when I do yarn --version it works properly.
$ yarn --version
1.21.1
You can upgrade a package with brew upgrade, so something like
brew upgrade yarn
You may need to get homebrew to update it's package list first, with brew update
[Edit]
In your case there is some confusion, the yarn package that brew installs is the javascript package manager, whereas the yarn you have on your path is the ruby gem. You can upgrade the latter with gem update yarn. If you want to use the JavaScript package manager, try modifying your path, or use the fully qualified path (something like /use/local/bin/yarn)

How do I upgrade yarn to a specific version

The Yarn documentation tells us how to upgrade to the latest version, but does not explain how to upgrade to a specific non-latest version.
I need a specific version to match our CI server.
How do I specify the version that I want?
run yarn policies set-version <version> from the project directory
https://classic.yarnpkg.com/en/docs/cli/policies/#toc-policies-set-version
As you can see in the documentation, you can provide a version to the curl-install command with the --version flag.
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version [version]
In case you are using brew:
brew switch yarn [version]
Or maybe you installed it with npm as global package, then update like that:
npm install --global yarn#[version]
yarn set version [version.number] should work.
You can specify the yarn version using install in the following way:
Assuming you want version 1.7.0:
yarn upgrade v1.7.0
On Mac OSX 12.2.1 had following message when tried yarn upgrade v1.22.17
warning Your current version of Yarn is out of date. The latest version is "1.22.17", while you're on "1.22.4".
info To upgrade, run the following command:
$ brew upgrade yarn
success Saved 0 new dependencies.
So just did brew upgrade yarn and yarn --version returned 1.22.17

Why doesn't yarn updated when running upgrade?

I'm trying to use latest yarn version after upgrading it.
I've follow over https://yarnpkg.com/en/docs/install#mac-stable instructions, but yarn didn't really upgraded.
After running brew upgrade yarn:
$ brew upgrade yarn
Updating Homebrew...
Error: yarn 1.9.4 already installed
And after running yarn --version:
$ yarn --version
1.9.2
Is there any way to use the latest version?
Although the guide says that brew upgrade yarn should do it automatically..
There's a lengthy thread on Github regarding upgrades; here's what is suggested for HomeBrew:
brew upgrade yarn
brew link --overwrite yarn
Then try yarn -v
If that fails then you could:
First, uninstall brew's yarn:
brew uninstall yarn
Removing yarn binaries manually:
rm -f /usr/local/bin/yarnpkg
rm -f /usr/local/bin/yarn
Remove yarn cache:
rm -rf ${HOME}/.yarn
If you have the following in your .zshrc or .bash_profile, remove it:
export PATH="$PATH:`yarn global bin`"
Install 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"
↳ Github : yarn update discussion thread
If you installed yarn with npm in an nvm environment then you can just run npm -g upgrade yarn. To check that run which yarn -- if you see .nvm in the result of that, you are in an nvm environment.

mongodb devel cannot be installed on macosx with homebrew

I tried to install mongodb development version with this command as per the documentation:
brew install mongodb --devel
But it fails with this message:
Error: No devel block is defined for mongodb
brew install mongodb works normally. I am using OSX El Capitan 10.11.2.
That didn't work because mongodb is no longer on --devel branch.
This works:
brew install -v --fresh mongodb

Resources