ruby/psych

Can't install psych 5.0.1 in macOS on Apple Silicon

dentarg opened this issue · 19 comments

I have libyaml from Homebrew installed. It works when running Ruby with Rosetta 2 (arch -x86_64 /bin/zsh).

Issue seems to be checking for yaml_get_version() in -lyaml... no for arm64.

Details:

arm64: gem install --verbose psych
arm64 $ gem install --verbose psych
HEAD https://index.rubygems.org/
200 OK
GET https://index.rubygems.org/info/psych
200 OK
GET https://index.rubygems.org/quick/Marshal.4.8/psych-5.0.1.gemspec.rz
200 OK
GET https://index.rubygems.org/info/stringio
200 OK
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/.gitignore
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/Gemfile
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/LICENSE
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/Mavenfile
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/README.md
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/Rakefile
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/bin/console
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/bin/setup
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/ext/psych/depend
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/ext/psych/extconf.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/ext/psych/psych.c
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/ext/psych/psych.h
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/ext/psych/psych_emitter.c
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/ext/psych/psych_emitter.h
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/ext/psych/psych_parser.c
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/ext/psych/psych_parser.h
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/ext/psych/psych_to_ruby.c
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/ext/psych/psych_to_ruby.h
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/ext/psych/psych_yaml_tree.c
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/ext/psych/psych_yaml_tree.h
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/class_loader.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/coder.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/core_ext.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/exception.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/handler.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/handlers/document_stream.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/handlers/recorder.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/json/ruby_events.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/json/stream.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/json/tree_builder.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/json/yaml_events.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/nodes.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/nodes/alias.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/nodes/document.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/nodes/mapping.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/nodes/node.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/nodes/scalar.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/nodes/sequence.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/nodes/stream.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/omap.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/parser.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/scalar_scanner.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/set.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/stream.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/streaming.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/syntax_error.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/tree_builder.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/versions.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/visitors.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/visitors/depth_first.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/visitors/emitter.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/visitors/json_tree.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/visitors/to_ruby.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/visitors/visitor.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/visitors/yaml_tree.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/y.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/psych.gemspec
Building native extensions. This could take a while...
current directory: /Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/ext/psych
["/Users/dentarg/.arm64_rubies/3.1.2/bin/ruby", "-I", "/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/site_ruby/3.1.0", "extconf.rb"]
checking for yaml.h... yes
checking for yaml_get_version() in -lyaml... no
libyaml 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/dentarg/.arm64_rubies/3.1.2/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
  --with-yaml-dir
  --without-yaml-dir
  --with-yaml-include
  --without-yaml-include=${yaml-dir}/include
  --with-yaml-lib
  --without-yaml-lib=${yaml-dir}/lib
  --with-yamllib
  --without-yamllib
ERROR:  Error installing psych:
  ERROR: Failed to build gem native extension.

    current directory: /Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/ext/psych
/Users/dentarg/.arm64_rubies/3.1.2/bin/ruby -I /Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/site_ruby/3.1.0 extconf.rb
Building has failed. See above output for more information on the failure.
To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Users/dentarg/.arm64_rubies/3.1.2/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/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1 for inspection.
Results logged to /Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/extensions/arm64-darwin-21/3.1.0/psych-5.0.1/gem_make.out
cat mkmf.log
arm64 $ cat /Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/extensions/arm64-darwin-21/3.1.0/psych-5.0.1/mkmf.log
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/dentarg/.arm64_rubies/3.1.2/lib pkg-config --exists yaml-0.1
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/dentarg/.arm64_rubies/3.1.2/lib pkg-config --libs yaml-0.1 |
=> "-L/opt/homebrew/Cellar/libyaml/0.2.5/lib -lyaml\n"
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/dentarg/.arm64_rubies/3.1.2/lib "clang -o conftest -I/Users/dentarg/.arm64_rubies/3.1.2/include/ruby-3.1.0/arm64-darwin21 -I/Users/dentarg/.arm64_rubies/3.1.2/include/ruby-3.1.0/ruby/backward -I/Users/dentarg/.arm64_rubies/3.1.2/include/ruby-3.1.0 -I. -I/Users/dentarg/.arm64_rubies/3.1.2/include  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -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 -Wundef  -fno-common -pipe conftest.c  -L. -L/Users/dentarg/.arm64_rubies/3.1.2/lib -L. -L/Users/dentarg/.arm64_rubies/3.1.2/lib  -fstack-protector-strong -L/usr/local/lib     -lruby.3.1   "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5:   return !!argv[argc];
6: }
/* end */

