Ruby-build: Unable to install Ruby versions >= 2.7.2. The error is "dyld: Library not loaded" for libruby.2.7.dylib

Created on 21 Jan 2021  路  7Comments  路  Source: rbenv/ruby-build

I am unable to install Ruby versions >= 2.7.2. The error is "dyld: Library not loaded" error for libruby.2.7.dylib. The error for Ruby 3.0.0 is similar. I'm on macOS Big Sur.

100% [1142/1142]  win32/README.win32

Generating RI format into /private/var/folders/_7/ry5dr9z94yxdty95rw2t82nw0000gn/T/ruby-build.20210121130100.92358.xJounK/ruby-2.7.2/.ext/rdoc...

  Files:       1142

  Classes:     1614 ( 758 undocumented)
  Modules:      327 ( 134 undocumented)
  Constants:   2436 ( 727 undocumented)
  Attributes:  1489 ( 559 undocumented)
  Methods:    13029 (3996 undocumented)

  Total:      18895 (6174 undocumented)
   67.32% documented

  Elapsed: 28.3s

    BASERUBY = /Users/cmurphy/.rbenv/shims/ruby --disable=gems
    CC = clang
    LD = ld
    LDSHARED = clang -dynamiclib
    CFLAGS = -O3 -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -std=gnu99  -fno-common -pipe
    XCFLAGS = -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fno-strict-overflow -fvisibility=hidden -DRUBY_EXPORT -DCANONICALIZATION_FOR_MATHN -I. -I.ext/include/x86_64-darwin20 -I./include -I. -I./enc/unicode/12.1.0
    CPPFLAGS = -I/Users/cmurphy/.rbenv/versions/2.7.2/include  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT
    DLDFLAGS = -L/Users/cmurphy/.rbenv/versions/2.7.2/lib  -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -install_name /Users/cmurphy/.rbenv/versions/2.7.2/lib/libruby.2.7.dylib -compatibility_version 2.7 -current_version 2.7.2  -fstack-protector-strong -framework Security -framework Foundation  -fstack-protector-strong -framework Security -framework Foundation
    SOLIBS = -lpthread -lgmp -ldl -lobjc
    LANG = en_US.UTF-8
    LC_ALL =
    LC_CTYPE =
    MFLAGS =

Apple clang version 12.0.0 (clang-1200.0.32.28)
Target: x86_64-apple-darwin20.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
dyld: Library not loaded: /Users/cmurphy/.rbenv/versions/2.7.2/lib/libruby.2.7.dylib
  Referenced from: /var/folders/_7/ry5dr9z94yxdty95rw2t82nw0000gn/T/ruby-build.20210121130100.92358.xJounK/ruby-2.7.2/ruby
  Reason: image not found
/bin/sh: line 1: 43664 Abort trap: 6           /Users/cmurphy/.rbenv/shims/ruby --disable=gems ./tool/file2lastrev.rb -q --revision.h --srcdir="." > revision.tmp
make: *** [revision.tmp] Error 134

BUILD FAILED (macOS 11.1 using ruby-build 20210119)

Inspect or clean up the working tree at /var/folders/_7/ry5dr9z94yxdty95rw2t82nw0000gn/T/ruby-build.20210121130100.92358.xJounK
Results logged to /var/folders/_7/ry5dr9z94yxdty95rw2t82nw0000gn/T/ruby-build.20210121130100.92358.log

Last 10 log lines:
    MFLAGS =
Apple clang version 12.0.0 (clang-1200.0.32.28)
Target: x86_64-apple-darwin20.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
dyld: Library not loaded: /Users/cmurphy/.rbenv/versions/2.7.2/lib/libruby.2.7.dylib
  Referenced from: /var/folders/_7/ry5dr9z94yxdty95rw2t82nw0000gn/T/ruby-build.20210121130100.92358.xJounK/ruby-2.7.2/ruby
  Reason: image not found
/bin/sh: line 1: 43664 Abort trap: 6           /Users/cmurphy/.rbenv/shims/ruby --disable=gems ./tool/file2lastrev.rb -q --revision.h --srcdir="." > revision.tmp
make: *** [revision.tmp] Error 134

ruby-build.log

Most helpful comment

Check your PATH. After removing .: (current directory), Ruby 2.7+ installs for me successfully.

Bad:

$ echo $PATH
/Users/cmurphy/.rbenv/shims:.:./bin: # and so on...

Good:

$ echo $PATH
/Users/you/.rbenv/shims:./bin: # and so on...
$ rbenv install 2.7.2
Downloading openssl-1.1.1i.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/e8be6a35fe41d10603c3cc635e93289ed00bf34b79671a3a4de64fcee00d5242
Installing openssl-1.1.1i...
Installed openssl-1.1.1i to /Users/cmurphy/.rbenv/versions/2.7.2

Downloading ruby-2.7.2.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.2.tar.bz2
Installing ruby-2.7.2...
ruby-build: using readline from homebrew
Installed ruby-2.7.2 to /Users/cmurphy/.rbenv/versions/2.7.2

