asdf-vm / asdf-ruby

Ruby plugin for asdf version manager
https://github.com/asdf-vm/asdf
MIT License
662 stars 134 forks source link

Ruby 2.6.5 fails to compile on MacOS Big Sur #184

Open bartoszmaka opened 3 years ago

bartoszmaka commented 3 years ago

After update to Big Sur, the ruby 2.6.5 won't compile. asdf install ruby 2.6.5 returns the following output:

Downloading openssl-1.1.1g.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/ddb04774f1e32f0c49751e21b67216ac87852ceb056b75209af2443400636d46
Installing openssl-1.1.1g...
Installed openssl-1.1.1g to /Users/bartoszmaka/.asdf/installs/ruby/2.6.5

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

BUILD FAILED (macOS 11.0.1 using ruby-build 20201005)

Inspect or clean up the working tree at /var/folders/q2/0bgpj9917svbst6d9ls2bdfh0000gn/T/ruby-build.20201124095057.44614.wwBG4Q
Results logged to /var/folders/q2/0bgpj9917svbst6d9ls2bdfh0000gn/T/ruby-build.20201124095057.44614.log

Last 10 log lines:
transform_mjit_header: SKIPPED to transform __inline_isinff
transform_mjit_header: SKIPPED to transform __inline_isfinitel
transform_mjit_header: SKIPPED to transform __inline_isfinited
transform_mjit_header: SKIPPED to transform __inline_isfinitef
transform_mjit_header: SKIPPED to transform __darwin_fd_clr
transform_mjit_header: SKIPPED to transform __darwin_fd_set
transform_mjit_header: SKIPPED to transform __darwin_fd_isset
transform_mjit_header: SKIPPED to transform __darwin_check_fd_set
transform_mjit_header: SKIPPED to transform __sputc
ln -sf ../../../.ext/include/x86_64-darwin20/rb_mjit_min_header-2.6.5.h include/ruby-2.6.0/x86_64-darwin20/rb_mjit_min_header-2.6.5.h

Those are last lines from compilation log:

linking miniruby
ld: warning: dylib (/usr/local/lib/libgmp.dylib) was built for newer macOS version (11.0) than being linked (10.15.6)
rb_mjit_header.h updated
generating encdb.h
building .ext/include/x86_64-darwin20/rb_mjit_min_header-2.6.5.h
./miniruby -I./lib -I. -I.ext/common  ./tool/transform_mjit_header.rb "clang " rb_mjit_header.h .ext/include/x86_64-darwin20/rb_mjit_min_header-2.6.5.h
encdb.h updated
./tool/ifchange "--timestamp=.rbconfig.time" rbconfig.rb rbconfig.tmp
rbconfig.rb updated
generating enc.mk
creating verconf.h
verconf.h updated
compiling loadpath.c
making srcs under enc
linking static-library libruby.2.6-static.a
make[1]: Nothing to be done for `srcs'.
generating transdb.h
linking shared-library libruby.2.6.dylib
ld: warning: dylib (/usr/local/lib/libgmp.dylib) was built for newer macOS version (11.0) than being linked (10.15.6)
Undefined symbols for architecture x86_64:
  "__mh_execute_header", referenced from:
      _rb_dump_backtrace_with_lines in addr2line.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [libruby.2.6.dylib] Error 1
make: *** Waiting for unfinished jobs....
transdb.h updated

The same issue occurs with ruby 2.7.2, and ruby 2.6.5 installed via rvm

Stratus3D commented 3 years ago

Not sure. I don't know that asdf-ruby or ruby-build (which it asdf-ruby uses) have gotten much use on Big Sur yet.

sohooo commented 3 years ago

Currently, the asdf-ruby plugin references an old ruby-build tag (which uses an old openssl version; we need openssl-111i https://github.com/rbenv/ruby-build/commit/bad7a7c0b4833f44cf653e7107f0e19e209bfe2e). I had to manually update the tag to be able to install Ruby on Apple M1:

.asdf/plugins/ruby  master ✗   
▶ git diff
diff --git a/lib/utils.sh b/lib/utils.sh
index 43c4409..ab81fab 100644
--- a/lib/utils.sh
+++ b/lib/utils.sh
@@ -1,4 +1,5 @@
-RUBY_BUILD_VERSION="${ASDF_RUBY_BUILD_VERSION:-v20201208}"
+# RUBY_BUILD_VERSION="${ASDF_RUBY_BUILD_VERSION:-v20201208}"
+RUBY_BUILD_VERSION="${ASDF_RUBY_BUILD_VERSION:-v20201210}"

With that, installing Ruby should work now:

▶ asdf list ruby
  2.7.2

▶ which ruby
/Users/sohooo/.asdf/shims/ruby

▶ ruby -v
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [arm64-darwin20]
edmangimelli commented 3 years ago

I ran into a problem installing ruby 2.6.6 (not 2.6.5) on Big Sur / 2020 MacBook Air (M1 / apple silicon). I tried every which way with openssl to no avail.

Found this comment in ruby-build issues:

santostiago commented on Jan 18 I ended up doing this: export optflags="-Wno-error=implicit-function-declaration"; export LDFLAGS="-L/opt/homebrew/opt/libffi/lib"; export CPPFLAGS="-I/opt/homebrew/opt/libffi/include"; export PKG_CONFIG_PATH="/opt/homebrew/opt/libffi/lib/pkgconfig" | rbenv install 2.5.5

Here's what I did:

export optflags="-Wno-error=implicit-function-declaration"
export LDFLAGS="-L/opt/homebrew/opt/libffi/lib"
export CPPFLAGS="-I/opt/homebrew/opt/libffi/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/libffi/lib/pkgconfig"
asdf install ruby 2.6.6

(fish shell version)

set -gx optflags "-Wno-error=implicit-function-declaration"
set -gx LDFLAGS "-L/opt/homebrew/opt/libffi/lib"
set -gx CPPFLAGS "-I/opt/homebrew/opt/libffi/include"
set -gx PKG_CONFIG_PATH "/opt/homebrew/opt/libffi/lib/pkgconfig"
asdf install ruby 2.6.6

if that doesn't work, let me know --I tried a bunch of things before I got there

rpdecks commented 3 years ago

What things did you try before this? I presume I need one of those preceding steps. I am still failing. Big Sur (not M1) ruby 2.6.5

edmangimelli commented 3 years ago

@rpdecks

sorry, these notes are a little rough:

installing asdf
installing coreutils (a dependency of asdf) (i already have curl and git) ``` username@MacBook-Air ~> brew install coreutils Updating Homebrew... ==> Homebrew is run entirely by unpaid volunteers. Please consider donating: https://github.com/Homebrew/brew#donations ==> Auto-updated Homebrew! Updated 1 tap (homebrew/core). ==> Updated Formulae Updated 43 formulae. ==> Downloading https://homebrew.bintray.com/bottles/coreutils-8.32.arm64_big_sur.bottle.2.tar.gz ==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/e7d88d2b7a91a57dfd37c2ea14752d1bb116f25694eab1161d6e8088f7db5921?respon ######################################################################## 100.0% ==> Pouring coreutils-8.32.arm64_big_sur.bottle.2.tar.gz /opt/homebrew/Library/Homebrew/download_strategy.rb:94: warning: conflicting chdir during another chdir block ==> Caveats Commands also provided by macOS have been installed with the prefix "g". If you need to use these commands with their normal names, you can add a "gnubin" directory to your PATH from your bashrc like: PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH" ==> Summary 🍺 /opt/homebrew/Cellar/coreutils/8.32: 476 files, 12MB ```
installing asdf ``` username@MacBook-Air ~> brew install asdf ==> Downloading https://homebrew.bintray.com/bottles/autoconf-2.69.arm64_big_sur.bottle.4.tar.gz ==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/e56508f2b40d96057225de13bc9ac27f1c64f4c120a5c73f34864a1669073fc9?respon ######################################################################## 100.0% ==> Downloading https://homebrew.bintray.com/bottles/automake-1.16.3.arm64_big_sur.bottle.tar.gz ==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/b989d3db71b5bc3456f52edd92b818d1fcb5c03e62ab5c6ffeb5bf404dc22aa5?respon ######################################################################## 100.0% ==> Downloading https://homebrew.bintray.com/bottles/libtool-2.4.6_2.arm64_big_sur.bottle.tar.gz ==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/c4f95f52617ef0d9a6ec19b5c581241be4593497cd120e42621f55b0ae9548b6?respon ######################################################################## 100.0% ==> Downloading https://homebrew.bintray.com/bottles/libyaml-0.2.5.arm64_big_sur.bottle.tar.gz ######################################################################## 100.0% ==> Downloading https://homebrew.bintray.com/bottles/openssl%400.1-1.1.1j.arm64_big_sur.bottle.tar.gz ==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/f8b99ea0ad2a19855aab784122271fbc811c69b03c53c0e8b959b02977e4444a?respon ######################################################################## 100.0% ==> Downloading https://homebrew.bintray.com/bottles/readline-8.1.arm64_big_sur.bottle.tar.gz ==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/940e7c2b80ef7f59b26726a5669a31fcb8ba7cbbb17eb1f2ca589dafa6e68e5e?respon ######################################################################## 100.0% ==> Downloading https://homebrew.bintray.com/bottles/unixodbc-2.3.9.arm64_big_sur.bottle.tar.gz ==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/112790241d32af0dedc7173711c714eae35ddac6f6aee9d5a7bc979063956990?respon ######################################################################## 100.0% ==> Downloading https://github.com/asdf-vm/asdf/archive/v0.8.0.tar.gz ==> Downloading from https://codeload.github.com/asdf-vm/asdf/tar.gz/v0.8.0 ######################################################################## 100.0% ==> Installing dependencies for asdf: autoconf, automake, libtool, libyaml, openssl@1.1, readline and unixodbc ==> Installing asdf dependency: autoconf ==> Pouring autoconf-2.69.arm64_big_sur.bottle.4.tar.gz 🍺 /opt/homebrew/Cellar/autoconf/2.69: 68 files, 3.0MB ==> Installing asdf dependency: automake ==> Pouring automake-1.16.3.arm64_big_sur.bottle.tar.gz 🍺 /opt/homebrew/Cellar/automake/1.16.3: 131 files, 3.4MB ==> Installing asdf dependency: libtool ==> Pouring libtool-2.4.6_2.arm64_big_sur.bottle.tar.gz ==> Caveats In order to prevent conflicts with Apple's own libtool we have prepended a "g" so, you have instead: glibtool and glibtoolize. ==> Summary 🍺 /opt/homebrew/Cellar/libtool/2.4.6_2: 71 files, 3.7MB ==> Installing asdf dependency: libyaml ==> Pouring libyaml-0.2.5.arm64_big_sur.bottle.tar.gz 🍺 /opt/homebrew/Cellar/libyaml/0.2.5: 10 files, 369.6KB ==> Installing asdf dependency: openssl@1.1 ==> Pouring openssl@1.1-1.1.1j.arm64_big_sur.bottle.tar.gz ==> Caveats A CA file has been bootstrapped using certificates from the system keychain. To add additional certificates, place .pem files in /opt/homebrew/etc/openssl@1.1/certs and run /opt/homebrew/opt/openssl@1.1/bin/c_rehash openssl@1.1 is keg-only, which means it was not symlinked into /opt/homebrew, because macOS provides LibreSSL. If you need to have openssl@1.1 first in your PATH, run: echo 'set -g fish_user_paths "/opt/homebrew/opt/openssl@1.1/bin" $fish_user_paths' >> ~/.config/fish/config.fish For compilers to find openssl@1.1 you may need to set: set -gx LDFLAGS "-L/opt/homebrew/opt/openssl@1.1/lib" set -gx CPPFLAGS "-I/opt/homebrew/opt/openssl@1.1/include" ==> Summary 🍺 /opt/homebrew/Cellar/openssl@1.1/1.1.1j: 8,071 files, 18MB ==> Installing asdf dependency: readline ==> Pouring readline-8.1.arm64_big_sur.bottle.tar.gz ==> Caveats readline is keg-only, which means it was not symlinked into /opt/homebrew, because macOS provides BSD libedit. For compilers to find readline you may need to set: set -gx LDFLAGS "-L/opt/homebrew/opt/readline/lib" set -gx CPPFLAGS "-I/opt/homebrew/opt/readline/include" ==> Summary 🍺 /opt/homebrew/Cellar/readline/8.1: 48 files, 1.7MB ==> Installing asdf dependency: unixodbc ==> Pouring unixodbc-2.3.9.arm64_big_sur.bottle.tar.gz 🍺 /opt/homebrew/Cellar/unixodbc/2.3.9: 46 files, 2.3MB ==> Installing asdf ==> Caveats fish completions have been installed to: /opt/homebrew/share/fish/vendor_completions.d ==> Summary 🍺 /opt/homebrew/Cellar/asdf/0.8.0: 115 files, 243KB, built in 1 second ==> Caveats ==> libtool In order to prevent conflicts with Apple's own libtool we have prepended a "g" so, you have instead: glibtool and glibtoolize. ==> openssl@1.1 A CA file has been bootstrapped using certificates from the system keychain. To add additional certificates, place .pem files in /opt/homebrew/etc/openssl@1.1/certs and run /opt/homebrew/opt/openssl@1.1/bin/c_rehash openssl@1.1 is keg-only, which means it was not symlinked into /opt/homebrew, because macOS provides LibreSSL. If you need to have openssl@1.1 first in your PATH, run: echo 'set -g fish_user_paths "/opt/homebrew/opt/openssl@1.1/bin" $fish_user_paths' >> ~/.config/fish/config.fish For compilers to find openssl@1.1 you may need to set: set -gx LDFLAGS "-L/opt/homebrew/opt/openssl@1.1/lib" set -gx CPPFLAGS "-I/opt/homebrew/opt/openssl@1.1/include" ==> readline readline is keg-only, which means it was not symlinked into /opt/homebrew, because macOS provides BSD libedit. For compilers to find readline you may need to set: set -gx LDFLAGS "-L/opt/homebrew/opt/readline/lib" set -gx CPPFLAGS "-I/opt/homebrew/opt/readline/include" ==> asdf fish completions have been installed to: /opt/homebrew/share/fish/vendor_completions.d ```
can't remember where this came from: ``` echo -e "\nsource "(brew --prefix asdf)"/asdf.fish" >> ~/.config/fish/config.fish ``` adding to .asdfrc ``` legacy_version_file = yes ```
installing Ruby 2.6.6 with asdf (FAILED) ``` asdf plugin-add ruby https://github.com/asdf-vm/asdf-ruby.git asdf update asdf install ruby 2.6.6 ``` ``` Downloading openssl-1.1.1i.tar.gz... -> https://dqw8nmjcqpjn7.cloudfront.net/e8be6a35fe41d10603c3cc635e93289ed00bf34b79671a3a4de64fcee00d5242 Installing openssl-1.1.1i... Installed openssl-1.1.1i to /Users/username/.asdf/installs/ruby/2.6.6 Downloading ruby-2.6.6.tar.bz2... -> https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.6.tar.bz2 Installing ruby-2.6.6... ruby-build: using readline from homebrew BUILD FAILED (macOS 11.2.1 using ruby-build 20201225) Inspect or clean up the working tree at /var/folders/xl/h01bytjx21d2j1ltnz65q_w40000gn/T/ruby-build.20210223015413.21725.ogHTr1 Results logged to /var/folders/xl/h01bytjx21d2j1ltnz65q_w40000gn/T/ruby-build.20210223015413.21725.log Last 10 log lines: compiling ../.././ext/psych/yaml/reader.c compiling ../.././ext/psych/yaml/emitter.c 3 warnings generated. compiling ../.././ext/psych/yaml/parser.c linking shared-object date_core.bundle 5 warnings generated. linking shared-object zlib.bundle 1 warning generated. linking shared-object psych.bundle make: *** [build-ext] Error 2 ```
installing Ruby 3.0.0 with asdf (SUCCESS) ``` username@MacBook-Air ~/Repos> asdf install ruby 3.0.0 Downloading openssl-1.1.1i.tar.gz... -> https://dqw8nmjcqpjn7.cloudfront.net/e8be6a35fe41d10603c3cc635e93289ed00bf34b79671a3a4de64fcee00d5242 Installing openssl-1.1.1i... Installed openssl-1.1.1i to /Users/username/.asdf/installs/ruby/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/username/.asdf/installs/ruby/3.0.0 ```
installing Ruby 2.7.2 with asdf (HANGS) ``` username@MacBook-Air ~/Repos [1]> 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/username/.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 ^C received sigint, cleaning up ```
installing Ruby 2.7.1 with asdf (FAILED) ``` username@MacBook-Air ~/Repos> asdf install ruby 2.7.1 Downloading openssl-1.1.1i.tar.gz... -> https://dqw8nmjcqpjn7.cloudfront.net/e8be6a35fe41d10603c3cc635e93289ed00bf34b79671a3a4de64fcee00d5242 Installing openssl-1.1.1i... Installed openssl-1.1.1i to /Users/username/.asdf/installs/ruby/2.7.1 Downloading ruby-2.7.1.tar.bz2... -> https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.1.tar.bz2 Installing ruby-2.7.1... ruby-build: using readline from homebrew BUILD FAILED (macOS 11.2.1 using ruby-build 20201225) Inspect or clean up the working tree at /var/folders/xl/h01bytjx21d2j1ltnz65q_w40000gn/T/ruby-build.20210223075451.49748.0YW9U8 Results logged to /var/folders/xl/h01bytjx21d2j1ltnz65q_w40000gn/T/ruby-build.20210223075451.49748.log Last 10 log lines: compiling psych_parser.c compiling psych_to_ruby.c compiling psych_yaml_tree.c compiling ../.././ext/psych/yaml/reader.c compiling ../.././ext/psych/yaml/scanner.c compiling ../.././ext/psych/yaml/writer.c linking shared-object stringio.bundle linking shared-object zlib.bundle linking shared-object psych.bundle make: *** [build-ext] Error 2 ```
trying a comment from rbenv issues (FAILED) trying this https://github.com/rbenv/ruby-build/issues/1691#issuecomment-772224551 ``` set -xp PATH "/opt/homebrew/opt/openssl@1.1/bin" set -gx LDFLAGS "-L/opt/homebrew/opt/openssl@1.1/lib" set -gx CPPFLAGS "-I/opt/homebrew/opt/openssl@1.1/include" set -gx PKG_CONFIG_PATH "/opt/homebrew/opt/openssl@1.1/lib/pkgconfig" set -gx RUBY_CONFIGURE_OPTS "--with-openssl-dir=/opt/homebrew/opt/openssl@1.1" ``` ^^^ also failed

let's try rbenv instead, first removing legacy_version_file = yes from .asdfrc

installing rbenv ``` brew install rbenv ``` ``` Updating Homebrew... ==> Auto-updated Homebrew! Updated 1 tap (homebrew/core). ==> Updated Formulae Updated 7 formulae. ==> Downloading https://homebrew.bintray.com/bottles/pkg-config-0.29.2_3.arm64_big_sur.bottle.tar.gz ==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/ffd4491f62201d14b7eca6beff954a2ab265351589cd5b3b79b8bbb414485574?response-content-disposition=attachment%3Bfilename%3D%22pkg-config-0.29.2_3.arm6 ######################################################################## 100.0% ==> Downloading https://github.com/rbenv/ruby-build/archive/v20210119.tar.gz ==> Downloading from https://codeload.github.com/rbenv/ruby-build/tar.gz/v20210119 ######################################################################## 100.0% ==> Downloading https://homebrew.bintray.com/bottles/rbenv-1.1.2.arm64_big_sur.bottle.tar.gz ######################################################################## 100.0% ==> Installing dependencies for rbenv: pkg-config and ruby-build ==> Installing rbenv dependency: pkg-config ==> Pouring pkg-config-0.29.2_3.arm64_big_sur.bottle.tar.gz 🍺 /opt/homebrew/Cellar/pkg-config/0.29.2_3: 11 files, 676.9KB ==> Installing rbenv dependency: ruby-build ==> ./install.sh ==> Caveats ruby-build installs a non-Homebrew OpenSSL for each Ruby version installed and these are never upgraded. To link Rubies to Homebrew's OpenSSL 1.1 (which is upgraded) add the following to your ~/.config/fish/config.fish: export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1)" Note: this may interfere with building old versions of Ruby (e.g <2.4) that use OpenSSL <1.1. ==> Summary 🍺 /opt/homebrew/Cellar/ruby-build/20210119: 520 files, 259.9KB, built in 1 second ==> Installing rbenv ==> Pouring rbenv-1.1.2.arm64_big_sur.bottle.tar.gz 🍺 /opt/homebrew/Cellar/rbenv/1.1.2: 36 files, 123.5KB ==> Caveats ==> ruby-build ruby-build installs a non-Homebrew OpenSSL for each Ruby version installed and these are never upgraded. To link Rubies to Homebrew's OpenSSL 1.1 (which is upgraded) add the following to your ~/.config/fish/config.fish: export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1)" Note: this may interfere with building old versions of Ruby (e.g <2.4) that use OpenSSL <1.1. ```
installing Ruby 2.6.6 with rbenv (FAILED) ``` username@MacBook-Air ~ [1]> rbenv install 2.6.6 Downloading openssl-1.1.1i.tar.gz... -> https://dqw8nmjcqpjn7.cloudfront.net/e8be6a35fe41d10603c3cc635e93289ed00bf34b79671a3a4de64fcee00d5242 Installing openssl-1.1.1i... Installed openssl-1.1.1i to /Users/username/.rbenv/versions/2.6.6 Downloading ruby-2.6.6.tar.bz2... -> https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.6.tar.bz2 Installing ruby-2.6.6... ruby-build: using readline from homebrew BUILD FAILED (macOS 11.2.1 using ruby-build 20210119) Inspect or clean up the working tree at /var/folders/xl/h01bytjx21d2j1ltnz65q_w40000gn/T/ruby-build.20210223110322.18877.KScox2 Results logged to /var/folders/xl/h01bytjx21d2j1ltnz65q_w40000gn/T/ruby-build.20210223110322.18877.log Last 10 log lines: ~~~~~~ ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~ 3 warnings generated. compiling ../.././ext/psych/yaml/reader.c compiling ../.././ext/psych/yaml/emitter.c compiling ../.././ext/psych/yaml/parser.c 5 warnings generated. linking shared-object zlib.bundle 1 warning generated. linking shared-object psych.bundle make: *** [build-ext] Error 2 ``` ``` set -gx RUBY_CONFIGURE_OPTS "--with-openssl-dir="(brew --prefix openssl@1.1) rbenv install 2.6.6 ``` also failed ^^^
brew uninstall rbenv
installing Ruby 2.6.6 with asdf - Round 2 (FAILED) following this: https://github.com/rbenv/ruby-build/issues/1691#issuecomment-751936989 installed xcode command line tools Command_Line_Tools_for_Xcode_12.5_beta_2.dmg ``` brew reinstall -s readline brew install libyaml asdf install ruby 2.6.6 ``` ^^ failed
installing Ruby 2.6.6 with asdf - Round 3 (SUCCESS!!!) ``` brew uninstall --ignore-dependencies readline brew uninstall --ignore-dependencies openssl rm -rf /opt/homebrew/etc/openssl@1.1 rm -rf /opt/homebrew/etc/openssl@1.1/cert.pem rm -rf /opt/homebrew/etc/openssl@1.1/certs rm -rf /opt/homebrew/etc/openssl@1.1/ct_log_list.cnf rm -rf /opt/homebrew/etc/openssl@1.1/ct_log_list.cnf.dist rm -rf /opt/homebrew/etc/openssl@1.1/misc rm -rf /opt/homebrew/etc/openssl@1.1/misc/CA.pl rm -rf /opt/homebrew/etc/openssl@1.1/misc/tsget rm -rf /opt/homebrew/etc/openssl@1.1/misc/tsget.pl rm -rf /opt/homebrew/etc/openssl@1.1/openssl.cnf rm -rf /opt/homebrew/etc/openssl@1.1/openssl.cnf.dist rm -rf /opt/homebrew/etc/openssl@1.1/private brew uninstall --ignore-dependencies ruby-build brew install -s readline brew install -s openssl brew install -s ruby-build asdf install ruby 2.6.6 # FAILED set -gx RUBY_CONFIGURE_OPTS "--with-openssl-dir="(brew --prefix openssl@1.1) asdf install ruby 2.6.6 # FAILED set -gxp PATH "/opt/homebrew/opt/openssl@1.1/bin" set -gx LDFLAGS "-L/opt/homebrew/opt/openssl@1.1/lib" set -gx CPPFLAGS "-I/opt/homebrew/opt/openssl@1.1/include" set -gx PKG_CONFIG_PATH "/opt/homebrew/opt/openssl@1.1/lib/pkgconfig" set -gx RUBY_CONFIGURE_OPTS "--with-openssl-dir=/opt/homebrew/opt/openssl@1.1" asdf install ruby 2.6.6 #failed ``` from https://github.com/rbenv/ruby-build/issues/1699#issuecomment-762122911 `export optflags="-Wno-error=implicit-function-declaration"; export LDFLAGS="-L/opt/homebrew/opt/libffi/lib"; export CPPFLAGS="-I/opt/homebrew/opt/libffi/include"; export PKG_CONFIG_PATH="/opt/homebrew/opt/libffi/lib/pkgconfig"` converted to fish: ``` set -gx optflags "-Wno-error=implicit-function-declaration" set -gx LDFLAGS "-L/opt/homebrew/opt/libffi/lib" set -gx CPPFLAGS "-I/opt/homebrew/opt/libffi/include" set -gx PKG_CONFIG_PATH "/opt/homebrew/opt/libffi/lib/pkgconfig" ``` ``` asdf install ruby 2.6.6 # SUCCESS !!!!!! ``` adding to .asdfrc ``` legacy_version_file = yes ```
rpdecks commented 3 years ago