DYLD_FALLBACK_LIBRARY_PATH=.:/Users/dentarg/.arm64_rubies/3.1.2/lib "clang -o conftest -I/Users/dentarg/.arm64_rubies/3.1.2/include/ruby-3.1.0/arm64-darwin21 -I/Users/dentarg/.arm64_rubies/3.1.2/include/ruby-3.1.0/ruby/backward -I/Users/dentarg/.arm64_rubies/3.1.2/include/ruby-3.1.0 -I. -I/Users/dentarg/.arm64_rubies/3.1.2/include  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -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 -Wundef  -fno-common -pipe conftest.c  -L. -L/Users/dentarg/.arm64_rubies/3.1.2/lib -L. -L/Users/dentarg/.arm64_rubies/3.1.2/lib  -fstack-protector-strong -L/usr/local/lib     -lruby.3.1 -L/opt/homebrew/Cellar/libyaml/0.2.5/lib -lyaml  "
ld: warning: ignoring file /usr/local/lib/libyaml.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5:   return !!argv[argc];
6: }
/* end */

DYLD_FALLBACK_LIBRARY_PATH=.:/Users/dentarg/.arm64_rubies/3.1.2/lib pkg-config --cflags-only-I yaml-0.1 |
=> "-I/opt/homebrew/Cellar/libyaml/0.2.5/include\n"
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/dentarg/.arm64_rubies/3.1.2/lib pkg-config --cflags-only-other yaml-0.1 |
=> "\n"
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/dentarg/.arm64_rubies/3.1.2/lib pkg-config --libs-only-l yaml-0.1 |
=> "-lyaml\n"
package configuration for yaml-0.1
incflags: -I/opt/homebrew/Cellar/libyaml/0.2.5/include
cflags:
ldflags: -L/opt/homebrew/Cellar/libyaml/0.2.5/lib
libs: -lyaml

find_header: checking for yaml.h... -------------------- yes

DYLD_FALLBACK_LIBRARY_PATH=.:/Users/dentarg/.arm64_rubies/3.1.2/lib "clang -I/Users/dentarg/.arm64_rubies/3.1.2/include/ruby-3.1.0/arm64-darwin21 -I/Users/dentarg/.arm64_rubies/3.1.2/include/ruby-3.1.0/ruby/backward -I/Users/dentarg/.arm64_rubies/3.1.2/include/ruby-3.1.0 -I. -I/opt/homebrew/Cellar/libyaml/0.2.5/include -I/Users/dentarg/.arm64_rubies/3.1.2/include  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -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 -Wundef  -fno-common -pipe    -c conftest.c"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <yaml.h>
/* end */

--------------------

find_library: checking for yaml_get_version() in -lyaml... -------------------- no

DYLD_FALLBACK_LIBRARY_PATH=.:/Users/dentarg/.arm64_rubies/3.1.2/lib "clang -o conftest -I/Users/dentarg/.arm64_rubies/3.1.2/include/ruby-3.1.0/arm64-darwin21 -I/Users/dentarg/.arm64_rubies/3.1.2/include/ruby-3.1.0/ruby/backward -I/Users/dentarg/.arm64_rubies/3.1.2/include/ruby-3.1.0 -I. -I/opt/homebrew/Cellar/libyaml/0.2.5/include -I/Users/dentarg/.arm64_rubies/3.1.2/include  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -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 -Wundef  -fno-common -pipe  conftest.c  -L. -L/Users/dentarg/.arm64_rubies/3.1.2/lib -L. -L/Users/dentarg/.arm64_rubies/3.1.2/lib  -fstack-protector-strong -L/usr/local/lib -L/opt/homebrew/Cellar/libyaml/0.2.5/lib     -lyaml -lruby.3.1 -lyaml  -lyaml  "
conftest.c:14:57: error: use of undeclared identifier 'yaml_get_version'
int t(void) { void ((*volatile p)()); p = (void ((*)()))yaml_get_version; return !p; }
                                                        ^
