-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trouble locating libncurses on MacOS with reline + jruby + fiddle FFI #766
Comments
Re RUBY_PLATFORM, it would be nice if JRuby would be compatible there, and be the native platform, i.e. like the Re not finding the library, I suspect that's because JRuby uses a rather old FFI which doesn't have this fix to search for Homebrew on darwin-arm64: ffi/ffi#968 |
JRuby has used "java" for RUBY_PLATFORM for almost twenty years and there are hundreds of gems out there that expect it to remain that way, as I described in jruby/jruby#6152. We originally were forced to use "java" here because RubyGems could not support JRuby-specific extension gems any other way. I'm not sure when RubyGems switched to
JRuby does not use a "rather old FFI". JRuby sources all FFI Ruby code from the gem, currently at version 1.16.3. That fix appears to have been released in 1.16.0. That should be updated to 1.17.0 but the fix you describe should already be shipping with JRuby. |
Same result with FFI 1.17.0:
|
Again, as I said in the original description, this might be a JRuby issue, but I am filing it here for other reasons:
Perhaps there's a way to make this dependency on libncurses lazy and only load and use it if necessary? It's a separate issue from the inability to load on MacOS (or specifically on my machine), but it is definitely a concern for e.g. minimized Docker containers that may not need libncurses otherwise. |
Another point: RubyGems decided it was better to use |
What's the path of your |
ncurses appears to install in
I am on macos-aarch64. The SEARCH_PATH does appear to be set up with /opt/homebrew/lib but I do not know why it doesn't show in the error message:
Neither does |
Mmh, so there is no |
There are two issues to address here:
|
I have not been able to find it in the usual places, but macOS sprinkles libraries all over the place. |
I have been unable to locate libncurses.dylib anywhere in the standard macOS dirs. This may be related (.tbd as a new dylib extension for "text-based stub libraries"): https://discourse.cmake.org/t/newer-versions-of-macos-require-linking-against-tbd-files-and-not-old-system-paths-to-dylib/6871/2 I do have some |
tbd files for libncurses on my machine. Note that without xcode these would not exist either. I can find no evidence that macOS provides libncurses in any reliable way (and there seems to be some debate about this elsewhere online too):
|
@headius If you look at https://github.com/ruby/reline/blob/master/lib/reline/terminfo.rb libcurses is clearly optional. |
Ah it's a bug of that code: @lib = FFI::DynamicLibrary.open(libname, flags) rescue LoadError is the same as @lib = begin
FFI::DynamicLibrary.open(libname, flags)
rescue
LoadError
end I'll fix it in ruby/fiddle: ruby/fiddle#156 |
Thank you for addressing the fiddle issue. In Reline, libncurses is optional, and in most case that environment variable TERM is set to |
* Fixes issue at build time where mkmf required fileutils but it was not installed yet (ruby/fiddle#153). * Fixes issue related to reline where missing native libraries did not raise error and fall back correctly (ruby/reline#766).
* Fixes issue at build time where mkmf required fileutils but it was not installed yet (ruby/fiddle#153). * Fixes issue related to reline where missing native libraries did not raise error and fall back correctly (ruby/reline#766). * Switches fiddle to a default gem.
Hello!
We recently started pulling the latest stdlib gems into JRuby for Ruby 3.4 support and ran into an issue with reline loading libncurses via fiddle:
Several locations are searched here but the file is not found. A few possible issues:
.dylib
name rather than.so
.RUBY_PLATFORM
isjava
and RbConfig should be used to get the real host platform.libncurses.dylib
installed via Homebrew.We are keen to figure this issue out so we can proceed with running the latest gems, stdlib, and tests in JRuby's 3.4-compatible branch.
Patch for reline to properly select a set of libncurses file names:
The text was updated successfully, but these errors were encountered: