Homebrew / brew

🍺 The missing package manager for macOS (or Linux)
https://brew.sh
BSD 2-Clause "Simplified" License
41.53k stars 9.77k forks source link

brew install failed one time with "Homebrew must be run under Ruby 2.3!" on Ruby 2.4, now works fine #3299

Closed bbugh closed 7 years ago

bbugh commented 7 years ago

Running brew install colordiff gave me an error message related to #3240, but only once. I am running Ruby 2.4, but #3240 is checking for minor version less than 3. I'm not sure how I saw this error, as the code looks like it would allow for 2.4.

Below is the exact sequence of commands I used.

> brew install colordiff                                                                                       
Updating Homebrew...
==> Downloading https://homebrew.bintray.com/bottles-portable/portable-ruby-2.3.3.leopard_64.bottle.1.tar.gz
######################################################################## 100.0%
==> Pouring portable-ruby-2.3.3.leopard_64.bottle.1.tar.gz
==> Auto-updated Homebrew!
Updated 4 taps (beeftornado/rmtree, caskroom/cask, homebrew/core, homebrew/services).
==> New Formulae
abyss                    bwfmetaedit              duc                      landscaper               mecab-unidic-extended    ssh-vault
beast                    bzt                      dvanalyzer               libbitcoin-blockchain    msgpuck                  xmrig
bench                    clac                     fn                       libbitcoin-node          pdfpc                    ykman
bowtie2                  crc32c                   gdcm                     libbitcoin-server        precomp                  zim
==> Updated Formulae
abcmidi                       ejabberd                      hevea                         metaproxy                     redis@3.2
algernon                      elasticsearch                 hg-fast-export                metricbeat                    remake
allure                        elixir βœ”                      hh                            micro                         reop
amazon-ecs-cli                elvish                        hledger                       mikutter                      rocksdb
angular-cli                   emscripten                    hopenpgp-tools                minimal-racket                rom-tools
ansible                       enigma                        hugo                          minisign                      root
ansible-lint                  erlang βœ”                      hyper                         minizinc                      rswift
apache-arrow                  etcd                          hyperscan                     mkvtoolnix                    s-nail
apache-brooklyn-cli           etsh                          i3                            monit                         sbcl
apache-geode                  evince                        ibex                          mosquitto                     sdl2
apache-zeppelin               exa                           icdiff                        mpage                         selenium-server-standalone
apibuilder-cli                exact-image                   idutils                       mpg123 βœ”                      serd
apktool                       exploitdb                     imagemagick βœ”                 mpw                           shadowsocks-libev
app-engine-go-64              eye-d3                        imagemagick@6                 mutt                          shairport-sync
app-engine-java               faac                          imapsync                      mycli                         shfmt
arangodb                      faad2                         influxdb                      mypy                          siege
armadillo                     faas-cli                      influxdb@0.8                  ncmpc                         simple-obfs
artifactory                   fastd                         ios-sim                       nco                           sip βœ”
aubio                         fb-client                     iozone                        ndpi                          snakemake
augeas                        fd                            ipfs                          neatvi                        snap-telemetry
autoconf-archive              fdroidserver                  ipython                       nedit                         snap7
avro-tools                    feh                           ipython@5                     neofetch                      snapcraft
aws-elasticbeanstalk          fibjs                         isync                         nexus                         sngrep
aws-sdk-cpp                   file-roller                   itstool                       nghttp2                       sourcery
awscli                        filebeat                      jenkins                       nifi                          sphinx-doc
azure-cli                     fio                           jfrog-cli-go                  ninja                         spigot
bandcamp-dl                   firebase-cli                  jhipster                      nnn                           sqlmap
baobab                        flow                          jose                          no-more-secrets               sqlparse
bartycrouch                   fluent-bit                    jsonnet                       node βœ”                        ssh-copy-id
bash-preexec                  folly                         jsonschema2pojo               node@6                        sshguard
bazel                         fontconfig βœ”                  kawa                          noti                          stone-soup
bear                          fonttools                     kerl                          nss                           stubby
bento4                        fox                           khal                          numpy                         submarine
binaryen                      freetds                       kibana                        nvi                           subversion
binutils                      fwup                          kitchen-sync                  offlineimap                   svtplay-dl
bison                         gauge                         knot                          open-mpi                      swfmill
bison@2.7                     gcviewer                      knot-resolver                 openal-soft                   swift
bit                           gdk-pixbuf βœ”                  kops                          opencoarrays                  swiftformat
bitrise                       geographiclib                 kotlin                        openjpeg βœ”                    swiftgen
blahtexml                     get_iplayer                   kpcli                         opensaml                      swiftlint
bluepill                      getdns                        kubernetes-cli                openssh                       swimat
bnd                           geth                          kubernetes-helm               openvpn                       sysdig
botan                         ghostscript                   laszip                        orientdb                      taisei
bower                         git βœ”                         launch                        osc                           tarantool
brotli                        git-annex                     launchdns                     osm2pgsql                     tbb
buildifier                    git-ftp                       ldc                           osmfilter                     telegraf
bulk_extractor                git-lfs                       lean                          osquery                       teleport
bullet                        git-number                    lean-cli                      osrm-backend                  terraform
byobu                         gitbucket                     lego                          osxutils                      terragrunt
caddy                         giter8                        lftp                          ott                           testssl
caf                           gjs                           libav                         overmind                      texmath
camlp5                        glade                         libbitcoin                    p11-kit βœ”                     tig
ccm                           glib βœ”                        libbitcoin-explorer           packetbeat                    tmux
certbot                       glide                         libdap                        paket                         todolist
certstrap                     globus-toolkit                libfabric                     par2                          tomcat
cfr-decompiler                gmic                          libgphoto2                    parallel                      tomcat@7
cgal                          gnatsd                        libhdhomerun                  pazpar2                       tracebox
chapel                        gnupg-pkcs11-scd              libhttpseverywhere            pcap_dnsproxy                 ttyd
checkstyle                    go                            libmatroska                   pdf2svg                       twemcache
chromedriver βœ”                go@1.4                        libmodplug                    pdfgrep                       twtxt
chronograf                    go@1.8                        libmtp                        pdftoedn                      typescript
cimg                          gobject-introspection βœ”       libnatpmp                     pdftoipe                      ucommon
citus                         godep                         libofx                        pegtl                         vala βœ”
clojure                       goenv                         libowfat                      perl βœ”                        vapoursynth βœ”
clojurescript                 goocanvas                     libphonenumber                pgcli βœ”                       varnish
cmake                         googler                       libprotoident                 pgroonga                      vbindiff
coffeescript                  gopass                        libqalculate                  pilosa                        vdirsyncer
configen                      gphoto2                       libraw                        pioneer                       vim βœ”
convox                        gprof2dot                     librem                        pktanon                       vim@7.4
coreutils βœ”                   gpsd                          librsvg βœ”                     planck                        vips
cppad                         gradle                        libshout                      pldebugger                    virtualpg
cppcheck                      grafana                       libsmi                        pmdmini                       vnu
curl                          grails                        libsodium                     ponyc                         vte3
cutter                        grib-api                      libspectre                    ponysay                       watchexec
cvs                           grip                          libtcod                       poppler βœ”                     weechat
cython                        groonga                       libtensorflow                 postgis                       wireguard-tools
dbus                          grpc                          libuecc                       pqiv                          wxmaxima
dbxml                         gsmartcontrol                 libuv                         pre-commit                    x265
dc3dd                         gst-editing-services          libuvc                        presto                        xa
dcm2niix                      gst-libav                     libvirt                       prometheus                    xalan-c
diff-pdf                      gst-plugins-bad               libwebsockets                 protobuf-swift                xerces-c
diffoscope                    gst-plugins-base              libxlsxwriter                 pure-ftpd                     xml-security-c
digdag                        gst-plugins-good              libxml2                       pyenv                         xml-tooling-c
direnv                        gst-plugins-ugly              linkerd                       pyenv-virtualenv              xqilla
dnscrypt-proxy                gst-python                    links                         pygobject3                    xsd
dnscrypt-wrapper              gst-rtsp-server               logstalgia                    pypy                          xtensor
dnsmasq                       gst-validate                  logstash                      pypy3                         yarn
dnsviz                        gstreamer                     logtalk                       python βœ”                      yle-dl
docfx                         gtk+3                         macosvpn                      python3 βœ”                     youtube-dl βœ”
docker                        gtk-doc                       macvim                        qbs                           zabbix
docker-completion             gtk-gnutella                  magic-wormhole                qemu                          zile
docker2aci                    gtkextra                      mame                          qrencode                      zorba
doitlive                      gtksourceview3                mariadb                       quantlib                      zsh
dshb                          gucharmap                     mariadb@10.1                  quex                          zstd
dspdfviewer                   gwt                           maxima                        r
dtc                           haxe                          mercurial                     rclone
dwarf                         help2man                      meson                         rcs
efl                           heroku βœ”                      metabase                      redis βœ”
==> Renamed Formulae
gitlab-ci-multi-runner -> gitlab-runner            httpd24 -> httpd                                   thrift@0.90 -> thrift@0.9
gnome-icon-theme -> adwaita-icon-theme             mobile-shell -> mosh
==> Deleted Formulae
elixirscript                          rexster                               rexster-console                       tcpurify

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

> ruby -v
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]

> brew update
Already up-to-date.

> brew install colordiff                                                                                       bbugh@Brians-MacBook-Pro
To restore the stashed changes to /usr/local/Homebrew run:
  'cd /usr/local/Homebrew && git stash pop'
==> Downloading https://homebrew.bintray.com/bottles/colordiff-1.0.18.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring colordiff-1.0.18.sierra.bottle.tar.gz
🍺  /usr/local/Cellar/colordiff/1.0.18: 10 files, 58.1KB

Testing the same homebrew code that raised the error in irb, in the same folder.

2.4.0 :001 > # check ruby version before requiring any modules.
2.4.0 :002 >   RUBY_VERSION_SPLIT = RUBY_VERSION.split "."
 => ["2", "4", "0"] 
2.4.0 :003 > RUBY_X = RUBY_VERSION_SPLIT[0].to_i
 => 2 
2.4.0 :004 > RUBY_Y = RUBY_VERSION_SPLIT[1].to_i
 => 4 
2.4.0 :005 > if RUBY_X < 2 || (RUBY_X == 2 && RUBY_Y < 3)
2.4.0 :006?>     raise "Homebrew must be run under Ruby 2.3!"
2.4.0 :007?>   end
 => nil

Output of brew config

brew config
HOMEBREW_VERSION: 1.3.5
ORIGIN: https://github.com/Homebrew/brew.git
HEAD: 91ab116ace7f4f97d3440190463c93be9ec6d675
Last commit: 2 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: a57a3704b4e7a8dcb311cf2309d485ad93d4977d
Core tap last commit: 4 hours ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_REPOSITORY: /usr/local/Homebrew
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_BOTTLE_DOMAIN: https://homebrew.bintray.com
CPU: octa-core 64-bit haswell
Homebrew Ruby: 2.3.3 => /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/bin/ruby
Clang: 8.1 build 802
Git: 2.13.1 => /usr/local/bin/git
Perl: /usr/local/bin/perl => /usr/local/Cellar/perl/5.26.0/bin/perl
Python: /usr/local/opt/python/libexec/bin/python => /usr/local/Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7/bin/python2.7
Ruby: /Users/bbugh/.rvm/rubies/ruby-2.4.0/bin/ruby
Java: 1.8.0_101
macOS: 10.12.6-x86_64
Xcode: 8.3.3
CLT: 9.0.0.0.1.1504363082
X11: 2.7.11 => /opt/X11
-----------------------

