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?
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With