How to use Ruby on the OS X machines

ruby
xcode
rvm
rubyversionmanger

#1

We just flipped the switch on our new OS X image which brings you a Ruby version manager in the form of chruby and ruby-install.

Out of the box the system installed Ruby v2.0.0 is selected so if you want the latest and greatest version please specify it in your circle.yml like so:

dependencies:
  pre:
    - echo "2.3.1" > .ruby-version

or checking a .ruby-version file into your repo. You can easily create one by running the same command in your repos directory with echo "2.3.1" > .ruby-version and then check it in with git add .ruby-version && git commit -am "Added .ruby-version file"

The available versions out of the box are:

1. chruby --system
2. chruby 2.1.9
3. chruby 2.2.5
4. chruby 2.3.1

, but you can always install a newer version with ruby-install like this:

dependencies:
  pre:
    - sudo ruby-install ruby --HEAD

If you run into any issues please feel free to let our support team know.


OS X machine - ruby version
#2

Great updating!
Now we can use this feature, right?


#3

Hi great feature, but chruby 2.3.1 doesnt seem to work for us


#4

seems like we need to run gem install bundler after chruby? but we get this

ERROR:  While executing gem ... (Errno::EACCES)
    Permission denied - /Library/Ruby/Gems/2.0.0/gems/bundler-1.13.6/.codeclimate.yml

gem install bundler returned exit code 1

Action failed: gem install bundler

#5

Yes you can. The new image is live on all our production machines.


#6

Can you please open a support ticket? I’d like to take a closer look.

Thanks,
Constantin


#7

hi @anon47539524, i started getting a similar error last night on my OS X machine. seems unrelated to any code changes we made. Can I be updated on the results as well?

gem install bundler --pre
ERROR:  While executing gem ... (Errno::EACCES)
    Permission denied - /Library/Ruby/Gems/2.0.0/gems/bundler-1.13.6/.codeclimate.yml

gem install bundler --pre returned exit code 1

Action failed: gem install bundler --pre

#8

hey @philfung, @anon47539524 suggest workaround by doing something like chruby 2.3.1 && bundle <command>


#9

Same for us as well. Build system has broken, working fine yesterday and not today, with the following similar error :frowning:

gem install shenzhen
ERROR:  While executing gem ... (Errno::EACCES)
    Permission denied - /Library/Ruby/Gems/2.0.0/gems/shenzhen-0.14.2/Gemfile

gem install shenzhen returned exit code 1

Action failed: gem install shenzhen

#10

thx a bunch @tflhyl , will give it a try!


#11

@tflhyl your solutions works!


#12

No luck


#13

@betzerra It looks like you missed an extra & there. It should be chruby 2.2.5 && bundle install.


#14

Just to follow up on this, the temporary solution (as mentioned above) is to use chruby 2.X.X before all calls to anything Ruby related.

Example:

chruby 2.3.1 && gem install bundler
chruby 2.3.1 && bundle install
chruby 2.3.1 && bundle exec pod install

If you are using rvm and your project includes a .ruby-version file, you can also do chruby $(cat .ruby-version | cut -d '-' -f 2) rather than having to hardcode the value in your circle.yml file.


#15

Hey,

please add sudo to your gem install shenzhen command.

Please excuse the inconvenience.

Constantin


#16

For now please take a look at @boostworthy 's answer.

I’m working on a longterm fix and a short term one as I post this.

In the future you’ll be able to use simply put your preferred Ruby version in a ~/.ruby-version file and chruby will pick that up by itself.


#17

AH! Thanks! I missed that :smiley: :smiley: :smiley:


#18

Could this update have impacted the way OSX installs code signing credentials? We are currently not finding the valid identities even though our last build yesterday found it no problem.

Currently getting this all throughout that step.

chruby: unknown Ruby: ruby-2.2.4


#19

Did anyone test this? Because every line in circle.yml runs in its own shell, I had to prefix every step of ours that used ruby with chruby 2.3.1; export PATH; and then it worked


#20

It’s pretty disappointing to have a feature like this counted as shipped and a blog post written about how to use it, when it doesn’t work and breaks all our builds and deployments. Maybe test this and do an opt-in roll out rather than breaking everything next time


Getting rvm: command not found Action failed: set ruby version to 2.2.2