Opened 8 months ago
Last modified 7 months ago
#69604 assigned defect
ruby-build fails with fatal error: 'yaml.h' file not found
Reported by: | breun (Nils Breunese) | Owned by: | mojca (Mojca Miklavec) |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | |
Keywords: | Cc: | ||
Port: | ruby-build |
Description
I have installed the rbenv
and ruby-build
ports, and then tried to install Ruby 3.3.0, but this fails:
❯ rbenv install 3.3.0 ==> Downloading openssl-3.1.4.tar.gz... -> curl -q -fL -o openssl-3.1.4.tar.gz https://dqw8nmjcqpjn7.cloudfront.net/840af5366ab9b522bde525826be3ef0fb0af81c6a9ebd84caa600fea1731eee3 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 14.8M 100 14.8M 0 0 31.7M 0 --:--:-- --:--:-- --:--:-- 31.7M ==> Installing openssl-3.1.4... -> ./config "--prefix=$HOME/.rbenv/versions/3.3.0/openssl" "--openssldir=$HOME/.rbenv/versions/3.3.0/openssl/ssl" zlib-dynamic no-ssl3 shared -> make -j 10 -> make install_sw install_ssldirs ==> Installed openssl-3.1.4 to /Users/breun/.rbenv/versions/3.3.0 ==> Downloading ruby-3.3.0.tar.gz... -> curl -q -fL -o ruby-3.3.0.tar.gz https://cache.ruby-lang.org/pub/ruby/3.3/ruby-3.3.0.tar.gz % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 21.0M 100 21.0M 0 0 40.3M 0 --:--:-- --:--:-- --:--:-- 40.3M ==> Installing ruby-3.3.0... -> ./configure "--prefix=$HOME/.rbenv/versions/3.3.0" "--with-openssl-dir=$HOME/.rbenv/versions/3.3.0/openssl" --enable-shared --with-ext=openssl,psych,+ -> make -j 10 *** Following extensions are not compiled: psych: Could not be configured. It will not be installed. Check /var/folders/m7/7n1s8z9r8vlfjs008k8z7sr80000gn/T/ruby-build.20240327173636.655.zYSH3n/ruby-3.3.0/ext/psych/mkmf.log for more details. BUILD FAILED (macOS 14.4.1 on arm64 using ruby-build 20240318) You can inspect the build directory at /var/folders/m7/7n1s8z9r8vlfjs008k8z7sr80000gn/T/ruby-build.20240327173636.655.zYSH3n See the full build log at /var/folders/m7/7n1s8z9r8vlfjs008k8z7sr80000gn/T/ruby-build.20240327173636.655.log
The log file contains:
package configuration for yaml-0.1 is not found find_header: checking for yaml.h... -------------------- no DYLD_FALLBACK_LIBRARY_PATH=.:../.. "clang -o conftest -I../../.ext/include/arm64-darwin23 -I../.././include -I../.././ext/psych -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wextra-tokens -Wdeprecated-declarations -Wdivision-by-zero -Wdiv-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 -Wundef -fno-common -pipe conftest.c -L. -L../.. -L. -fstack-protector-strong -lruby.3.2-static -framework CoreFoundation -ldl -lobjc -lpthread -lpthread " ld: warning: ignoring duplicate libraries: '-lpthread' 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=.:../.. "clang -I../../.ext/include/arm64-darwin23 -I../.././include -I../.././ext/psych -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wextra-tokens -Wdeprecated-declarations -Wdivision-by-zero -Wdiv-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 -Wundef -fno-common -pipe -c conftest.c" 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 */ --------------------
I get a similar error when trying to install Ruby 3.2.3 this way.
I see that the libyaml
port includes /opt/local/include/yaml.h
, but I'm not sure if that is the right file, and if so, how to make this process use it.
Is this a bug, or am I doing something wrong?
Change History (7)
comment:1 Changed 8 months ago by breun (Nils Breunese)
comment:2 Changed 8 months ago by ryandesign (Ryan Carsten Schmidt)
As with any scenario when you are building something outside of MacPorts but want to use libraries installed by MacPorts, you would need to add -I/opt/local/include
in CPPFLAGS and -L/opt/local/lib
in LDFLAGS. How to achieve that with rbenv I don't know.
comment:3 Changed 8 months ago by ryandesign (Ryan Carsten Schmidt)
It looks like rbenv is installing its own private copy of openssl first. If rbenv's intention is to be self-contained, then I guess it should either be installing its own private copy of libyaml or else telling ruby not to use libyaml, if that's possible. These would be bugs to report to the developers of rbenv. Or if they are not intending to be self-contained, then hopefully they have documentation explaining how to inform rbenv about the location of your copy of libyaml and anything else that's needed.
comment:4 follow-up: 6 Changed 8 months ago by breun (Nils Breunese)
It looks like ruby-build
added auto-detection support for Homebrew's libyaml
last year: https://github.com/rbenv/ruby-build/releases/tag/v20230306 Maybe ruby-build
also needs a MacPorts version of this feature?
comment:5 Changed 8 months ago by breun (Nils Breunese)
Via https://github.com/rbenv/ruby-build/pull/1929#issuecomment-1245427464 I found that RUBY_CONFIGURE_OPTS=--with-libyaml-dir=/opt/local rbenv install 3.3.0
works.
Maybe libyaml
needs to be added as a dependency to the ruby-build
port, and maybe it can set the libyaml directory automatically?
comment:6 Changed 7 months ago by ryandesign (Ryan Carsten Schmidt)
Replying to breun:
Maybe
ruby-build
also needs a MacPorts version of this feature?
I would not consider that to be desirable. Instead of projects making assumptions about what different package managers the user might be using, there should be a simple straightforward method of detecting dependencies, like pkg-config, or a way that the user (or package manager) can specify where the dependency they want to use is located.
comment:7 Changed 7 months ago by breun (Nils Breunese)
Sure, letting the ruby-build
port take care of this does seem nicer than bothering upstream with knowledge about MacPorts. It looks like the most recent versions of Ruby require libyaml
to build. It would be great if the ruby-build
port would take care of installing libyaml
and setting --with-libyaml-dir=${prefix}
by default. Then rbenv install (…)
commands should work out if the box.
rbenv install 3.1.4
does complete without errors.