postmodern / ruby-install

Installs Ruby, JRuby, TruffleRuby, or mruby
MIT License
1.89k stars 250 forks source link

Install FreeBSD Ruby 3.2.2 #463

Open kaiquekandykoga opened 11 months ago

kaiquekandykoga commented 11 months ago

Description

I think it is related to https://github.com/rbenv/ruby-build/issues/2184.

Steps To Reproduce

$ ruby-install 3.2.2

Expected Behavior

Install 3.2.2.

Actual Behavior


*** Following extensions are not compiled:
fiddle:
        Could not be configured. It will not be installed.
        /usr/home/kandy/src/ruby-3.2.2/ext/fiddle/extconf.rb:73: missing libffi. Please install libffi or use --with-libffi-source-dir with libffi source location.
        Check ext/fiddle/mkmf.log for more details.
psych:
        Could not be configured. It will not be installed.
        Check ext/psych/mkmf.log for more details.
readline:
        Could not be configured. It will not be installed.
        /usr/home/kandy/src/ruby-3.2.2/ext/readline/extconf.rb:62: Neither readline nor libedit was found
        Check ext/readline/mkmf.log for more details.
*** Fix the problems, then remove these directories and try again if you want.

...

Ignoring debug-1.6.3 because its extensions are not built. Try: gem pristine debug --version 1.6.3
Ignoring rbs-2.7.0 because its extensions are not built. Try: gem pristine rbs --version 2.7.0
/usr/home/kandy/src/ruby-3.2.2/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
*** Error code 1

Stop.
make: stopped in /usr/home/kandy/src/ruby-3.2.2
!!! Compiling ruby 3.2.2 failed!

Environment

[kandy@freebsd ~]$ ruby-install --version
ruby-install: 0.9.0

[kandy@freebsd ~]$ uname -a
FreeBSD freebsd 13.1-RELEASE FreeBSD 13.1-RELEASE releng/13.1-n250148-fc952ac2212 GENERIC amd64

[kandy@freebsd ~]$ cc --version
FreeBSD clang version 13.0.0 (git@github.com:llvm/llvm-project.git llvmorg-13.0.0-0-gd7b669b3a303)
Target: x86_64-unknown-freebsd13.1
Thread model: posix
InstalledDir: /usr/bin

[kandy@freebsd ~]$ pkg info --prefix libyaml
libyaml-0.2.5                  /usr/local

[kandy@freebsd ~]$ pkg info --prefix libffi
libffi-3.4.4                   /usr/local

[kandy@freebsd ~]$ pkg info --prefix readline
readline-8.2.1                 /usr/local
postmodern commented 11 months ago

This is odd. libyaml and libffi are definitely dependencies for FreeBSD's pkg util and they appear to be installed. Ruby's ./configure should be able to find them in /usr/local.

nanaya commented 8 months ago

As mentioned in the linked issue, /usr/local isn't included in search path by default.

If one has pkgconf installed, some gems (including psych and fiddle) may still be successfully installed when the gem checks for additional flags through it using pkg_config method from mkmf. readline doesn't though so it must have the prefix explicitly specified.

That said, all this thing is generally a minefield so I just set these env when building ruby (not needed when building gems):

export cflags="-I/usr/local/include"
export LDFLAGS="-L/usr/local/lib"
# just setting the two above is probably enough
export cxxflags="${cflags}"
export cppflags="${cflags}"
export LIBS="-L/usr/local/lib"

With the env above any native extensions will have /usr/local included during build (including readline) without needing to specify the path manually.

(note that it should probably use $(sysctl -n user.localbase) instead of hardcoding /usr/local)

postmodern commented 8 months ago

@nanaya I think you should report this upstream to https://bugs.ruby-lang.org/ CRuby should be able to link against libraries in /usr/local which is a standard FHS directory. I want to avoid patching/working-around CRuby issues that could be fixed upstream.