Home > Software design >  Can't install RubyGems on mac: because Objective-C garbage collection is not supported
Can't install RubyGems on mac: because Objective-C garbage collection is not supported

Time:10-27

I am installing Ruby with RVM on MacOS, and apparently it also installs RubyGems along the way:

macruby-0.12 - #installing rubygems-3.0.9.

And right after that line I get this error:

Error running 'env GEM_HOME=/Users/alex/.rvm/gems/macruby-0.12@global GEM_PATH= /Users/alex/.rvm/rubies/macruby-0.12/bin/ruby -d /Users/alex/.rvm/src/rubygems-3.0.9/setup.rb --no-document',
please read /Users/alex/.rvm/log/1635157083_macruby-0.12/rubygems.install.log

The file /Users/alex/.rvm/log/1635157083_macruby-0.12/rubygems.install.log has the following log:

[2021-10-25 13:18:15] /Users/alex/.rvm/rubies/macruby-0.12/bin/ruby
current path: /Users/alex/.rvm/src/rubygems-3.0.9
PATH=/usr/local/Cellar/ruby/2.4.1_1/bin:/usr/local/mysql/bin:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/3.9/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/alex/.rvm/bin
command(7): env GEM_HOME=/Users/alex/.rvm/gems/macruby-0.12@global GEM_PATH= /Users/alex/.rvm/rubies/macruby-0.12/bin/ruby -d /Users/alex/.rvm/src/rubygems-3.0.9/setup.rb --no-document
dyld: dyld cache load error: existing shared cache in memory is not compatible
dyld: Library not loaded: /Library/Frameworks/MacRuby.framework/Versions/0.12/usr/lib/libmacruby.dylib
  Referenced from: /Users/alex/.rvm/rubies/macruby-0.12/usr/bin/macruby
  Reason: no suitable image found.  Did find:
    /Users/alex/.rvm/rubies/macruby-0.12/usr/lib/libmacruby.dylib: cannot load '/Users/alex/.rvm/rubies/macruby-0.12/usr/lib/libmacruby.dylib' because Objective-C garbage collection is not supported
    /Users/alex/.rvm/rubies/macruby-0.12/usr/lib/libmacruby.dylib: stat() failed with errno=1

How do I fix it?

CodePudding user response:

MacRuby is a completely different (and apparently unmaintained) re-implementation of the Ruby language based on macOS primitives. Given that MacRuby was never finished and was last updated in 2012, it appears that MacRuby is not compatible with modern macOS versions anymore.

With that being said, MacRuby is different from the "default" Ruby implementation usually called MRI or just ruby. On your Mac (as well as Linux, other *nix systems or Windows), you can just use the standard Ruby just fine.

To install the latest version of Ruby using RVM, you can run

rvm install 3.0
rvm use 3.0

At the time this answer was written, this will install and activate Ruby 3.0.2 on your Mac.

  • Related