$ rbenv install 3.0.0
Downloading openssl-1.1.1i.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/e8be6a35fe41d10603c3cc635e93289ed00bf34b79671a3a4de64fcee00d5242
Installing openssl-1.1.1i...
Installing openssl-1.1.1i...
Installed openssl-1.1.1i to /Users/cmurphy/.rbenv/versions/3.0.0

Downloading ruby-3.0.0.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.0.tar.gz
Installing ruby-3.0.0...
ruby-build: using readline from homebrew
Installed ruby-3.0.0 to /Users/cmurphy/.rbenv/versions/3.0.0

All 7 comments

Same error with Catalina (10.15.7) and xcode (Version 12.4 (12D4e))

Check your PATH. After removing .: (current directory), Ruby 2.7+ installs for me successfully.

Bad:

$ echo $PATH
/Users/cmurphy/.rbenv/shims:.:./bin: # and so on...

Good:

$ echo $PATH
/Users/you/.rbenv/shims:./bin: # and so on...
$ rbenv install 2.7.2
Downloading openssl-1.1.1i.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/e8be6a35fe41d10603c3cc635e93289ed00bf34b79671a3a4de64fcee00d5242
Installing openssl-1.1.1i...
Installed openssl-1.1.1i to /Users/cmurphy/.rbenv/versions/2.7.2

Downloading ruby-2.7.2.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.2.tar.bz2
Installing ruby-2.7.2...
ruby-build: using readline from homebrew
Installed ruby-2.7.2 to /Users/cmurphy/.rbenv/versions/2.7.2

$ rbenv install 3.0.0
Downloading openssl-1.1.1i.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/e8be6a35fe41d10603c3cc635e93289ed00bf34b79671a3a4de64fcee00d5242
Installing openssl-1.1.1i...
Installing openssl-1.1.1i...
Installed openssl-1.1.1i to /Users/cmurphy/.rbenv/versions/3.0.0

Downloading ruby-3.0.0.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.0.tar.gz
Installing ruby-3.0.0...
ruby-build: using readline from homebrew
Installed ruby-3.0.0 to /Users/cmurphy/.rbenv/versions/3.0.0

The above works around the issue. Should Rubies 2.7+ fail to build when the current directory (.) is included in the PATH though?

I had the same issue, but it was another problem in the $PATH:

/Users/you/.rbenv/shims::/ # and so on...

Removing of second colon symbol helped. /Users/you/.rbenv/shims:/ # and so on...

I had the same error, but my OS is mac 10.15.7 and my path is as follow:

/Users/huyvo/.asdf/shims:/Users/huyvo/.asdf/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Library/Apple/usr/bin:/Users/huyvo/.zinit/polaris/sbin:/Users/huyvo/.zinit/polaris/bin:/Users/huyvo/Library/Android/sdk/emulator:/Users/huyvo/Library/Android/sdk/tools:/Users/huyvo/Library/Android/sdk/tools/bin:/Users/huyvo/Library/Android/sdk/platform-tools:/Users/huyvo/.fzf/bin

I don't know what's wrong?

Output of asdf install ruby 2.7.2:

Downloading openssl-1.1.1i.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/e8be6a35fe41d10603c3cc635e93289ed00bf34b79671a3a4de64fcee00d5242
Installing openssl-1.1.1i...
Installed openssl-1.1.1i to /Users/huyvo/.asdf/installs/ruby/2.7.2

Downloading ruby-2.7.2.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.2.tar.bz2
Installing ruby-2.7.2...
ruby-build: using readline from homebrew

BUILD FAILED (Mac OS X 10.15.7 using ruby-build 20201225)

Inspect or clean up the working tree at /var/folders/bd/phnbltcx17sfq3_bvkxmcy7m0000gn/T/ruby-build.20210326170905.54439.FwVIGY
Results logged to /var/folders/bd/phnbltcx17sfq3_bvkxmcy7m0000gn/T/ruby-build.20210326170905.54439.log

Last 10 log lines:
        MFLAGS =
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
dyld: Library not loaded: /Users/huyvo/.asdf/installs/ruby/2.7.2/lib/libruby.2.7.dylib
  Referenced from: /var/folders/bd/phnbltcx17sfq3_bvkxmcy7m0000gn/T/ruby-build.20210326170905.54439.FwVIGY/ruby-2.7.2/ruby
  Reason: image not found
/bin/sh: line 1: 86168 Abort trap: 6           /Users/huyvo/.asdf/shims/ruby --disable=gems ./tool/file2lastrev.rb -q --revision.h --srcdir="." > revision.tmp
make: *** [revision.tmp] Error 134

@huyvohcmc have you tried removing as many of those paths from your PATH to see if the problem goes away? If it does, then you can slowly add back each path until it breaks, then you'll know.

@chmurph2 Yeah it was Android SDK paths.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kriscard picture kriscard  路  5Comments

Lukom picture Lukom  路  5Comments

JDutil picture JDutil  路  3Comments

artoodeeto picture artoodeeto  路  4Comments

noraj picture noraj  路  4Comments