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

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)

Related

Unable to upgrade yarn (macOS 10.13.6)

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

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.

brew install hadoop installing 2.8.1 version. But needed 2.7.4 version

I have Homebrew 1.3.1
I want to install hadoop 2.7 but brew is installing hadoop 2.8 version.
I tried
brew versions, which is not available anymore.
brew tap homebrew/version, which is now deprecated.
In previous brew version, we were able to use brew tap homebrew/boneyard and then brew versions work. But, now even from homebrew/boneyard the versions command is removed.
Would we good to know the direct command for homebrew to run and install hadoop 2.7.4
(#bfontaine its not a duplicate question as that answer is 6 years ago and no longer works)
You can try running
brew list --versions hadoop
to see if you have previous versions and you can switch to it by running
brew switch hadoop 2.7.4
There is
brew install <package_name>#<version>
Unfortunately it seems hadoop and many other packages haven't set it up to be possible to download the older version and I haven't found out a way to do it.
As I am writing this, there is a version 2.7.7 of hadoop here: https://dist.apache.org/repos/dist/release/hadoop/common/
You can use 'brew edit hadoop' to refer to that version directly, and then run 'brew install hadoop'.

tns doctor not working. WARNING: There was a problem with CocoaPods

I tried installing Nativescript on my machine and successfully ran all the commands but when I ran TNS doctor I got the following error.
Verifying CocoaPods. This may take more than a minute, please be patient.
Installing iOS runtime.tns-ios#2.1.1 ../../var/folders/pr/zxhdgq354w36_v4jnkyg89fr0000gn/T/nativescript-check-cocoapods11679-71167-clmpmh/node_modules/tns-ios
Verifying CocoaPods. This may take some time, please be patient..
sandbox-exec: /Users/myname/.rvm/gems/ruby-2.3.1#global/gems/cocoapods-1.0.1/bin/pod: Operation not permitted
WARNING: There was a problem with CocoaPods
Verify that CocoaPods are configured properly.
There seem to be issues with your configuration.
1
I have googled around for a fix but could not get any answer e.g. https://github.com/NativeScript/nativescript-cli/issues/1943
There was a mention of chmodding ./Pods but that didn't work. Has anyone else had this problem and fixed it?
I have installed and checked cocoapods but it still yields the same error.
Last login: Tue Aug 9 19:24:23 on ttys000
XXX-MacBook-Air:~ mine$ sudo gem install cocoapods
Password:
Successfully installed cocoapods-1.0.1
Parsing documentation for cocoapods-1.0.1
Done installing documentation for cocoapods after 4 seconds
1 gem installed
XXX-MacBook-Air:~ mine$ pod --version
1.0.1
`
Install your CocoaPods with superuser permissions.
sudo gem install cocoapods
And then check if they are installed correctly
pod --version
Also, you might want to update your XCode version if you are using older one.
Refer to this issue for similar problem discussed.
You will need a lower version of cocoapods first you will need to remove your current version sudo gem uninstall cocoapods then you can proceed to install
sudo gem install activesupport -v 4.2.6
sudo gem install cocoapods -v 0.39.0
After installing cocoapods you can try creating a demo app and run it
tns create demoApp
cd demoApp
tns run ios
You can ignore tns doctor for now
After some research I found the right answer (at least for me) and paste it for future references.
currently using:
MacOs Sierra with
xcode: v7.3.0
cocoapods: v1.0.1
nativescript: v2.3.0
node: v6.8.1
Steps:
Locate your node_modules folder where your global npm packages are installed (I am using nvm version manager and node v6.8.1 so it was /Users/myuser/.nvm/versions/node/v6.8.1/lib/node_modules/nativescript/config).
open node_modules/nativescript/config/config.json
Change the value of USE_POD_SANDBOX to false
Reason (as act of faith): NativeScript uses the sandbox-pod executable. This may prevent some pods from installing correctly. If you encounter such cases, you can switch to the regular pod executable.
original source: https://github.com/NativeScript/nativescript-cli/issues/1943#issuecomment-246186556
[Cocoapods problems][1]
[1]: https://i.stack.imgur.com/fCWVI.png
[continue Cocoapods problems][2]
[2]: https://i.stack.imgur.com/trSvT.png
[continue Cocoapods problems][3]
[3]: https://i.stack.imgur.com/iwvhK.png

Resources