LoginSignup
1
2

More than 3 years have passed since last update.

Dockerでyarnを入れたはずなのに「ERROR: There are no scenarios; must have at least one」と怒られた時の対処法

Last updated at Posted at 2020-11-18

背景

Dockerでyarnを入れたはずでしたが、いざ以下コマンドを叩いてみると怒られた

Dockerfileの中身

FROM ruby:2.5
RUN apt-get update && apt-get install -y \
    build-essential \
    libpq-dev \
    nodejs \
    postgresql-client \
    yarn
WORKDIR /kosare
COPY Gemfile Gemfile.lock /kosare/
RUN bundle install

yarnコマンドでエラー発生

root@5847e387581e:/kosare# yarn -v
ERROR: There are no scenarios; must have at least one.

解決策(一時的な解決策)

基本的には参考に記載のURLと同じことをすれば解決します。
私の場合はすでにrootで入っていたので、sudoと記載している部分はなくして順番に実行したら解決しました。

古いyarnを削除

sudo apt remove cmdtest
sudo apt remove yarn

最新を取得

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

update

apt-get update 

再インストール

apt-get install yarn

バージョン確認

yarn -v

解決策(根本的な解決策)

上記のやり方だと、dockerで再度bundle installし直した時に再度同じ事象が発生する。
Dockerfileでbuildした際に解決したいため、以下の2行をdockerfileに追記する。

RUN curl https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list

Dockerfile(最終形)

FROM ruby:2.5
RUN curl https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update && apt-get install -y \
    build-essential \
    libpq-dev \
    nodejs \
    postgresql-client \
    yarn
WORKDIR /kosare
COPY Gemfile Gemfile.lock /kosare/
RUN bundle install

これでbuildしなおせば、yarnがちゃんと使えるはず。

参考

https://k-koh.hatenablog.com/entry/2020/04/02/143017
https://github.com/yarnpkg/yarn/issues/7329
https://qiita.com/MasatoraAtarashi/items/3f0317cd648ff63fa92c

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2