1 error generated.
checked program was:
/* begin */
 1: #include "ruby.h"
 2:
 3: /*top*/
 4: extern int t(void);
 5: int main(int argc, char **argv)
 6: {
 7:   if (argc > 1000000) {
 8:     int (* volatile tp)(void)=(int (*)(void))&t;
 9:     printf("%d", (*tp)());
10:   }
11:
12:   return !!argv[argc];
13: }
14: int t(void) { void ((*volatile p)()); p = (void ((*)()))yaml_get_version; return !p; }
/* end */

DYLD_FALLBACK_LIBRARY_PATH=.:/Users/dentarg/.arm64_rubies/3.1.2/lib "clang -o conftest -I/Users/dentarg/.arm64_rubies/3.1.2/include/ruby-3.1.0/arm64-darwin21 -I/Users/dentarg/.arm64_rubies/3.1.2/include/ruby-3.1.0/ruby/backward -I/Users/dentarg/.arm64_rubies/3.1.2/include/ruby-3.1.0 -I. -I/opt/homebrew/Cellar/libyaml/0.2.5/include -I/Users/dentarg/.arm64_rubies/3.1.2/include  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -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 -Wundef  -fno-common -pipe  conftest.c  -L. -L/Users/dentarg/.arm64_rubies/3.1.2/lib -L. -L/Users/dentarg/.arm64_rubies/3.1.2/lib  -fstack-protector-strong -L/usr/local/lib -L/opt/homebrew/Cellar/libyaml/0.2.5/lib     -lyaml -lruby.3.1 -lyaml  -lyaml  "
ld: warning: ignoring file /usr/local/lib/libyaml.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
Undefined symbols for architecture arm64:
  "_yaml_get_version", referenced from:
      _t in conftest-fa07a3.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
checked program was:
/* begin */
 1: #include "ruby.h"
 2:
 3: /*top*/
 4: extern int t(void);
 5: int main(int argc, char **argv)
 6: {
 7:   if (argc > 1000000) {
 8:     int (* volatile tp)(void)=(int (*)(void))&t;
 9:     printf("%d", (*tp)());
10:   }
11:
12:   return !!argv[argc];
13: }
14: extern void yaml_get_version();
15: int t(void) { yaml_get_version(); return 0; }
/* end */

--------------------

arm64 $ uname -m -r -s ; brew info libyaml
Darwin 21.6.0 arm64
==> libyaml: stable 0.2.5 (bottled)
YAML Parser
https://github.com/yaml/libyaml
/opt/homebrew/Cellar/libyaml/0.2.5 (10 files, 353KB) *
  Poured from bottle on 2022-09-12 at 13:06:35
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/libyaml.rb
License: MIT
==> Dependencies
Build: autoconf ✔, automake ✘, libtool ✔
x86_64: gem install --verbose psych
intel $ gem install --verbose psych
HEAD https://index.rubygems.org/
200 OK
GET https://index.rubygems.org/info/psych
200 OK
GET https://index.rubygems.org/info/stringio
200 OK
Downloading gem psych-5.0.1.gem
GET https://index.rubygems.org/gems/psych-5.0.1.gem
Fetching psych-5.0.1.gem
200 OK
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/.gitignore
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/Gemfile
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/LICENSE
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/Mavenfile
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/README.md
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/Rakefile
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/bin/console
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/bin/setup
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/ext/psych/depend
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/ext/psych/extconf.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/ext/psych/psych.c
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/ext/psych/psych.h
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/ext/psych/psych_emitter.c
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/ext/psych/psych_emitter.h
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/ext/psych/psych_parser.c
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/ext/psych/psych_parser.h
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/ext/psych/psych_to_ruby.c
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/ext/psych/psych_to_ruby.h
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/ext/psych/psych_yaml_tree.c
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/ext/psych/psych_yaml_tree.h
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/class_loader.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/coder.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/core_ext.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/exception.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/handler.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/handlers/document_stream.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/handlers/recorder.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/json/ruby_events.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/json/stream.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/json/tree_builder.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/json/yaml_events.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/nodes.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/nodes/alias.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/nodes/document.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/nodes/mapping.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/nodes/node.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/nodes/scalar.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/nodes/sequence.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/nodes/stream.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/omap.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/parser.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/scalar_scanner.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/set.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/stream.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/streaming.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/syntax_error.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/tree_builder.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/versions.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/visitors.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/visitors/depth_first.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/visitors/emitter.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/visitors/json_tree.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/visitors/to_ruby.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/visitors/visitor.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/visitors/yaml_tree.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/lib/psych/y.rb
/Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/psych.gemspec
Building native extensions. This could take a while...
current directory: /Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/ext/psych
["/Users/dentarg/.rubies/3.1.2/bin/ruby", "-I", "/Users/dentarg/.rubies/3.1.2/lib/ruby/3.1.0", "-r", "./siteconf20221213-26874-7qq7kx.rb", "extconf.rb"]
checking for yaml.h... yes
checking for yaml_get_version() in -lyaml... yes
creating Makefile
current directory: /Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/ext/psych
["make", "DESTDIR=", "clean"]
cd libyaml && /Library/Developer/CommandLineTools/usr/bin/make clean
/bin/sh: line 0: cd: libyaml: No such file or directory
make: [clean-so] Error 1 (ignored)
current directory: /Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/ext/psych
["make", "DESTDIR="]
compiling psych.c
compiling psych_emitter.c
compiling psych_parser.c
compiling psych_to_ruby.c
compiling psych_yaml_tree.c
linking shared-object psych.bundle
ld: warning: -undefined dynamic_lookup may not work with chained fixups
current directory: /Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/ext/psych
["make", "DESTDIR=", "install"]
/usr/bin/install -c -m 0755 psych.bundle ./.gem.20221213-26874-ayv8x1
current directory: /Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/ext/psych
/Users/dentarg/.rubies/3.1.2/bin/ruby -I /Users/dentarg/.rubies/3.1.2/lib/ruby/3.1.0 -r ./siteconf20221213-26874-7qq7kx.rb extconf.rb
current directory: /Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/ext/psych
make DESTDIR\= clean
current directory: /Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/ext/psych
make DESTDIR\=
current directory: /Users/dentarg/.rubies/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.0.1/ext/psych
make DESTDIR\= install
Successfully installed psych-5.0.1
1 gem installed
intel $ uname -m -r -s ; brew info libyaml
Darwin 21.6.0 x86_64
==> libyaml: stable 0.2.5 (bottled)
YAML Parser
https://github.com/yaml/libyaml
/usr/local/Cellar/libyaml/0.2.5 (10 files, 331.3KB) *
  Poured from bottle on 2022-09-12 at 13:06:06
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/libyaml.rb
License: MIT
==> Dependencies
Build: autoconf ✔, automake ✘, libtool ✘
hsbt commented

I could install psych on Apple Silicon.

$ ruby -v
ruby 3.2.0dev (2022-12-12T21:05:03Z master f88f2bd92f) +YJIT [arm64-darwin22]
$ gem i psych -v 5.0.1
Fetching psych-5.0.1.gem
Building native extensions. This could take a while...
Successfully installed psych-5.0.1
1 gem installed

Yes, 3.2.0-preview3 works for me too with arm64. Should it not work on Ruby 3.1.2?

3.2.0-preview3: gem install --verbose psych
arm64 $ gem install --verbose psych
HEAD https://index.rubygems.org/
200 OK
GET https://index.rubygems.org/info/psych
200 OK
GET https://index.rubygems.org/info/stringio
200 OK
Downloading gem psych-5.0.1.gem
GET https://index.rubygems.org/gems/psych-5.0.1.gem
Fetching psych-5.0.1.gem
200 OK
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/.gitignore
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/Gemfile
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/LICENSE
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/Mavenfile
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/README.md
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/Rakefile
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/bin/console
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/bin/setup
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/ext/psych/depend
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/ext/psych/extconf.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/ext/psych/psych.c
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/ext/psych/psych.h
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/ext/psych/psych_emitter.c
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/ext/psych/psych_emitter.h
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/ext/psych/psych_parser.c
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/ext/psych/psych_parser.h
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/ext/psych/psych_to_ruby.c
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/ext/psych/psych_to_ruby.h
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/ext/psych/psych_yaml_tree.c
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/ext/psych/psych_yaml_tree.h
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/lib/psych.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/lib/psych/class_loader.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/lib/psych/coder.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/lib/psych/core_ext.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/lib/psych/exception.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/lib/psych/handler.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/lib/psych/handlers/document_stream.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/lib/psych/handlers/recorder.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/lib/psych/json/ruby_events.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/lib/psych/json/stream.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/lib/psych/json/tree_builder.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/lib/psych/json/yaml_events.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/lib/psych/nodes.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/lib/psych/nodes/alias.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/lib/psych/nodes/document.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/lib/psych/nodes/mapping.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/lib/psych/nodes/node.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/lib/psych/nodes/scalar.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/lib/psych/nodes/sequence.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/lib/psych/nodes/stream.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/lib/psych/omap.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/lib/psych/parser.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/lib/psych/scalar_scanner.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/lib/psych/set.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/lib/psych/stream.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/lib/psych/streaming.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/lib/psych/syntax_error.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/lib/psych/tree_builder.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/lib/psych/versions.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/lib/psych/visitors.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/lib/psych/visitors/depth_first.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/lib/psych/visitors/emitter.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/lib/psych/visitors/json_tree.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/lib/psych/visitors/to_ruby.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/lib/psych/visitors/visitor.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/lib/psych/visitors/yaml_tree.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/lib/psych/y.rb
/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/psych.gemspec
Building native extensions. This could take a while...
current directory: /Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/ext/psych
["/Users/dentarg/.arm64_rubies/3.2.0-preview3/bin/ruby", "-I", "/Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/3.2.0+3", "extconf.rb"]
checking for yaml.h... yes
checking for yaml_get_version() in -lyaml... yes
creating Makefile
current directory: /Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/ext/psych
["make", "DESTDIR=", "sitearchdir=./.gem.20221213-32811-q9ak6y", "sitelibdir=./.gem.20221213-32811-q9ak6y", "clean"]
cd libyaml && /Library/Developer/CommandLineTools/usr/bin/make clean
/bin/sh: line 0: cd: libyaml: No such file or directory
make: [clean-so] Error 1 (ignored)
current directory: /Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/ext/psych
["make", "DESTDIR=", "sitearchdir=./.gem.20221213-32811-q9ak6y", "sitelibdir=./.gem.20221213-32811-q9ak6y"]
compiling psych.c
compiling psych_emitter.c
compiling psych_parser.c
compiling psych_to_ruby.c
compiling psych_yaml_tree.c
linking shared-object psych.bundle
current directory: /Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/ext/psych
["make", "DESTDIR=", "sitearchdir=./.gem.20221213-32811-q9ak6y", "sitelibdir=./.gem.20221213-32811-q9ak6y", "install"]
/usr/bin/install -c -m 0755 psych.bundle ./.gem.20221213-32811-q9ak6y
current directory: /Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/ext/psych
/Users/dentarg/.arm64_rubies/3.2.0-preview3/bin/ruby -I /Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/3.2.0+3 extconf.rb
current directory: /Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/ext/psych
make DESTDIR\= sitearchdir\=./.gem.20221213-32811-q9ak6y sitelibdir\=./.gem.20221213-32811-q9ak6y clean
current directory: /Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/ext/psych
make DESTDIR\= sitearchdir\=./.gem.20221213-32811-q9ak6y sitelibdir\=./.gem.20221213-32811-q9ak6y
current directory: /Users/dentarg/.arm64_rubies/3.2.0-preview3/lib/ruby/gems/3.2.0+3/gems/psych-5.0.1/ext/psych
make DESTDIR\= sitearchdir\=./.gem.20221213-32811-q9ak6y sitelibdir\=./.gem.20221213-32811-q9ak6y install
Successfully installed psych-5.0.1
1 gem installed
hsbt commented

