Reputation: 2259
I am using circleCI for CI with the following .yml file
version: 2
jobs:
build:
machine:
ruby:
version: 2.4.4
steps:
- checkout
- run: bundle install
- run: echo "hello"
The error message is
Your Ruby version is 2.3.3, but your Gemfile specified 2.4.4
Your Ruby version is 2.3.3, but your Gemfile specified 2.4.4
My Gemfile is
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.4.4'
What is the proper way to set ruby version?
Upvotes: 4
Views: 4325
Reputation: 4017
disclaimer: I'm a CircleCI Developer Advocate
Your config example is mixing CircleCI 2.0 and 1.0 config syntax and this is causing the issue.
If you want to use Ruby 2.4.4 in a CircleCI 2.0 build and you want to use our premade Docker image, then your config should look like this:
version: 2
jobs:
build:
docker:
- image: circleci/ruby:2.4.4
steps:
- checkout
- run: bundle install
- run: echo "hello"
The above example is for the Linux environment. If you're doing macOS builds, then @e_a_o's answer will help you there.
Upvotes: 5
Reputation: 2259
I referred this CircleCI docs and created a file .ruby-version that explicitly stated the version to be used i.e. 2.4.4 and it works. The content was
2.4.4
Upvotes: 1
Reputation: 601
It looks like you are using CircleCI 2
but you're setting the ruby version using the CircleCI 1
way.
As stated in this documentation, to set the ruby version in Circle CI 2
, you can either create a .ruby-version
file in your rails app and commit the file or you can create it from a build step:
run:
name: Set Ruby Version
command: echo "ruby-2.4.4" > ~/.ruby-version
Upvotes: 4