@edmangimelli you're the best. That was helpful. Who keeps notes like that?? Attempting to good citizen in response... I'm circling back here to note what worked for me.

brew uninstall --ignore-dependencies readline
brew uninstall --ignore-dependencies openssll
rm -rf /opt/homebrew/etc/openssl@1.1
rm -rf /opt/homebrew/etc/openssl@1.1/cert.pem
rm -rf /opt/homebrew/etc/openssl@1.1/certs 
rm -rf /opt/homebrew/etc/openssl@1.1/ct_log_list.cnf
rm -rf /opt/homebrew/etc/openssl@1.1/ct_log_list.cnf.dist
rm -rf /opt/homebrew/etc/openssl@1.1/misc
rm -rf /opt/homebrew/etc/openssl@1.1/misc/CA.pl
rm -rf /opt/homebrew/etc/openssl@1.1/misc/tsget
rm -rf /opt/homebrew/etc/openssl@1.1/misc/tsget.pl
rm -rf /opt/homebrew/etc/openssl@1.1/openssl.cnf
rm -rf /opt/homebrew/etc/openssl@1.1/openssl.cnf.dist
rm -rf /opt/homebrew/etc/openssl@1.1/private
brew install -s readline
brew install -s ruby-build
asdf install ruby 2.6.5
=> PROFIT!!