Output of brew doctor

Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!

Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected dylibs:
  /usr/local/lib/libwkhtmltox.0.12.4.dylib

Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected header files:
  /usr/local/include/wkhtmltox/image.h
  /usr/local/include/wkhtmltox/pdf.h

Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
  mono

Warning: Some installed formula are missing dependencies.
You should `brew install` the missing dependencies:
  brew install gd graphviz libpq webp

Run `brew missing` for more details.

Please always follow these steps:

reitermarkus commented 7 years ago

I am running Ruby 2.4

Homebrew always uses the system Ruby, so it likely started with Ruby 2.0.0, installed the vendored Ruby 2.3.3, but then didn't use the vendored Ruby the first time.

Can you reproduce the error if you remove /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby?

stevenzeck commented 7 years ago

Would this explain why Travis builds for OSX fail? https://travis-ci.org/szeck87/atom-beautify/jobs/286285106

MariadeAnton commented 7 years ago

Hi everyone! This is MarΓ­a from Travis CI -

As @szeck87 mentioned, we're seeing a similar behaviour in our macOS environment on macOS builds https://github.com/travis-ci/travis-ci/issues/8552#issuecomment-335430374

Seems that current workarounds would be:

Does this help? Thank you!

reitermarkus commented 7 years ago

This was fixed in Homebrew 1.3.4, so if you are on >= 1.3.4 now, you can safely ignore this error. For Travis, refer to the workaround above.

MikeMcQuaid commented 7 years ago

@MariadeAnton The better fix would be if Travis CI could prioritise updating the Homebrew on your base images (basically: run brew update, create a new image). I've removed one of your suggestions because we intentionally don't want people to just disable auto-updating because then they will never turn it back on and file bugs to us based on old Homebrew versions. Thanks!

MariadeAnton commented 7 years ago

@MikeMcQuaid thank you for explaining - that makes sense! These are workarounds while we update our long-term support macOS images, we'll stick to brew update in the meantime :)

stevenzeck commented 7 years ago

OK, running brew update before any installs worked. Not to sidetrack this issue, but @MariadeAnton is there an issue in https://github.com/travis-ci/travis-ci/ I can comment on about updating images? Updating Homebrew takes the longest and certainly doesn't help the number of backlog OSX builds, while updating the images frequently would reduce that significantly.

JCount commented 7 years ago

@javadba Could you please open a new issue and fill out the issue template as much as you can.