0

(apologizes: not a native english)

I upgraded my MacBook Air a few days ago to OS High-sierra and I encounter a lot of problems with my ruby versions.

In particular:

  • Terminal works with a 2.4 ruby version I can't find anywhere…
  • Apache server seems to work with a 2.3.3 ruby version I find… outside of the rbenv folder…
  • My rbenv knows only 2.3.0 and 2.3.1 ruby versions…
  • I'm not be able to install 2.4 version with rbenv (see below)…
  • rbenv global 2.3.1 doesn't help at all (nothing changes)…

What could I try to use only the 2.3.1 ruby version?………


Some (maybe) helpfull information:

I don't have a ~/.rvm folder.

Some feedbacks about config, in Terminal:

$> ruby -v
   # => ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin17]

$> rbenv versions
   # => 
   * system (set by /Users/philippeperret/.rbenv/version)
   2.3.0
   2.3.1

$> which -a ruby
   # => 
     /Users/philippeperret/.rbenv/shims/ruby
     /usr/local/bin/ruby
     /usr/bin/ruby

$> irb
irb> RUBY_VERSION
     # => "2.4.2"

About homebrew

$> brew config
HOMEBREW_VERSION: 1.4.1
ORIGIN: https://github.com/Homebrew/brew
...
HOMEBREW_PREFIX: /usr/local
CPU: quad-core 64-bit haswell
Homebrew Ruby: 2.3.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
Clang: 9.0 build 900
Git: 2.14.3 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Curl: 7.54.0 => /usr/bin/curl
...
Ruby: /Users/philippeperret/.rbenv/shims/ruby => /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
Java: 1.8.0_45
macOS: 10.13.2-x86_64
Xcode: 9.2
CLT: N/A
X11: 2.7.11 => /opt/X11

I can't figure out why the ruby version 2.3 (.3) is in /System/Library/Frameworks/Ruby.framework/Versions/ rather than in .rbenv folder?… (despite the fact that I know it's a high-sierra installation)


When I run a local (rails-like) web app (in my browser), asking it the ruby version:

$> RUBY_VERSION
# => 2.3.3
$> ruby --version
# => ruby 2.3.3p222 (2016-11-21 revision 56859) [universal.x86_64-darwin17]
$> which -a ruby
# => /usr/bin/ruby

And it can't find some ruby gems (require 'rubygems' doesn't help). I can't install these gems, of course, until I can't choose 2.3.3 version with rbenv in Terminal:

When I run:

$> rbenv global 2.4.2p198

… (which is the Terminal ruby version), it complains:

rbenv: version `2.4.2p198' not installed

When I try:

rbenv install 2.4.2p198

… it complains:

ruby-build: definition not found: 2.4.2p198

See all available versions with `rbenv install --list'.
If the version you need is missing, try upgrading ruby-build:
brew update && brew upgrade ruby-build

(of course I "brew updated" and so on)


I spent the last few days to read documentation and SO's question/answers in vain…

  • did you run rbenv install --list? as you can see below, the full version is the one that is available on rbenv - try `rbenv install 2.4.2` once you confirm you can see it here: `rbenv install --list|grep 2.4.2 2.4.2` – dstull Dec 29 '17 at 15:35
  • High Sierra updates the system Ruby to 2.3 from 2.0. – Joe Dec 29 '17 at 15:54
  • Thanks @dstull. Unfortunately, `rbenv install 2.4.2` doesn't work. Same `ruby-build: definition not found: 2.4.2`. And my `grep` finds nothing at all. – Philippe Perret Dec 29 '17 at 16:05
  • Thanks @Joe, but I already know that… That solves nothing, unfortunately. ;-) – Philippe Perret Dec 29 '17 at 16:08
  • I know you said you did brew update already - is this what you ran? `brew upgrade rbenv ruby-build` . also, what does `which rbenv` show you? – dstull Dec 29 '17 at 16:42
  • @dstull `which rbenv` -> `/usr/local/bin/rbenv`. I updated rbenv and ruby-build… Right now, I am upgrading all with `brew upgrade`. Take a while… – Philippe Perret Dec 29 '17 at 16:48
  • ok - kinda looks like you had 2 rbenv's installed - one OS level and one homebrew..you could put the one homebrew installed first in your path and it will likely resolve – dstull Dec 29 '17 at 23:27
  • @dstull, how can I "put the one homebrew installed first in my path"? Really thanks for your help… – Philippe Perret Dec 30 '17 at 09:46
  • well first determine where you installed homebrew - i.e. on my machine, rbenv exists here: `/usr/local/homebrew/bin/brew`, then put this in your path - you can issue this command on the console to do it immediately, then put in .bash_profile for future logins(if using bash): `export PATH=/usr/local/homebrew/bin:$PATH` - then the rbenv you are targeting w/brew should be under the homebrew/bin dir, but you can search like this if you really want to; to see: `find / -name 'rbenv' 2>/dev/null` – dstull Dec 30 '17 at 18:26
  • OK, you meant "put in your PATH". Thanks for your effort, @dstull, but this solution will not help… For instance, apache server doesn't load the .bash_profile file. By the way, you can use `locate rbenv` rather than `find`, and `-print` option rather than `2>/dev/null` ;-). A big hug for your help! And Happy New Year to you! – Philippe Perret Dec 31 '17 at 06:01
  • Ok. i am not sure what apache has to do with this as we were trying to figure out why the standard rbenv steps for installing ruby were not working for you on a local laptop..no more, no less. Apache setup is a separate issue, but could be resolved as well for a production like setup..but out of scope for the question asked – dstull Jan 01 '18 at 12:15
  • @dstull Local laptop with a apache server. And it's the origin of my problem. My local server doesn't find the gems installed. After a lot of investigations, I discovered the multiple and confusionning ruby versions. So the question. – Philippe Perret Jan 01 '18 at 12:34

1 Answers1

0

Without any answer, the only way I found was to remove all ruby versions:

> brew remove --force ruby
> brew uninstall --ignore-dependencies ruby
> brew uninstall --force ruby
> sudo rm -rf /usr/local/lib/ruby
> sudo rm -rf ~/.rbenv
> sudo rm -rf ~/.gem

Now I use 2.3.3 version everywhere.

> ruby -v
# => 2.3.3

In brew config:

Homebrew Ruby: 2.3.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
Ruby: /usr/bin/ruby => /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby

I can find my gems in /Library/Ruby/Gems/2.3.0/gems:

gem which sass
# => /Library/Ruby/Gems/2.3.0/gems/sass-3.5.4/lib/sass.rb

To install a new gem, super user privileges are required:

sudo gem install <gem name>

Thanks for help. Maybe It helps.