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

Use homebrew-versions to install an old version of yarn #1882

Open
zyy7259 opened this issue Nov 16, 2016 · 9 comments
Open

Use homebrew-versions to install an old version of yarn #1882

zyy7259 opened this issue Nov 16, 2016 · 9 comments

Comments

@zyy7259
Copy link

zyy7259 commented Nov 16, 2016

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.

@sonicparke
Copy link

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.

@Falieson
Copy link

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:

  • uninstalled brew's version of node
  • installed node 6 and 7 side-by-side with nvm (node version manager)
  • use .nvmrc and auto-switch bash script for node6 repos

@mysterycommand
Copy link

I would love to see this fixed. If I may rephrase the problem:

  1. I install Yarn early via Homebrew (brew install yarn) and get v0.27.5 and generate a lock file/commit that to Git.
  2. Developer B installs Yarn later via Homebrew (brew install yarn) and gets v1.1.0.
  3. In his or her first 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).
  4. There's no way for me to tell Developer B to just 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 curling 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]

@alvincrespo
Copy link

Yeah running into the same issue as @mysterycommand - your recommendation is what I've been using for a while now.

@dbechrd
Copy link

dbechrd commented Oct 17, 2017

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]

@JamesTheHacker
Copy link

JamesTheHacker commented Dec 22, 2017

@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.

@kevinSuttle
Copy link

kevinSuttle commented Aug 30, 2018

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.

@robertmorgan
Copy link

Here's the solution to anyone wanting to use homebrew for different versions of yarn - or any formula for that matter.

  1. First off, if you already have a version installed, unlink it from brew running the brew unlink yarn command in your terminal.
  2. Next, in a web browser, find the Pull Request that has been merged which contained the formula (version) of Yarn that you want to install.
  3. View the files changed in that Pull Request - there should be one for Formula/yarn.rb.
  4. Click the "View" button for the Formula/yarn.rb file to see the whole contents of the file for that commit.
  5. Click the button to view the "Raw" version of that file. This will open a url which should start with https://raw.githubusercontent.com/....
    This is the URL that you will need for the next step - so copy the complete URL to your clipboard.
  6. Back in your terminal window, use the command brew install followed by the URL that you've copied.
    e.g. to install v1.6.0 of yarn it would be:
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

@calebfaruki
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests