Homebrew must be run under Ruby 2.3! (RuntimeError)

Today started to get this failure:

dependencies:
  pre:
    - brew install yarn

Output:

Updating Homebrew…
==> Downloading https://homebrew.bintray.com/bottles-portable/portable-ruby-2.3.3.leopard_64.bottle.1.tar.gz
0.1% 0.2% 0.6% 1.3%# 2.2%## 3.5%### 5.4%##### 8.1%######## 11.5%########### 16.0%############### 22.2%##################### 29.7%########################## 36.4%############################### 43.7%#################################### 51.0%########################################## 58.9%############################################### 65.4%#################################################### 73.0%######################################################### 80.3%############################################################### 88.0%#################################################################### 95.5%######################################################################## 100.0%
==> Pouring portable-ruby-2.3.3.leopard_64.bottle.1.tar.gz
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
abuse libedit

libchaos zyre
==> Updated Formulae
aalib libimobiledevice

libical-glib zurl
libicns
==> Renamed Formulae
antlr2 → antlr@2

zeromq40 → zeromq@4.0
==> Deleted Formulae
abi-compliance-checker gh rexster

fb-adb qtplay yelp-xsl

/usr/local/Homebrew/Library/Homebrew/brew.rb:12:in `': Homebrew must be run under Ruby 2.3! (RuntimeError)

brew install yarn returned exit code 1

3 Likes

Same issue here. This seems to occur in the xcode 8.2 image.

Upgrading to 8.3 and adding brew update to circle.yml fixes this, but this brings in other problems.

This renders the 8.2 image essentially useless. Any other workarounds?

The weird thing is that the version of ruby installed on 8.2 is clearly 2.3.x.

Likely related to this PR: https://github.com/Homebrew/brew/pull/3240/files

I tried upgrading to xcode 8.3.3 but then I got this:
Select Xcode Version

chruby: unknown Ruby: 2.3.1
Xcode 8.3.3
Build version 8E3004b

and then later yarn failed. I then tried setting the machine version of ruby to 2.3.1 but:
set ruby version to 2.3.1

chruby: unknown Ruby: 2.3.1

BTW to install yarn we are doing this:

dependencies:
  pre:
    - |
      if [[ ! -e ~/.yarn/bin/yarn || $(yarn --version) != "${YARN_VERSION}" ]]; then
        curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version $YARN_VERSION
      fi

Is that the best way to do it?

Had the same problem.
It’s indeed related to this https://github.com/Homebrew/brew/pull/3240/files sent above.
Just insert a - brew update on your dependencies: pre: and you will be fine.
It will, as informed in a comment in this PR, “unset HOMEBREW_RUBY_PATH to ensure that this doesn’t “stick” on a Ruby 2.0 version after a portable Ruby has been installed.”.

You can continue to use the 8.2 image, also there’s no need to change the Ruby version.

dependencies:
  pre:
    - brew update

How were you setting the machine version? Through the config like below?

machine:
  ruby:
    version: "2.3.1"

The 8.3.3 Xcode image has ruby 2.3.4 installed, so try updating it to version: "2.3.4". You can read more about what software versions are available in each of our OSX image docs here. If you’re using a Xcode image different from 8.3.3 you can check the docs to see what ruby version is available in your image.

@fernfernfern perfect I will try that. Also I’m updating brew as suggested @vcali and that is working too.

These answers seem to be all for Circleci 1.0 - But the easy workaround in every case is just to do a

brew update

before doing anything else with homebrew. So in Circleci 2.0 in your step that is installing something from homebrew, you can just do the brew update first.

1 Like

Thanks! it worked for me, just by doing brew update