I did not set all those flags this time around but I did try that earlier before all the readline and openssl business... so perhaps that is still necessary? I use ZSH shell but foolishly typed it all in using the fish syntax... anyhow?

edmangimelli commented 3 years ago

ヘ( ^o^)ノ\(^_^ )

jujudellago commented 3 years ago

Took me a long day to try the different suggestions, could get ruby 2.6.5, 2.6.7, 3.0.1 compiled, with both asdf and rbenv.

But....

Still looking for a way to run rails server or console, all the rubies bring me the same ffi errors: 1: from /Users/juju/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/ffi-1.9.18/lib/ffi/library.rb:535:infind_type' /Users/juju/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/ffi-1.9.18/lib/ffi/types.rb:69:in find_type': unable to resolve type 'size_t' (TypeError)

Found a comment of a guy saying: I got an error from ffi as well on M1. What solved for me was to run bundle update ffi -- --disable-system-libffi

but this doesn't work, raising an error Could not find gem '--disable-system-libffi'.

For those who could successfully compile rubies, could you actually run rails with them ?

isikyus commented 3 years ago

Found a comment of a guy saying: I got an error from ffi as well on M1. What solved for me was to run bundle update ffi -- --disable-system-libffi

but this doesn't work, raising an error Could not find gem '--disable-system-libffi'.