I recommend to use Ruby 3.1.3 because 3.1.2 is not working correctly with Ventura/Xcode14 and Apple Silicon.

The failure is the same with Ruby 3.1.3 and Apple Silicon (+ I'm not using Ventura; this is macOS 12.6.1)

arm64 $ ruby -v
ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e) [arm64-darwin21]
Building native extensions. This could take a while...
current directory: /Users/dentarg/.arm64_rubies/3.1.3/lib/ruby/gems/3.1.0/gems/psych-5.0.1/ext/psych
["/Users/dentarg/.arm64_rubies/3.1.3/bin/ruby", "-I", "/Users/dentarg/.arm64_rubies/3.1.3/lib/ruby/3.1.0", "extconf.rb"]
checking for yaml.h... yes
checking for yaml_get_version() in -lyaml... no
libyaml 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.
find_library: checking for yaml_get_version() in -lyaml... -------------------- no

DYLD_FALLBACK_LIBRARY_PATH=.:/Users/dentarg/.arm64_rubies/3.1.3/lib "clang -o conftest -I/Users/dentarg/.arm64_rubies/3.1.3/include/ruby-3.1.0/arm64-darwin21 -I/Users/dentarg/.arm64_rubies/3.1.3/include/ruby-3.1.0/ruby/backward -I/Users/dentarg/.arm64_rubies/3.1.3/include/ruby-3.1.0 -I. -I/opt/homebrew/Cellar/libyaml/0.2.5/include -I/Users/dentarg/.arm64_rubies/3.1.3/include  -I/opt/homebrew/opt/gmp/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -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 -Wundef  -fno-common -pipe  conftest.c  -L. -L/Users/dentarg/.arm64_rubies/3.1.3/lib -L. -L/Users/dentarg/.arm64_rubies/3.1.3/lib  -fstack-protector-strong -L/opt/homebrew/opt/gmp/lib -L/usr/local/lib -L/opt/homebrew/Cellar/libyaml/0.2.5/lib     -lyaml -lruby.3.1 -lyaml  -lyaml  "
conftest.c:14:57: error: use of undeclared identifier 'yaml_get_version'
int t(void) { void ((*volatile p)()); p = (void ((*)()))yaml_get_version; return !p; }
                                                        ^
