I'm new to CircleCI.
Rails 6.0.3.1
#### **`ruby 2.6.3`**
Bundler version 2.1.4
***
By referring to the following article, I was trying to introduce circleCI to the original application in cooperation with github.
[[CircleCI] Run rubocop and rspec tests in cooperation with github with Rails app](https://qiita.com/AK4747471/items/b2161784065f21cd1645)
Then the following error ...
#!/bin/bash -eo pipefail bundle -v Traceback (most recent call last):
2: from /usr/local/bin/bundle:23:in `<main>'
1: from /usr/local/lib/ruby/2.6.0/rubygems.rb:302:in `activate_bin_path'
/usr/local/lib/ruby/2.6.0/rubygems.rb:283:in `find_spec_for_exe': Could not find 'bundler' (2.1.4) required by your /home/circleci/project/Gemfile.lock. (Gem::GemNotFoundException)
To update to the latest version installed on your system, run bundle update --bundler
.
To install the missing version, run gem install bundler:2.1.4
Exited with code exit status 1 CircleCI received exit code 1
For now, let's take a look at the contents of ``` .circleci / config.yml```.
#### **`.circleci/config.yml`**
version: 2.1 orbs: ruby: circleci/[email protected]
jobs: build: docker: - image: circleci/ruby:2.6.3-stretch-node executor: ruby/default steps: - checkout - run: name: Which bundler? command: bundle -v - ruby/bundle-install
That is different from what I set in the ``` docker``` branch ...
It wasn't merged properly.
An ordinary mistake.
Rewrite it properly and then try again
```set up priject```→```start building```Let's do it!
By the way, I referred to the following article for how to write ``` config.yml```.
[Create an environment where you can execute system specifications with CircleCI while converting an existing Rails 6 application to Docker](https://qiita.com/kenzoukenzou104809/items/e3d970b59bf106cab19e)
#### **`.circleci/config.yml`**
version: 2
jobs:
build:
working_directory: ~/my-app
docker:
- image: circleci/ruby:2.6.3-node-browsers
environment:
BUNDLE_RETRY: 3
BUNDLE_PATH: vendor/bundle
BUNDLER_VERSION: 2.1.4
DATABASE_URL: postgres://postgres:password@localhost:5432/myapp_test
RAILS_ENV: test
- image: circleci/postgres:11-alpine
steps:
- checkout
- restore_cache:
keys:
- my-app-bundle-v1-{{ checksum "Gemfile.lock" }}
- my-app-bundle-v1-
- run:
name: Bundler install
command: |
gem update --system
gem install bundler -v 2.1.4
- run:
name: Bundle Install
command: bundle check || bundle install
- save_cache:
key: my-app-bundle-v1-{{ checksum "Gemfile.lock" }}
paths:
- vendor/bundle
- restore_cache:
keys:
- rails-demo-yarn-{{ checksum "yarn.lock" }}
- rails-demo-yarn-
- run:
name:Install Yarn
command: yarn install --cache-folder ~/.cache/yarn
- run:
name: Wait for DB
command: dockerize -wait tcp://127.0.0.1:5432 -timeout 1m
- run:
name: Database setup
command: bin/rails db:create db:schema:load --trace
- run: bundle exec bin/webpack
- run:
name: execute rspec
command: bundle exec rspec
- store_test_results:
path: /tmp/test-results
As a caveat, bundle install seems to fail if it is ``` ** bundle 2.0.1 or higher` ``, so you need to explicitly specify it in the environment.
Excerpt below.
#### **`.circleci/config.yml`**
#abridgement
docker:
- image: circleci/ruby:2.6.3-node-browsers
environment:
BUNDLE_RETRY: 3
BUNDLE_PATH: vendor/bundle
#Specify the version
BUNDLER_VERSION: 2.1.4
DATABASE_URL: postgres://postgres:password@localhost:5432/myapp_test
RAILS_ENV: test
#abridgement
Along with that, specify the version for oysters
#### **`.circleci/config.yml`**
The above is now `` `Success```.
Reference article
> [[CircleCI] "You must use Bundler 2 or greater with this lock file." Error](https://haayaaa.hatenablog.com/entry/2019/10/05/223705)
[[CircleCI] Run rubocop and rspec tests in cooperation with github with Rails app](https://qiita.com/AK4747471/items/b2161784065f21cd1645)
[[CircleCI] Easy individual CI introduction method starting from CircleCI 2.0-until cooperation with github](https://www.tweeeety.blog/entry/2018/02/09/195345)
Recommended Posts