Do you want to request a feature or report a bug?
feature
What is the current behavior?
I use yarn 0.16.1, and want to update a dev dep. But yarn does not properly update the package.json
file.
So I search around and found #1458. In this issue, it said the latest yarn has fix the problem. So I use brew to update to yarn 0.17.2 but encounter another problem similar like this #1834.
What is the expected behavior?
The first thing came into my mind is that I need to downgrade yarn to a working version. Then I found this question on stackoverflow.
Luck for me, I still have the old version installed. So I can easily switch to an old version use brew switch yarn 0.16.1
. But what if someone have only installed the newest version of yarn and it does not work. So I think it would be nice if we can install an old version through homebrew-versions. But I am not very familiar with brew. So is there anyone who can write some formulas and upload to homebrew-versions.
I ran into this today and I do not have the previous version of yarn already installed via brew. So now I am a bit stuck.
yarn (0.23.2) isn't tied to the node version, it will run whatever version of node your terminal environment has declared
My solution:
nvm
(node version manager)I would love to see this fixed. If I may rephrase the problem:
brew install yarn
) and get v0.27.5 and generate a lock file/commit that to Git.brew install yarn
) and gets v1.1.0.yarn install
that version of Yarn invalidates the lock file (unexpected/confusing), and possibly resolves some dependencies differently (we are currently running into this in a way that's causing Jest snapshots to be generated differently depending on which version of Yarn is used to install dependencies).brew switch yarn 0.27.5
(they haven't installed that version) and brew search yarn
doesn't yield anything but the latest version.As a work around it's still possible to do the following, but it involves curl
ing into bash
which is fine looking at that install script, but also just kinda gross:
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version [version]
Yeah running into the same issue as @mysterycommand - your recommendation is what I've been using for a while now.
The recommend solution in this StackOverflow answer fixed it well enough for my script to proceed, but I'm not sure what side effects it has. It certainly doesn't enable a brew switch
.
npm install --global yarn@[version]
@mysterycommand the install script doesn't. It references an invalid URL that doesn't exist.
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.3.1 [~]âœ
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 6988 0 6988 0 0 4999 0 --:--:-- 0:00:01 --:--:-- 5002
Installing Yarn!
> Downloading tarball...
[1/2]: https://yarnpkg.com/downloads/1.3.1/yarn-v1.3.1.tar.gz --> /var/folders/lp/qxycffd53lxdhbhvy34lymrh0000gn/T/yarn.tar.gz.XXXXXXXXXX.te6FzQAf
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 91 100 91 0 0 69 0 0:00:01 0:00:01 --:--:-- 69
0 0 0 0 0 0 0 0 --:--:-- 0:00:02 --:--:-- 0curl: (22) The requested URL returned error: 404 Not Found
[2/2]: https://yarnpkg.com/downloads/1.3.1/yarn-v1.3.1.tar.gz.asc --> /var/folders/lp/qxycffd53lxdhbhvy34lymrh0000gn/T/yarn.tar.gz.XXXXXXXXXX.te6FzQAf.asc
100 95 100 95 0 0 115 0 --:--:-- --:--:-- --:--:-- 0
curl: (22) The requested URL returned error: 404 Not Found
> Failed to download https://yarnpkg.com/downloads/1.3.1/yarn-v1.3.1.tar.gz.
curl -o- -L https://yarnpkg.com/install.sh | bash
ignores/trumps both brew
and npm
installed versions, placing a .yarn
directory at ~
. Deleting that worked for me because that's where the executable is.
Here's the solution to anyone wanting to use homebrew for different versions of yarn - or any formula for that matter.
brew unlink yarn
command in your terminal.Formula/yarn.rb
.Formula/yarn.rb
file to see the whole contents of the file for that commit.https://raw.githubusercontent.com/...
.brew install
followed by the URL that you've copied.brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/fba7635ab69384ac980c635483a7af825bc06088/Formula/yarn.rb
You can then verify the versions available to Homebrew by running: brew list --versions yarn
, and switch between versions using brew switch yarn VERSION_NUMBER
Using a CI tool that is locked to Yarn 1.13.0. Used this command.
brew uninstall yarn && curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.13.0
In effect, I don't have yarn managed by brew anymore. But I still added it to my path using the following:
echo 'export PATH=$PATH:~/.yarn/bin/yarn' >> ~/.bash_profile
source ~/.bash_profile
Good enough for me. But having it managed by brew seems preferable.
Most helpful comment
Here's the solution to anyone wanting to use homebrew for different versions of yarn - or any formula for that matter.
brew unlink yarn
command in your terminal.Formula/yarn.rb
.Formula/yarn.rb
file to see the whole contents of the file for that commit.https://raw.githubusercontent.com/...
.This is the URL that you will need for the next step - so copy the complete URL to your clipboard.
brew install
followed by the URL that you've copied.e.g. to install v1.6.0 of yarn it would be:
You can then verify the versions available to Homebrew by running:
brew list --versions yarn
, and switch between versions usingbrew switch yarn VERSION_NUMBER