1 error generated.
checked program was:
/* begin */
 1: #include "ruby.h"
 2:
 3: /*top*/
 4: extern int t(void);
 5: int main(int argc, char **argv)
 6: {
 7:   if (argc > 1000000) {
 8:     int (* volatile tp)(void)=(int (*)(void))&t;
 9:     printf("%d", (*tp)());
10:   }
11:
12:   return !!argv[argc];
13: }
14: int t(void) { void ((*volatile p)()); p = (void ((*)()))yaml_get_version; return !p; }
/* end */
hsbt commented

There is no idea to resolve it. Maybe it related with --with-yaml-dir or other options.

It seems your environmental issue.

Literally just ran into this same issue on Ventura, M1. With ruby 3.0.5p211, and ruby 3.1.3p185

libyaml appears to be available...

❯ brew info libyaml
==> libyaml: stable 0.2.5 (bottled)
YAML Parser
https://github.com/yaml/libyaml
/opt/homebrew/Cellar/libyaml/0.2.5 (10 files, 351.3KB) *
  Poured from bottle on 2022-12-12 at 17:01:52
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/libyaml.rb
License: MIT

And I can install version ~4 of psych.

❯ gem install psych --version=4.0.6
Fetching psych-4.0.6.gem
Building native extensions. This could take a while...
Successfully installed psych-4.0.6
Parsing documentation for psych-4.0.6
Installing ri documentation for psych-4.0.6
Done installing documentation for psych after 0 seconds
1 gem installed

But psych version ~5 isn't installable.

❯ gem install psych --version=5.0.0
Fetching psych-5.0.0.gem
Building native extensions. This could take a while...
ERROR:  Error installing psych:
	ERROR: Failed to build gem native extension.

And in the mkmf.log:

conftest.c:3:10: fatal error: 'yaml.h' file not found
#include <yaml.h>
         ^~~~~~~~
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <yaml.h>
/* end */

Interestingly, I see a similar issue when trying to install ruby 3.2.0.rc1, where I was going to check as well:

Installing ruby-3.2.0-rc1...

BUILD FAILED (macOS 13.0.1 using ruby-build 20221206)

Inspect or clean up the working tree at /var/folders/2b/35p9phl91mj6b6c101_gp0cr0000gn/T/ruby-build.20221212174353.71759.2JUfpa
Results logged to /var/folders/2b/35p9phl91mj6b6c101_gp0cr0000gn/T/ruby-build.20221212174353.71759.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/2b/35p9phl91mj6b6c101_gp0cr0000gn/T/ruby-build.20221212174353.71759.2JUfpa/ruby-3.2.0-rc1/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

EDIT: Maybe I'm not seeing the same thing. It looks like for me libyaml yaml.h is just not being found, and I've tried providing it in a couple different ways when trying to build the native extension.

@hsbt It works if I do brew uninstall libyaml for x86_64

I noticed this line from mkmf.log posted above: ld: warning: ignoring file /usr/local/lib/libyaml.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64

I think this should just work as it does work using 3.2.0-preview3 when libyaml is installed for both arm64 and x86_64

Is there some recent change to mkmf.rb that should be backported?

I was facing the same issue ->

91mGem::Ext::BuildError: ERROR: Failed to build gem native extension.
    current directory:
