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

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

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

PostgreSQLはオープンソースのオブジェクトリレーショナルデータベース管理システムです。 Oracle Databaseで使われるPL/SQLを参考に実装されたビルトイン言語で、Windows、 Mac、Linux、UNIX、MSなどいくつものプラットフォームに対応しています。

Ruby on Rails

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

Docker

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

Circle CI

Circle CIは、クラウド上に簡単にCI環境を構築できるWebサービスです。GitHubと連携させ、CIしたいリポジトリーを選択しビルド・テストを行います。チャット等を利用して結果を確認することが可能です。

Q&A

解決済

1回答

1987閲覧

CircleCIで「bundle exec rails db:migrate」に失敗する

Hyzsa

総合スコア10

PostgreSQL

PostgreSQLはオープンソースのオブジェクトリレーショナルデータベース管理システムです。 Oracle Databaseで使われるPL/SQLを参考に実装されたビルトイン言語で、Windows、 Mac、Linux、UNIX、MSなどいくつものプラットフォームに対応しています。

Ruby on Rails

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

Docker

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

Circle CI

Circle CIは、クラウド上に簡単にCI環境を構築できるWebサービスです。GitHubと連携させ、CIしたいリポジトリーを選択しビルド・テストを行います。チャット等を利用して結果を確認することが可能です。

1グッド

0クリップ

投稿2022/01/11 08:15

現在Dockerでrailsアプリを作成して、CircleCIの導入をおこなっております。
まだ簡単な表示(Hello World)しか実装していませんが、
CircleCIで自動ビルド&テストの動作確認を行おうとしたところ、
「bundle exec rails db:migrate」実行時に下記エラーが発生して詰まりました。

まだBundlerについての理解(Gemの保存先など)が乏しいため、
いろいろ調べましたが解決策が見つからず、どこに原因があるのかも見当がつきませんので
ご教授いただければと思います。

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

イメージ説明

エラーメッセージ Could not find rake-13.0.6 in any of the sources Run `bundle install` to install missing gems.

.circleci/config.yml

version: 2.1 orbs: ruby: circleci/ruby@1.1.2 jobs: build: docker: - image: circleci/ruby:2.7.5 working_directory: ~/app/src steps: - checkout: path: ~/app - ruby/install-deps test: docker: - image: circleci/ruby:2.7.5 - image: circleci/postgres:13.5 environment: POSTGRES_USER: postgres POSTGRES_HOST_AUTH_METHOD: trust POSTGRES_DB: app_test environment: BUNDLE_JOBS: "3" BUNDLE_RETRY: "3" APP_DATABASE_HOST: "127.0.0.1" RAILS_ENV: test working_directory: ~/app/src steps: - checkout: path: ~/app - ruby/install-deps - run: name: Database setup command: bundle exec rails db:migrate - run: name: test command: bundle exec rake test workflows: version: 2 build_and_test: jobs: - build - test: requires: - build

試したこと

Docker開発環境でのマイグレーション実行

$ docker-compose exec web bundle exec rails db:migrate Running via Spring preloader in process 408

###気になった点
ローカルでCircleCIを実行したところ、下記動作をおこなっているようでした。(rake 13.0.6をインストールしている?)
ですがクラウド上のログでは、「Gemfileの依存関係が満たされている」とのことでgemインストールしていない気がします。
ただ、どちらも失敗するので関係あるかはわかりません。

ローカルのBundle Installログ(一部抜粋)

$ circleci local execute : 省略 Gemfile.lock is bundled with bundler version 2.1.4 bundler 2.1.4 is already installed. [DEPRECATED] The `--path` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set path './vendor/bundle'`, and stop using this flag The following gems are missing * rake (13.0.6) * concurrent-ruby (1.1.9) : 省略 Install missing gems with `bundle install` [DEPRECATED] The `--deployment` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set deployment 'true'`, and stop using this flag Fetching gem metadata from https://rubygems.org/.......... Fetching rake 13.0.6 Installing rake 13.0.6 Fetching concurrent-ruby 1.1.9 Installing concurrent-ruby 1.1.9 Fetching i18n 1.8.11

クラウド側のBundle Installログ
イメージ説明

補足情報(関連しそうなソースコード)

Gemfile

source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '2.7.5' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main' gem 'rails', '~> 6.1.4', '>= 6.1.4.4' # Use postgresql as the database for Active Record gem 'pg', '~> 1.1' # Use Puma as the app server gem 'puma', '~> 5.0' # Use SCSS for stylesheets gem 'sass-rails', '>= 6' # Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker gem 'webpacker', '~> 5.0' # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks gem 'turbolinks', '~> 5' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.7' # Use Redis adapter to run Action Cable in production # gem 'redis', '~> 4.0' # Use Active Model has_secure_password # gem 'bcrypt', '~> 3.1.7' # Use Active Storage variant # gem 'image_processing', '~> 1.2' # Reduces boot times through caching; required in config/boot.rb gem 'bootsnap', '>= 1.4.4', require: false group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] end group :development do # Access an interactive console on exception pages or by calling 'console' anywhere in the code. gem 'web-console', '>= 4.1.0' # Display performance information such as SQL time and flame graphs for each request in your browser. # Can be configured to work on production as well see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md gem 'rack-mini-profiler', '~> 2.0' gem 'listen', '~> 3.3' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' end group :test do # Adds support for Capybara system testing and selenium driver gem 'capybara', '>= 3.26' gem 'selenium-webdriver' # Easy installation and use of web drivers to run system tests with browsers gem 'webdrivers' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data'
退会済みユーザー👍を押しています

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

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

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

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

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

guest

回答1

0

自己解決

プレフィックスが「 circleci / 」のレガシーイメージは、 2021 年 12 月 31 日に廃止されます。 ビルドを高速化するには、次世代の CircleCI イメージを使ってプロジェクトをアップグレードしてください。

(引用元)

とのことだったので、config.yml で指定しているDockerイメージを下記のように修正したら解決しました。

<before> ``` docker: - image: circleci/ruby:2.7.5 ``` <After> ``` docker: - image: cimg/ruby:2.7.5 ```

投稿2022/01/11 15:00

Hyzsa

総合スコア10

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.49%

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

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

質問する

関連した質問