admin管理员组

文章数量:1387352

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 .gpg | apt-key add && \
    echo "deb / 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.

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/debian/pubkey.gpg | apt-key add && \
    echo "deb https://dl.yarnpkg/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.

Share Improve this question edited Apr 2 at 11:17 MDickten asked Mar 17 at 10:22 MDicktenMDickten 1601 silver badge12 bronze badges 1
  • output for which yarn: /usr/bin/yarn – MDickten Commented Mar 18 at 12:07
Add a comment  | 

2 Answers 2

Reset to default 1

There are different yarns

https://packages.debian./bullseye/yarn (cmdtest, what you installed)

https://packages.debian./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/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg/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/debian/pubkey.gpg | apt-key add - && \
    echo "deb https://dl.yarnpkg/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:

  1. Add correct repository
  2. Update package lists
  3. Install correct package

Also read more about yarn installation in the official docs

https://classic.yarnpkg/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.

If you want to continue using Yarn 1.x, replace --immutable with --frozen-lockfile, which is the equivalent option for that version.

本文标签: rails assetsprecompile gives yarn no such option immutable (Rails 6Ruby 3)Stack Overflow