/fluentd/localgems/ruby/2.7.0/gems/psych-5.0.0/ext/psych
/opt/rh/rh-ruby27/root/usr/bin/ruby -I
/opt/rh/rh-ruby27/root/usr/share/rubygems
extconf.rb
checking for yaml.h... no
yaml.h not found
*** extconf.rb failed ***

An error occurred while installing psych (5.0.0), and Bundler cannot
continue.
Make sure that `gem install psych -v '5.0.0' --source 
before bundling
In Gemfile:
  rdoc was resolved to 6.4.0, which depends on
    psych

I believe after psych added a runtime dependency on stringio from ver 5.0.0 starting December 5th 2022 , we are facing the issue. If I rollback to psych 4.0.6 , it's working fine for me.

hsbt commented

@Sairav No, It's different issue. You should install libyaml-dev for resolving it.

hsbt commented

@dentarg I don't know what changes of mkmf related your issue.

Thanks @hsbt , my issue was resolved by installing libyaml-devel , working with latest ver psych 5.0.1 .

If it helps anyone , I was running Oracle Linux 7 Slim , command used -

  • yum --enablerepo=ol7_optional_latest install libyaml-devel

I've run into this same issue. Apple Silicon with fresh install MacOS Ventura, with latest Ruby & XCode

$ ruby -v
ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e) [arm64-darwin22]

$ brew install libyaml
Warning: libyaml 0.2.5 is already installed and up-to-date.

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

    current directory: /Users/colby/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/gems/psych-5.0.1/ext/psych
/Users/colby/.asdf/installs/ruby/3.1.3/bin/ruby -I /Users/colby/.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/colby/.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/colby/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/extensions/arm64-darwin-22/3.1.0/psych-5.0.1/mkmf.log

extconf failed, exit code 1

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

@colby-swandale Can you try with gem i paych -- --with-yaml-dir=$(brew --prefix libyaml)?

Don't have an M1/silicon but getting the same thing on my MBP

iiiw commented

brew reinstall libyaml worked for me (M2, MacOS Ventura, ruby 3.1.3p185)

brew reinstall libyaml worked for me (M2, MacOS Ventura, ruby 3.1.3p185)

This worked! Thanks!

Hi ~ Happy New Year
I facing the same issue as @jejacks0n, when I use asdf to install ruby 3.2.0.
I facing the same issue as @colby-swandale , when I gem install psych .
screenshoot

ruby -v
ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e) [arm64-darwin22]

brew install libyaml
libyaml 0.2.5 is already installed and up-to-date

PS: MacOS Ventura 13.1 M1 Pro

@colby-swandale Can you try with gem i paych -- --with-yaml-dir=$(brew --prefix libyaml)?

This works for me gem install paych -- --with-libyaml-dir=$(brew --prefix libyaml)?

But I'm running into this problem when I try to install ruby 3.2 also and breaks the entire installation 😕

$ asdf install ruby 3.2.0
To follow progress, use 'tail -f /var/folders/1b/092w4rr513v_1w3wl2fc69_c0000gn/T/ruby-build.20230105003024.47583.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/colby/.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

BUILD FAILED (macOS 13.1 using ruby-build 20221225)

Inspect or clean up the working tree at /var/folders/1b/092w4rr513v_1w3wl2fc69_c0000gn/T/ruby-build.20230105003024.47583.94w06Z
Results logged to /var/folders/1b/092w4rr513v_1w3wl2fc69_c0000gn/T/ruby-build.20230105003024.47583.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/1b/092w4rr513v_1w3wl2fc69_c0000gn/T/ruby-build.20230105003024.47583.94w06Z/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


$ brew info libyaml
==> libyaml: stable 0.2.5 (bottled)
YAML Parser
https://github.com/yaml/libyaml
/opt/homebrew/Cellar/libyaml/0.2.5 (10 files, 351.3KB) *
  Poured from bottle on 2023-01-05 at 00:17:23
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/libyaml.rb
License: MIT
==> Dependencies
Build: autoconf ✘, automake ✘, libtool ✘
==> Analytics
install: 85,632 (30 days), 289,998 (90 days), 1,096,000 (365 days)
install-on-request: 16,644 (30 days), 52,109 (90 days), 201,315 (365 days)
build-error: 4 (30 days)

To fix this; I reinstalled/rebuilt ruby with the following configuration:

RUBY_CONFIGURE_OPTS="--with-libyaml-dir=$(brew --prefix libyaml)"

This worked for Ruby 3.1.2 and libyaml 0.2.5 (installed via homebrew)