ruby-install icon indicating copy to clipboard operation
ruby-install copied to clipboard

Install FreeBSD Ruby 3.2.2

Open kaiquekandykoga opened this issue 2 years ago • 3 comments

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 ([email protected]: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

kaiquekandykoga avatar Sep 02 '23 01:09 kaiquekandykoga

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.

postmodern avatar Sep 02 '23 20:09 postmodern

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)

nanaya avatar Dec 09 '23 23:12 nanaya

@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.

postmodern avatar Dec 10 '23 00:12 postmodern