Yarn: How to upgrade yarn version using terminal? - ubuntu-16.04

How should yarn be upgraded to the latest version?

For macOS users, if you installed yarn via brew, you can upgrade it using the below command:
brew upgrade yarn
On Linux, just run the below command at the terminal:
$ curl --compressed -o- -L https://yarnpkg.com/install.sh | bash
On Windows, upgrade with Chocolatey
choco upgrade yarn
Credits:
Added answers with the help of the below answers
https://stackoverflow.com/a/54147594/842607
https://stackoverflow.com/a/53710422/842607

npm install --global yarn
npm upgrade --global yarn
This should work.

Not remembering how i've installed yarn the command that worked for me was:
yarn policies set-version
This command updates the current yarn version to the latest stable.
From the documentation:
Note that this command also is the preferred way to upgrade Yarn - it will work no matter how you originally installed it, which might sometimes prove difficult to figure out otherwise.
Reference

On Linux, just run below command at terminal:
$ curl --compressed -o- -L https://yarnpkg.com/install.sh | bash
After do this, close the current terminal and open it again. And then, run below command to check yarn current version:
$ yarn --version

yarn policies set-version
will download the latest stable release
Referenced yarn docs
https://yarnpkg.com/lang/en/docs/cli/policies/#toc-policies-set-version

For Windows users
I usually upgrade Yarn with Chocolatey.
choco upgrade yarn

npm install -g yarn - solved the issue when nothing happened running npm update --global yarn.
Alternative method to update yarn: curl --compressed -o- -L https://yarnpkg.com/install.sh | bash.
Mac users with homebrew can run brew upgrade yarn.
More details here and here.

Works on all OS's
yarn set version latest
yarn set version from sources
Worked without the second line for me, but it is in the documentation for some reason.
Reference

I had an outdated symlink that was preventing me from accessing the proper bin. I had also recently gone through a node upgrade which means a lot of my newer bins were available in a different folder with what i think was a lower priority
Here is what worked for me:
yarn -v
> 1.15.2
which yarn
> /Users/lfender/.yarn/bin/yarn
rm -rf /Users/lfender/.yarn/bin/yarn
npm uninstall --global yarn; npm install --global yarn
> + yarn#1.16.0
> added 1 package in 0.179s
which yarn
> /Users/lfender/.nvm/versions/node/v12.2.0/bin/yarn
yarn -v
> 1.16.0
If you are not using NVM, the location of your bin installs are likely to be unique to your system
From there, I've switched to doing yarn policies set-version as outlined here https://stackoverflow.com/a/55278430/1426788 to define my yarn version at the repo level

According to https://yarnpkg.com/getting-started/install#updating-to-the-latest-versions
yarn set version <version>
For example to upgrade yarn v1.22.4 to v1.22.10:
yarn set version 1.22.10

I updated yarn on my Ubuntu by running the following command from my terminal
curl --compressed -o- -L https://yarnpkg.com/install.sh | bash
source:https://yarnpkg.com/lang/en/docs/cli/self-update

Add Yarn Package Directory:
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
Install Yarn:
sudo apt-get update && sudo apt-get install yarn
Please note that the last command will upgrade yarn to latest version if package already installed.
For more info you can check the docs: yarn installation

If you already have yarn 1.x and you want to upgrade to yarn 2. You need to do something a bit different:
yarn set version berry
Where berry is the code name for yarn version 2. See this migration guide here for more info.

I tried at first
yarn policies set-version
Then it directed me to run
yarn set version stable
You should implement them in order, the first command will download your current yarn version and update .yarnrc after that running the second command will upgrade yarn successfully to the latest stable version

I tried all of the above solutions in Jenkins pipeline which needs the latest yarn.
Finally, this worked for me.
Run yarn policies set-version in the git repo
This will generate .yarn/releases/yarn-X.X.X.js file and .yarnrc file. Push both of these files in the Git repo.
Now build and all the yarn commands will use the yarn-X.X.X version.
Note: This is helpful when you don't have root access to npm install -g yarn.

npm i -g yarn
This should update your yarn version. Check version with yarn -v or yarn --version.

yarn policies set-version --rc
As per the yarn documentation to update yarn to latest version we should run the above command. Check version with yarn -v or yarn --version.
Ref : https://classic.yarnpkg.com/en/docs/cli/policies/#toc-policies-set-version

yarn policies set-version
Use the above command in powershell to upgrade your current yarn version to Latest.It will download the latest yarn release

yarn policies set-version
this upgraded my yarn version from 1.22.5 to 1.22.10

If You want to upgrade your yarn version from 1.22.5 to 1.22.10
yarn policies set-version

To upgrade to latest version of yarn, run the below command on your terminal.
"yarn set version latest -g"

This work for me to change yarn version 0.32 git to 1.22.5
https://www.codegrepper.com/code-examples/shell/yarn+0.32+git+ubuntu

Since you already have yarn installed and only want to upgrade/update. you can simply use
yarn self-update
Find ref here https://yarnpkg.com/en/docs/cli/self-update

Related

Running sbt in a Docker Container

