I build a Docker image from the ruby:3.2.3-bullseye
image for a Rails 6.1 project. I install yarn via apt-get (among others), copy the source code and later compile the assets
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list &&\
apt-get install -y yarn nano cron nodejs
The images gets built all right, but every time when compiling assets
rails assets:precompile
I get notified
yarn: no such option: --immutable
I've searched my project for that string, but I can't find it. Who calls yarn with this option?
It's not very important as the assets get compiled successfully, but it makes me nervous, and I'd like to understand what is happening.
There are different yarns
https://packages.debian.org/bullseye/yarn (cmdtest, what you installed)
https://packages.debian.org/bullseye/yarnpkg (JS package manager, what you need)
You need to uninstall current yarn and install correct one
As example this way
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
sudo apt update && sudo apt install yarn
If you use Docker, you should use such command
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt update && \
apt install -y yarn
It's basic command, of course you can add other packages to install command, drop package lists after installation, etc.
Brief explanation:
Also read more about yarn installation in the official docs
https://classic.yarnpkg.com/en/docs/install#debian-stable
You must update package lists after adding new repository. Otherwise apt is not aware of the new repository yet when installing yarn.