Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot install any version of ruby on Mojave - internal ranlib command failed

I know there are a few silimar issues to this one, but I cannot find one that matches my issue.

I cannot install any version of ruby with either rvm nor rbenv. Both result in the same error. For example, here's an extract for the logs when installing ruby 2.5.3:

compiling loadpath.c
making srcs under enc
linking static-library libruby.2.5.3-static.a
make[1]: Nothing to be done for `srcs'.
generating transdb.h
/opt/local/bin/ranlib: object: libruby.2.5.3-static.a(dln.o) malformed object (unknown load command 1)
ar: internal ranlib command failed
make: *** [libruby.2.5.3-static.a] Error 1
make: *** Waiting for unfinished jobs....
transdb.h updated

The issue seems to be here:

/opt/local/bin/ranlib: object: libruby.2.5.3-static.a(dln.o) malformed object (unknown load command 1)
ar: internal ranlib command failed
make: *** [libruby.2.5.3-static.a] Error 1

What I've tried

  • Installing, reinstalling, uninstalling rvm, rbenv.
  • Updating, reinstalling XCode.
  • Deleting, installing, XCode command line tools.

What is causing this?

Update

gcc --version returns:

gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1
Apple LLVM version 10.0.0 (clang-1000.10.44.4)
Target: x86_64-apple-darwin18.0.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
like image 913
andy Avatar asked Jan 25 '19 10:01

andy


2 Answers

For anyone else who steps on the same landmine, for me it was that there was an incompatible copy of ranlib from homebrew via the cctools package. To fix it, I just uninstalled it:

brew uninstall cctools

like image 157
Chris Conover Avatar answered Oct 21 '22 06:10

Chris Conover


For those who find this and aren't helped by the above solution...

I ran into this issue as well. In my case it was due to MacPorts being outdated after I upgraded to (MacOS) Mojave.

I followed the steps listed on MacPorts' migration guide here: https://trac.macports.org/wiki/Migration

Closed and reopened Terminal (just b/c)

ran rvm install ruby and got Install of ruby-2.6.0 - #complete, hooray!

like image 31
Ryan Crews Avatar answered Oct 21 '22 05:10

Ryan Crews