For those who could successfully compile rubies, could you actually run rails with them ?

I'm not seeing this exact error, but I had a similar chain of issues (Ruby wouldn't install; fixed by overriding library path but then FFI didn't work). What worked for me is bundle config build.ffi --disable-system-libffi then bundle update ffi. You might need to gem uninstall ffi first.

oleksandr-danylchenko commented 2 years ago

@edmangimelli you're the best. That was helpful. Who keeps notes like that?? Attempting to good citizen in response... I'm circling back here to note what worked for me.

brew uninstall --ignore-dependencies readline
brew uninstall --ignore-dependencies openssll
rm -rf /opt/homebrew/etc/openssl@1.1
rm -rf /opt/homebrew/etc/openssl@1.1/cert.pem
rm -rf /opt/homebrew/etc/openssl@1.1/certs 
rm -rf /opt/homebrew/etc/openssl@1.1/ct_log_list.cnf
rm -rf /opt/homebrew/etc/openssl@1.1/ct_log_list.cnf.dist
rm -rf /opt/homebrew/etc/openssl@1.1/misc
rm -rf /opt/homebrew/etc/openssl@1.1/misc/CA.pl
rm -rf /opt/homebrew/etc/openssl@1.1/misc/tsget
rm -rf /opt/homebrew/etc/openssl@1.1/misc/tsget.pl
rm -rf /opt/homebrew/etc/openssl@1.1/openssl.cnf
rm -rf /opt/homebrew/etc/openssl@1.1/openssl.cnf.dist
rm -rf /opt/homebrew/etc/openssl@1.1/private
brew install -s readline
brew install -s ruby-build
asdf install ruby 2.6.5
=> PROFIT!!

I did not set all those flags this time around but I did try that earlier before all the readline and openssl business... so perhaps that is still necessary? I use ZSH shell but foolishly typed it all in using the fish syntax... anyhow?

This solution didn't work on macOS 12.6 + ruby-build 20221004

Andreas-Just commented 1 year ago

This solution didn't work on macOS 12.6 + ruby-build 20221004

Not supported on macOS 13.0 either (ruby-build 20221101). Unfortunately, this is it. Ruby 2.6.X is outdated, so don’t expect the situation to change.

Ruby 2.6 reached the end of life in March 2022. Upgrading to 2.7.X is the recommended approach, and it might not be as complicated as you might think.

orthodoX commented 1 year ago

I assume you are using the M1 chip on your machine. I've wrote a SO post about this that might help you get it running https://stackoverflow.com/questions/69012676/install-older-ruby-versions-on-a-m1-macbook/69012677#69012677

sephethus commented 1 year ago

brew uninstall --ignore-dependencies readline

So I'm trying to figure out how to solve this same problem in OS Ventura and clearly something has changed in the last couple of years with regards to where Homebrew is now located. It is no longer in /opt/Homebrew

brandoncc commented 1 year ago

I finally solved my situation with:

brew uninstall libffi
brew install libffi

set -gx LDFLAGS "-L/usr/local/opt/libffi/lib"
set -gx CPPFLAGS "-I/usr/local/opt/libffi/include"
asdf install ruby 2.6.10

