Set ruby version

Hi, I need to set a specific version of ruby (2.3.1) to run my lanes. I tried using rvm but I failed. Do you have any guide on how I can Install and set 2.3.1?

We don’t have any ruby version manager pre-installed.

Why do you need exactly 2.3.1? Our Xcode 8.x build VMs have either 2.3.1 or 2.3.3 preinstalled right now

Xcode 8.0 stack is on 2.3.1 - https://github.com/bitrise-io/bitrise.io/blob/master/system_reports/osx-xcode-8.0.x.log#L16

Xcode 8.3 stack is on 2.3.3 - https://github.com/bitrise-io/bitrise.io/blob/master/system_reports/osx-xcode-8.3.x.log#L16

I need to setup that version of ruby because is the version set in our Gemfile.

We CI setup that works with that
I want to test bitrise without affect the existing configurations

The reason why we don’t have RVM, chruby or another ruby version manager preinstalled is because Xcode (Xcode’s command line tools) did have issues in the past when ruby was installed through RVM (see e.g. http://stackoverflow.com/a/33041110/974381 ) or any other ruby version manager.

Additionally, Ruby patch releases should be compatible, so Ruby 2.3.3 should work where 2.3.1 did (and in general patch releases do include important security/stability fixes).

You’re of course free to install and use any Ruby version manager ( http://devcenter.bitrise.io/tips-and-tricks/install-additional-tools/ ).

I’m just curious, which ruby version manager do you use on your Mac @lucabartoletti ?

Probably the fastest solution to switch between Ruby versions on macOS right now is to use brew.
Homebrew recently started to provide versioned minor Ruby versions.

They are still working out the details of their versioning, right now it looks like this:

#!/bin/bash
set -ex

# uninstall the previously installed ruby version
brew uninstall ruby
# install the minor version you want
brew install ruby@2.2
# "activate" this version
brew link --force ruby@2.2

Unfortunately there’s no way to specify a patch level/version too, only the major+minor versions, and brew will install the latest patch version for that major+minor version, but this shouldn’t cause issues in general.

Hello @viktorbenei,

Any updates on how to use ruby@2.3 on Bitrise? My application uses ruby@2.3 and I can’t make it work. It seems the previous options for the stack with Xcode no longer have ruby@2.3 pre-installed. I also tried installing a new ruby version, but I can’t make bundler work. I’m using this stack: https://github.com/bitrise-io/bitrise.io/blob/master/system_reports/osx-xcode-8.3.x.log

brew uninstall ruby
brew install ruby@2.3
brew link --force --overwrite ruby@2.3
gem install bundler
bundle install

Then I get the following
/bin/sh: /usr/local/bin/bundle: /usr/local/opt/ruby/bin/ruby: bad interpreter: No such file or directory

Hi @Remoov,
Could you send us the URL of the build that failed, so we can have a look at the logs?

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.