I am trying to use Github actions for my scala project and created a Docker workflow for it. Basically, I am trying to install sbt into my container and run the project.
Dockerfile looks like this:
FROM centos:centos8
ENV SCALA_VERSION 2.13.1
ENV SBT_VERSION 1.5.2
RUN yum install -y epel-release
RUN yum update -y && yum install -y wget
# INSTALL JAVA
RUN yum install -y java-11-openjdk
# INSTALL SBT
RUN wget http://dl.bintray.com/sbt/rpm/sbt-${SBT_VERSION}.rpm
RUN yum install -y sbt-${SBT_VERSION}.rpm
RUN wget -O /usr/local/bin/sbt-launch.jar http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/$SBT_VERSION/sbt-launch.jar
WORKDIR /root
EXPOSE 8080
RUN sbt compile
CMD sbt run
But when I push anything, I get the following error:
The command '/bin/sh -c wget http://dl.bintray.com/sbt/rpm/sbt-${SBT_VERSION}.rpm' returned a non-zero code: 8
When I check the link manually (by setting the sbt version), I see indeed bintray responds with 403 forbidden error but status.bintray.com tells all systems are operational.
Am I doing something wrong or is something wrong with bintray?
Forbidden doesnt mean non operational.
I think that url is incorrect as its not hosted on bintray rather jfrog, please see section on Centos which states
remove old Bintray repo file
https://www.scala-sbt.org/1.x/docs/Installing-sbt-on-Linux.html

My action runner for github is failing. How do I resolve yarn: command not found. Process completed with exit code 127?

I was running a self hosted github action runner but my jobs were failing with this error message in the picture. I searched stackoverflow before posting the question but couldn't find any relevant threads. Let me know if there are threads that I missed.
How do I resolve this error so that my github action runner can run my CI builds again?
The built-in GitHub Action runners have yarn installed on them by default but a self-hosted runner won't unless you install it. See relevant issue here: https://github.com/actions/setup-node/issues/182.
If you don't want to install yarn on your self-hosted runner you can install it in the workflows that need it. Just make sure to uninstall it afterward to keep your self-hosted runners clean.
# You'll need to make sure node is installed first
- name: Install Node
uses: actions/setup-node#v3
with:
node-version-file: '.node-version'
- name: Install yarn
run: npm install -g yarn
# Do what you need to do with yarn
# Uninstall when you're done
- name: Clean up
if: always()
run: npm uninstall -g yarn
I realised that the issue was literally as described in the error that for some reason yarn was not found on my computer. This was a little strange as I remembered installing yarn before.
Nevertheless I ran
brew install yarn
And ran brew update and upgrade just in case my homebrew was outdated
brew update
brew upgrade
And it resolved the error and issues.

I have upgraded to ionic 4 but my project doesnt support the version now I need to downgrade to ionic 3. What should i do? [duplicate]

The recent version is 3.2.0 and I'm facing lot's of issues with it like the ionic serve command not working.
npm install -g ionic#version_number
ex: if you want to install ionic 2.5.0,
npm install -g ionic#2.5.0
edit: to list all versions of ionic, npm info ionic
You can downgrade to your old version by running below command:
npm install -g ionic#3.9.2
Get your version here
IONIC CLI VERSIONS
You may try uninstalling it first: npm uninstall -g ionic
then install it again with the version that you want to install npm install -g ionic#x.x.x
then check ionic version with ionic --version you may need to restart your terminal to get the latest version running
First thing first, uninstall the current version:
npm uninstall -g ionic
then, install the version you want :
npm install -g ionic#"the version for example #3.20.0"
You just need to do like this:
npm install -g ionic#3.1.0
Changelog
Sometimes it throws error while overwriting the existing files , so add --force
Ex, If you want to downgrade to version 3.20, run:
npm i -g ionic#3.20 --force

How to install VS Code in Alpine Linux

I have an operating environment that is Alpine linux only and I need to install VS Code. How can VS Code be run on Alpine Linux?
Dockerfile:
FROM node:14.19.0-alpine
RUN set -x \
&& sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories \
&& apk upgrade \
&& apk --no-cache add alpine-sdk bash libstdc++ libc6-compat \
&& npm config set python python3
RUN git clone --recursive https://github.com/cdr/code-server.git
RUN cd code-server
RUN yarn global add code-server
ENV PASSWORD=changeme
ENTRYPOINT code-server --bind-addr 0:8443
Commands:
docker build . -t vscode
docker run -d -e PASSWORD=111111 -p8443:8443 vscode:latest
http://hostname:8443
Download it in Flatpak repos, it will run natively in a Gnome SDK environment.
Use a self-hosted environment such as Theia (https://www.theia-ide.org/index.html) or coder-editor (https://coder.com/). I've never tried them, I use the Flatpak one, but they seem interesting (you can "build" your osn editor in a Node environment).
Apologies for necrobump, but as what Marco suggested, coder.com has moved to github
the software, code-server is quite litterally VSCode, as a web application, I have been using this for about half a year and it is quite well developed, Alpine support is still spotty but i recall getting a few releases to function well a while back when i ran Alpine as my main.

Install ruby 2.1.5 via rbenv

I already have rbenv version 0.4.0-97-gfe0b243 installed, that manages ruby version 2.1.1
Now, I also want it to manage ruby 2.1.5
But, when I do rbenv install --list then I see max ruby 2.1.2 and then 2.2.0-dev. What should I do for getting version 2.1.5 ?
The following code helped me get over the situation.
GOTO
cd ~/.rbenv/plugins/ruby-build
git pull
Now I can see 2.1.5 also listed in rbenv install --list
You can perform an upgrade on ruby-build.
$ brew update
$ brew upgrade rbenv ruby-build
$ rbenv install --list
Note: I have tested the following procedure on Ubuntu 16.04, it work for me. I am assuming that you have already installed the rbnev on your system successfully. To check is it working properly or not? run the command rbenv -v
it will give you output like this.
rbenv 1.0.0-33-gc7dcaf1
but in your System the version of rbenv version may be different.
Run the following command to install required version of ruby.
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL
rbenv install --list
select appropiate available of ruby as per your requirement 2.1.5
rbenv install 2.1.5
rbenv global 2.1.5
rbenv rehash
ruby -v