Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to install Ruby 3.2.0 due to libyaml & psych related failure (M1 Chip Related) #328

Closed
edwinthinks opened this issue Jan 9, 2023 · 7 comments

Comments

@edwinthinks
Copy link

Greetings! Hope this isn't a repeat issue and this is actually new. Either way, I'm hoping to get some guidance.

I'm encountering the following issue when I run asdf install ruby 3.2.0:

To follow progress, use 'tail -f /var/folders/hw/xt0thdhd3ysghbkd16smwk140000gn/T/ruby-build.20230109121040.89183.log' or pass --verbose
Downloading openssl-3.0.7.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/83049d042a260e696f62406ac5c08bf706fd84383f945cf21bd61e9ed95c396e
Installing openssl-3.0.7...
Installed openssl-3.0.7 to /Users/emak/.asdf/installs/ruby/3.2.0

Downloading ruby-3.2.0.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.0.tar.gz
Installing ruby-3.2.0...
ruby-build: using readline from homebrew
ruby-build: using gmp from homebrew

BUILD FAILED (macOS 12.6.1 using ruby-build 20221225)

Inspect or clean up the working tree at /var/folders/hw/xt0thdhd3ysghbkd16smwk140000gn/T/ruby-build.20230109121040.89183.0fqGWu
Results logged to /var/folders/hw/xt0thdhd3ysghbkd16smwk140000gn/T/ruby-build.20230109121040.89183.log

Last 10 log lines:
	Check ext/psych/mkmf.log for more details.
*** Fix the problems, then remove these directories and try again if you want.
Generating RDoc documentation
/private/var/folders/hw/xt0thdhd3ysghbkd16smwk140000gn/T/ruby-build.20230109121040.89183.0fqGWu/ruby-3.2.0/lib/yaml.rb:3: warning: It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
uh-oh! RDoc had a problem:
cannot load such file -- psych

run with --debug for full backtrace
make: *** [rdoc] Error 1

What I've tried

I've tried installing libyaml which says it already installed when running brew install libyaml

I tried to install psych 5.0.1 using gem install psych which yields the following error saying that yaml.h not found:

Building native extensions. This could take a while...
ERROR:  Error installing psych:
	ERROR: Failed to build gem native extension.

    current directory: /Users/emak/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/gems/psych-5.0.1/ext/psych
/Users/emak/.asdf/installs/ruby/3.1.3/bin/ruby -I /Users/emak/.asdf/installs/ruby/3.1.3/lib/ruby/3.1.0 extconf.rb
checking for yaml.h... no
yaml.h not found
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
	--with-opt-dir
	--without-opt-dir
	--with-opt-include
	--without-opt-include=${opt-dir}/include
	--with-opt-lib
	--without-opt-lib=${opt-dir}/lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=/Users/emak/.asdf/installs/ruby/3.1.3/bin/$(RUBY_BASE_NAME)
	--with-libyaml-source-dir
	--without-libyaml-source-dir
	--with-yaml-0.1-dir
	--without-yaml-0.1-dir
	--with-yaml-0.1-include
	--without-yaml-0.1-include=${yaml-0.1-dir}/include
	--with-yaml-0.1-lib
	--without-yaml-0.1-lib=${yaml-0.1-dir}/lib
	--with-yaml-0.1-config
	--without-yaml-0.1-config
	--with-pkg-config
	--without-pkg-config
	--with-libyaml-dir
	--without-libyaml-dir
	--with-libyaml-include
	--without-libyaml-include=${libyaml-dir}/include
	--with-libyaml-lib
	--without-libyaml-lib=${libyaml-dir}/lib

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Users/emak/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/extensions/arm64-darwin-21/3.1.0/psych-5.0.1/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/emak/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/gems/psych-5.0.1 for inspection.
Results logged to /Users/emak/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/extensions/arm64-darwin-21/3.1.0/psych-5.0.1/gem_make.out

Operating System

MacOSX Montery 12.16.1 - M1 Max Chip

Appreciate it!

@edwinthinks
Copy link
Author

