質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Yarn

Yarnは、Facebook/Exponent/Google/Tildeが開発したJavaScriptのパッケージマネージャ。npmよりもインストールが速く、厳密にモジュールのバージョンを固定できるなど、npmの問題を解決。npmと互換性があり、同じpackage.jsonを使用できます。

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails 6

Ruby on Rails 6は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

RSpec

RSpecはRuby用のBDD(behaviour-driven development)フレームワークです。

Docker

Dockerは、Docker社が開発したオープンソースのコンテナー管理ソフトウェアの1つです

Q&A

0回答

1609閲覧

RSpecテストがローカルでは成功するがcircleCIでエラーになるため解決したい

hinata_hakumai

総合スコア3

Yarn

Yarnは、Facebook/Exponent/Google/Tildeが開発したJavaScriptのパッケージマネージャ。npmよりもインストールが速く、厳密にモジュールのバージョンを固定できるなど、npmの問題を解決。npmと互換性があり、同じpackage.jsonを使用できます。

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails 6

Ruby on Rails 6は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

RSpec

RSpecはRuby用のBDD(behaviour-driven development)フレームワークです。

Docker

Dockerは、Docker社が開発したオープンソースのコンテナー管理ソフトウェアの1つです

0グッド

0クリップ

投稿2021/11/23 15:57

前提・実現したいこと

投稿アプリを作成しています。ローカルでは問題なくテストが通るのですが、circleCI上ではエラーが発生してしまうため、アドバイスをいただければと思います。

発生している問題・エラーメッセージ

circleCIを実行したところ下記エラーが発生します。

Failure/Error: <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %> ActionView::Template::Error: Webpacker can't find application.js in /home/circleci/**************/src/public/packs-test/manifest.json. Possible causes: 1. You want to set webpacker.yml value of compile to true for your environment unless you are using the `webpack -w` or the webpack-dev-server. 2. webpack has not yet re-run to reflect updates. 3. You have misconfigured Webpacker's config/webpacker.yml file. 4. Your webpack configuration is not creating a manifest. Your manifest contains: { }

https://qiita.com/k-mashi/items/fdf7c962dbf95e0a55fa 
URLを参考にして.circleci/config.ymlにyarn installを追加しました。

ruby

1 - run: 2 name: yarn install 3 command: yarn install 4 - run: 5 name: webpack install 6 command: bundle exec bin/webpack

追加したのですが、別のエラーが発生しました。

ruby

1yarn install v1.22.15 2[1/4] Resolving packages... 3[2/4] Fetching packages... 4info fsevents@2.3.2: The platform "linux" is incompatible with this module. 5info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation. 6info fsevents@1.2.13: The platform "linux" is incompatible with this module. 7info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation. 8[3/4] Linking dependencies... 9warning " > webpack-dev-server@4.2.1" has unmet peer dependency "webpack@^4.37.0 || ^5.0.0". 10warning "webpack-dev-server > webpack-dev-middleware@5.1.0" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0". 11[4/4] Building fresh packages... 12error /home/circleci/**************/src/node_modules/node-sass: Command failed. 13Exit code: 1 14Command: node scripts/build.js 15Arguments: 16Directory: /home/circleci/**************/src/node_modules/node-sass 17Output: 18Building: /usr/local/bin/node /home/circleci/**************/src/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library= 19gyp info it worked if it ends with ok 20gyp verb cli [ 21gyp verb cli '/usr/local/bin/node', 22gyp verb cli '/home/circleci/**************/src/node_modules/node-gyp/bin/node-gyp.js', 23gyp info using node-gyp@3.8.0 24gyp info using node@16.13.0 | linux | x64 25gyp verb command rebuild [] 26gyp verb command clean [] 27gyp verb clean removing "build" directory 28gyp verb command configure [] 29gyp verb check python checking for Python executable "python2" in the PATH 30gyp verb `which` failed Error: not found: python2 31gyp verb `which` failed python2 Error: not found: python2 32gyp verb `which` failed at getNotFoundError (/home/circleci/**************/src/node_modules/which/which.js:13:12) 33gyp verb `which` failed at F (/home/circleci/**************/src/node_modules/which/which.js:68:19) 34gyp verb `which` failed at E (/home/circleci/**************/src/node_modules/which/which.js:80:29) 35gyp verb `which` failed at /home/circleci/**************/src/node_modules/which/which.js:89:16 36gyp verb `which` failed at /home/circleci/**************/src/node_modules/isexe/index.js:42:5 37gyp verb `which` failed at /home/circleci/**************/src/node_modules/isexe/mode.js:8:5 38gyp verb `which` failed at FSReqCallback.oncomplete (node:fs:198:21) { 39gyp verb `which` failed code: 'ENOENT' 40gyp verb `which` failed } 41gyp verb check python checking for Python executable "python" in the PATH 42gyp verb `which` failed Error: not found: python 43gyp verb `which` failed at getNotFoundError (/home/circleci/**************/src/node_modules/which/which.js:13:12) 44gyp verb `which` failed at F (/home/circleci/**************/src/node_modules/which/which.js:68:19) 45gyp verb `which` failed at E (/home/circleci/**************/src/node_modules/which/which.js:80:29) 46gyp verb `which` failed at /home/circleci/**************/src/node_modules/which/which.js:89:16 47gyp verb `which` failed at /home/circleci/**************/src/node_modules/isexe/index.js:42:5 48gyp verb `which` failed at /home/circleci/**************/src/node_modules/isexe/mode.js:8:5 49gyp verb `which` failed at FSReqCallback.oncomplete (node:fs:198:21) 50gyp verb `which` failed python Error: not found: python 51gyp verb `which` failed at getNotFoundError (/home/circleci/**************/src/node_modules/which/which.js:13:12) 52gyp verb `which` failed at F (/home/circleci/**************/src/node_modules/which/which.js:68:19) 53gyp verb `which` failed at E (/home/circleci/**************/src/node_modules/which/which.js:80:29) 54gyp verb `which` failed at /home/circleci/**************/src/node_modules/which/which.js:89:16 55gyp verb `which` failed at /home/circleci/**************/src/node_modules/isexe/index.js:42:5 56gyp verb `which` failed at /home/circleci/**************/src/node_modules/isexe/mode.js:8:5 57gyp verb `which` failed at FSReqCallback.oncomplete (node:fs:198:21) { 58gyp verb `which` failed code: 'ENOENT' 59gyp verb `which` failed } 60gyp ERR! configure error 61gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable. 62gyp ERR! System Linux 4.15.0-1115-aws 63gyp ERR! command "/usr/local/bin/node" "/home/circleci/**************/src/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library=" 64gyp ERR! cwd /home/circleci/**************/src/node_modules/node-sass 65gyp ERR! node -v v16.13.0 66gyp ERR! node-gyp -v v3.8.0 67gyp ERR! not ok 68Build failed with error code: 1 69info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