I'm using an Intel mac.

AlanGabbianelli commented 1 year ago

I ran into a problem installing ruby 2.6.6 (not 2.6.5) on Big Sur / 2020 MacBook Air (M1 / apple silicon). I tried every which way with openssl to no avail.

Found this comment in ruby-build issues:

santostiago commented on Jan 18 I ended up doing this: export optflags="-Wno-error=implicit-function-declaration"; export LDFLAGS="-L/opt/homebrew/opt/libffi/lib"; export CPPFLAGS="-I/opt/homebrew/opt/libffi/include"; export PKG_CONFIG_PATH="/opt/homebrew/opt/libffi/lib/pkgconfig" | rbenv install 2.5.5

Here's what I did:

export optflags="-Wno-error=implicit-function-declaration"
export LDFLAGS="-L/opt/homebrew/opt/libffi/lib"
export CPPFLAGS="-I/opt/homebrew/opt/libffi/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/libffi/lib/pkgconfig"
asdf install ruby 2.6.6

(fish shell version)

set -gx optflags "-Wno-error=implicit-function-declaration"
set -gx LDFLAGS "-L/opt/homebrew/opt/libffi/lib"
set -gx CPPFLAGS "-I/opt/homebrew/opt/libffi/include"
set -gx PKG_CONFIG_PATH "/opt/homebrew/opt/libffi/lib/pkgconfig"
asdf install ruby 2.6.6

if that doesn't work, let me know --I tried a bunch of things before I got there

This also worked for me to install 2.6.5