ruby/psych

Cannot install on an M1 Mac using `--with-libyaml-source-dir`

stevecheckoway opened this issue · 0 comments

gem install psych -- --with-libyaml-source-dir=/path/to/dir fails on an M1 Mac because psych is passing --host=arm64-apple-darwin22 and that host isn't recognized by the libyaml configure script.

Compile output
$ gem install psych -- --with-libyaml-source-dir="$PWD/yaml-0.2.5"
Building native extensions with: '--with-libyaml-source-dir=/Users/steve/.local/share/source/yaml-0.2.5'
This could take a while...
ERROR:  Error installing psych:
	ERROR: Failed to build gem native extension.

    current directory: /Users/steve/.local/share/gem/ruby/3.1.0/gems/psych-5.0.1/ext/psych
/nix/store/4a5x886ahr2g90yknfw9y7pnn63zn85l-ruby-3.1.2/bin/ruby -I /nix/store/4a5x886ahr2g90yknfw9y7pnn63zn85l-ruby-3.1.2/lib/ruby/3.1.0 extconf.rb --with-libyaml-source-dir\=/Users/steve/.local/share/source/yaml-0.2.5
Configuring libyaml source in /Users/steve/.local/share/source/yaml-0.2.5
/Users/steve/.local/share/source/yaml-0.2.5/configure --enable-shared --host=arm64-apple-darwin22 CC=clang CFLAGS=-w
checking for a BSD-compatible install... /Users/steve/.nix-profile/bin/install -c
checking whether build environment is sane... yes
checking for arm64-apple-darwin22-strip... no
checking for strip... strip
checking for a thread-safe mkdir -p... /Users/steve/.nix-profile/bin/mkdir -p
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for arm64-apple-darwin22-gcc... clang
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether clang accepts -g... yes
checking for clang option to accept ISO C89... none needed
checking whether clang understands -c and -o together... yes
checking for style of include used by make... GNU
checking dependency style of clang... gcc3
checking how to run the C preprocessor... clang -E
checking whether ln -s works... yes
checking whether make sets $(MAKE)... (cached) yes
checking build system type... arm-apple-darwin22.1.0
checking host system type... Invalid configuration `arm64-apple-darwin22': machine `arm64-apple' not recognized
configure: error: /bin/sh /Users/steve/.local/share/source/yaml-0.2.5/config/config.sub arm64-apple-darwin22 failed
*** 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=/nix/store/4a5x886ahr2g90yknfw9y7pnn63zn85l-ruby-3.1.2/bin/$(RUBY_BASE_NAME)
	--with-libyaml-source-dir
extconf.rb:31:in `<main>': failed to configure libyaml (RuntimeError)

extconf failed, exit code 1

Gem files will remain installed in /Users/steve/.local/share/gem/ruby/3.1.0/gems/psych-5.0.1 for inspection.
Results logged to /Users/steve/.local/share/gem/ruby/3.1.0/extensions/arm64-darwin-22/3.1.0/psych-5.0.1/gem_make.out

The library can be configured without passing the --host option so one potential way forward is to not pass this option to configure when not cross-compiling.

From a brief skim of the psych issues, it seems that libyaml was unbundled from psych recently and now libyaml is an explicit dependency. On an operating system with a package manager, this is no problem because the library can be installed trivially.

On macOS, several people have reported installation woes and it seems that the suggestion is to install the library via HomeBrew and then install the gem with additional configuration options. I don't use HomeBrew so this doesn't work for me. As a result, --with-libyaml-source-dir seems like the right choice in this case.

The user experience of having to manually install gems with options is pretty miserable and it'd be great if psych could be installed without requiring this.