エラーコードからnode.jsとnode-sassのバージョンの互換性を疑いnodeのバージョンを確認しました。次に、dockerのコンテナ内でnode --version を実行し、v12.22.5を確認。
"node-sass": "^6.0.1"だったので、yarn why node-sassを実行し、で対応しているバージョンを特定しました。

yarn why v1.22.15 [4/4] Calculating file sizes... => Found "node-sass@4.14.1" info Reasons this module exists - "@rails#webpacker" depends on it - Hoisted from "@rails#webpacker#node-sass" info Disk size without dependencies: "6.32MB" info Disk size with unique dependencies: "14.7MB" info Disk size with transitive dependencies: "27.14MB" info Number of shared dependencies: 74

yarn upgrade node-sass@4.14.1を実行し、ダウングレードしたのですがエラーに変化なく行き詰まっています。

該当のソースコード

ruby

1.circleci/config.yml 2 3version: 2.1 4orbs: 5 ruby: circleci/ruby@1.1.2 6 heroku: circleci/heroku@1.2.3 7 8jobs: 9 build: 10 docker: 11 - image: circleci/ruby:2.7-node 12 working_directory: ~/portfolio/src 13 steps: 14 - checkout: 15 path: ~/portfolio 16 - ruby/install-deps 17 - run: 18 name: yarn install 19 command: yarn install 20 - run: 21 name: webpack install 22 command: bundle exec bin/webpack 23 24 rubocop: 25 working_directory: ~/portfolio/src 26 docker: 27 - image: circleci/ruby:2.7-node 28 steps: 29 - checkout: 30 path: ~/portfolio-fuji 31 - ruby/install-deps 32 - restore_cache: 33 keys: 34 - v1-dependencies-{{ checksum "Gemfile.lock" }} 35 - v1-dependencies- 36 - run: bundle install 37 - save_cache: 38 paths: 39 - ./vendor/bundle 40 key: v1-dependencies-{{ checksum "Gemfile.lock" }} 41 - run: 42 name: Rubocop 43 command: bundle exec rubocop 44 45 rspec: 46 docker: 47 - image: circleci/ruby:2.7-node 48 - image: circleci/mysql:5.5 49 environment: 50 MYSQL_ROOT_PASSWORD: password 51 MYSQL_DATABASE: app_test 52 MYSQL_USER: root 53 environment: 54 BUNDLE_JOBS: "3" 55 BUNDLE_RETRY: "3" 56 APP_DATABASE_HOST: "127.0.0.1" 57 RAILS_ENV: test 58 NODE_ENV: test 59 working_directory: ~/portfolio-fuji/src 60 steps: 61 - checkout: 62 path: ~/portfolio 63 - ruby/install-deps 64 - run: 65 name: Database setup 66 command: bundle exec rails db:migrate 67 - run: 68 name: Run rspec 69 command: bundle exec rspec 70 71 deploy: 72 docker: 73 - image: circleci/ruby:2.7-node 74 steps: 75 - checkout 76 - setup_remote_docker: 77 version: 19.03.13 78 - heroku/install 79 - run: 80 name: heroku login 81 command: heroku container:login 82 - run: 83 name: push docker image 84 command: heroku container:push web -a $HEROKU_APP_NAME 85 - run: 86 name: release docker image 87 command: heroku container:release web -a $HEROKU_APP_NAME 88 - run: 89 name: database setup 90 command: heroku run bundle exec rake db:migrate RAILS_ENV=production -a $HEROKU_APP_NAME 91 92workflows: 93 version: 2 94 build_rubocop_rspec_and_deploy: 95 jobs: 96 - build 97 - rspec 98 - rubocop 99 - deploy: 100 requires: 101 - build 102 - rspec 103 - rubocop 104 filters: 105 branches: 106 only: main 107

ruby

1Dockerfile 2 3FROM ruby:2.7 4 5ENV RAILS_ENV=production 6 7RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \ 8 && echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \ 9 && apt-get update -qq \ 10 && apt-get install -y nodejs yarn mariadb-client 11WORKDIR /app 12COPY ./src /app 13RUN bundle config --local set path 'vendor/bundle' \ 14 && bundle install 15 16COPY start.sh /start.sh 17RUN chmod 744 /start.sh 18CMD ["sh", "/start.sh"] 19

補足情報(FW/ツールのバージョンなど)

MacOS
docker
RSpec
Ruby
Ruby on Rails

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問