I was able to get it to work by first running (credit to #198 (comment)):

export RUBY_CONFIGURE_OPTS="--with-zlib-dir=$(brew --prefix zlib) --with-openssl-dir=$(brew --prefix openssl@1.1) --with-readline-dir=$(brew --prefix readline) --with-libyaml-dir=$(brew --prefix libyaml)"

and then

asdf install ruby 3.2.0

Note - I've heard and cannot confirm myself that upgrading to macOS Venture solves this problem too.

@edwinthinks edwinthinks changed the title Failed to install Ruby 3.2.0 due to libyaml & psych related failure Failed to install Ruby 3.2.0 due to libyaml & psych related failure (M1 Chip Related) Jan 11, 2023
@crlane
Copy link

crlane commented Feb 16, 2023

For Ventura, the openssl version has changed. The workaround above should now be:

export RUBY_CONFIGURE_OPTS="--with-zlib-dir=$(brew --prefix zlib) --with-openssl-dir=$(brew --prefix openssl@3) --with-readline-dir=$(brew --prefix readline) --with-libyaml-dir=$(brew --prefix libyaml)"

This worked on 13.2.1 and M2 chip.

@NicholusMuwonge
Copy link

This is the only thing that worked for me on my M2 pro chipped Mac.

For Ventura, the openssl version has changed. The workaround above should now be:

export RUBY_CONFIGURE_OPTS="--with-zlib-dir=$(brew --prefix zlib) --with-openssl-dir=$(brew --prefix openssl@3) --with-readline-dir=$(brew --prefix readline) --with-libyaml-dir=$(brew --prefix libyaml)"

This worked on 13.2.1 and M2 chip.

This is the only thing that worked for me on my M2 pro chipped Mac.

@spencerdcarlson
Copy link

I was able to get it to work by first running (credit to #198 (comment)):

export RUBY_CONFIGURE_OPTS="--with-zlib-dir=$(brew --prefix zlib) --with-openssl-dir=$(brew --prefix openssl@1.1) --with-readline-dir=$(brew --prefix readline) --with-libyaml-dir=$(brew --prefix libyaml)"

and then

asdf install ruby 3.2.0

Note - I've heard and cannot confirm myself that upgrading to macOS Venture solves this problem too.

Also make sure that the referenced binaries are installed via homebrew

brew install zlib openssl@1.1 readline libyaml

@jwalinrami
Copy link

jwalinrami commented Aug 9, 2023

I've been trying to install ruby 3.2.2 on Macbook pro with M2 and Ventura 13.4.1 on it. Default ruby by mac is '2.6.10p210 (2022-04-12 revision 67958) [universal.arm64e-darwin22]'.

  • asdf install is failing despite trying several different ways including those mentioned above.
% asdf install
nodejs 18.16.0 is already installed
To follow progress, use 'tail -f /var/folders/6n/h3k8tctx53zblr2d5s9yw1vctp0f93/T/ruby-build.20230809094850.2082.log' or pass --verbose
Downloading ruby-3.2.2.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.2.tar.gz
Installing ruby-3.2.2...
ruby-build: using gmp from homebrew

BUILD FAILED (macOS 13.4.1 using ruby-build 20230717)

Inspect or clean up the working tree at /var/folders/6n/h3k8tctx53zblr2d5s9yw1vctp0f93/T/ruby-build.20230809094850.2082.kl5mhj
Results logged to /var/folders/6n/h3k8tctx53zblr2d5s9yw1vctp0f93/T/ruby-build.20230809094850.2082.log

Last 10 log lines:
compiling ossl_ts.c
linking shared-object json/ext/parser.bundle
make[1]: *** [ext/digest/sha2/all] Error 2
compiling ossl_x509cert.c
compiling ossl_x509crl.c
compiling ossl_x509attr.c
compiling ossl_x509.c
compiling ossl_x509ext.c
make[1]: *** [ext/openssl/all] Error 2
make: *** [build-ext] Error 2
% RUBY_CFLAGS="-Wno-error=implicit-function-declaration" asdf install
nodejs 18.16.0 is already installed
To follow progress, use 'tail -f /var/folders/6n/h3k8tctx53zblr2d5s9yw1vctp0f93/T/ruby-build.20230809095904.23520.log' or pass --verbose
Downloading ruby-3.2.2.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.2.tar.gz
Installing ruby-3.2.2...
ruby-build: using gmp from homebrew

BUILD FAILED (macOS 13.4.1 using ruby-build 20230717)

Inspect or clean up the working tree at /var/folders/6n/h3k8tctx53zblr2d5s9yw1vctp0f93/T/ruby-build.20230809095904.23520.FQ75Fl
Results logged to /var/folders/6n/h3k8tctx53zblr2d5s9yw1vctp0f93/T/ruby-build.20230809095904.23520.log

Last 10 log lines:
clang: note: diagnostic msg: /Users/jrami/Library/Logs/DiagnosticReports/clang_<YYYY-MM-DD-HHMMSS>_<hostname>.crash
clang: note: diagnostic msg: (choose the .crash file that corresponds to your crash)
clang: note: diagnostic msg:

********************
make[2]: *** [ancdata.o] Error 254
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [ext/digest/sha2/all] Error 2
make[1]: *** [ext/socket/all] Error 2
make: *** [build-ext] Error 2

@onesneakymofo
Copy link

onesneakymofo commented Aug 22, 2023

For the ADHDers like me / tldr; out there:

  1. Run brew install zlib openssl@1.1 readline libyaml
  2. Run export RUBY_CONFIGURE_OPTS="--with-zlib-dir=$(brew --prefix zlib) --with-openssl-dir=$(brew --prefix openssl@1.1) --with-readline-dir=$(brew --prefix readline) --with-libyaml-dir=$(brew --prefix libyaml)"
  3. Run asdf install ruby latest if you want the latest version or asdf install ruby 3.2.0 for this particular ticket.

This got me Ruby 3.2.2 on my M2 machine runnning Venture 13.4.2

@ccastillop
Copy link

It worked for me:
TaKO8Ki/frum#126 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants