Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.5.1
-
Fix Version/s: JRuby 1.6RC1
-
Component/s: None
-
Labels:None
-
Environment:OS: OSX 10.5.8
Jruby Version: 1.5.1
FFI gem version: 0.6.3
-
Number of attachments :
Description
Attempting to require 'pty' fails, with a "LoadError: no library specified" when using jruby 1.5.1 ('ffi' gem 0.6.3).
irb(main):001:0> require "rubygems" => true irb(main):002:0> require "ffi" => true irb(main):003:0> require "pty" LoadError: no library specified from /jruby/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/library.rb:46:in `ffi_libraries' from /jruby/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/library.rb:96:in `attach_function' from /jruby/jruby-1.5.1/lib/ruby/site_ruby/shared/pty.rb:11 from /jruby/jruby-1.5.1/lib/ruby/site_ruby/shared/pty.rb:31:in `require' from /jruby/jruby-1.5.1/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from (irb):3
Activity
Hiro Asari
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Description |
Attempting to require 'pty' fails, with a "LoadError: no library specified" when using jruby 1.5.1 ('ffi' gem 0.6.3).
Example: irb(main):001:0> require "rubygems" => true irb(main):002:0> require "ffi" => true irb(main):003:0> require "pty" LoadError: no library specified from /jruby/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/library.rb:46:in `ffi_libraries' from /jruby/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/library.rb:96:in `attach_function' from /jruby/jruby-1.5.1/lib/ruby/site_ruby/shared/pty.rb:11 from /jruby/jruby-1.5.1/lib/ruby/site_ruby/shared/pty.rb:31:in `require' from /jruby/jruby-1.5.1/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from (irb):3 |
Attempting to require 'pty' fails, with a "LoadError: no library specified" when using jruby 1.5.1 ('ffi' gem 0.6.3).
{noformat} irb(main):001:0> require "rubygems" => true irb(main):002:0> require "ffi" => true irb(main):003:0> require "pty" LoadError: no library specified from /jruby/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/library.rb:46:in `ffi_libraries' from /jruby/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/library.rb:96:in `attach_function' from /jruby/jruby-1.5.1/lib/ruby/site_ruby/shared/pty.rb:11 from /jruby/jruby-1.5.1/lib/ruby/site_ruby/shared/pty.rb:31:in `require' from /jruby/jruby-1.5.1/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from (irb):3 {noformat} |
Hiro Asari
made changes -
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Assignee | Thomas E Enebo [ enebo ] | Hiro Asari [ asari ] |
| Fix Version/s | JRuby 1.6 [ 16275 ] | |
| Resolution | Fixed [ 1 ] |
Michael Kohl
made changes -
| Attachment | properly_scoped_memory_pointer.patch [ 51174 ] |
Michael Kohl
made changes -
| Attachment | properly_scoped_memory_pointer.patch [ 51175 ] |
Michael Kohl
made changes -
| Attachment | properly_scoped_memory_pointer.patch [ 51174 ] |
Charles Oliver Nutter
made changes -
| Status | Resolved [ 5 ] | Closed [ 6 ] |
Edited for readability.
Also, you don't need rubygems to see this problem. (Note that JRuby's 'pty' requires the internal 'ffi'.)
It appears that, when extending FFI::Library, it is expected that there is a call to ffi_lib listing the libraries you'd want to load. In pty's case, it is 'libc', so on my MacBook Pro, the following makes the code go:
diff --git a/lib/ruby/site_ruby/shared/pty.rb b/lib/ruby/site_ruby/shared/pty.rb index 04d7bdc..d3a0cb6 100644 --- a/lib/ruby/site_ruby/shared/pty.rb +++ b/lib/ruby/site_ruby/shared/pty.rb @@ -4,6 +4,7 @@ module PTY private module LibUtil extend FFI::Library + ffi_lib 'libc' # forkpty(3) is in libutil on linux, libc on MacOS/BSD if FFI::Platform.linux? ffi_lib 'libutil' @@ -12,6 +13,7 @@ module PTY end module LibC extend FFI::Library + ffi_lib 'libc' attach_function :close, [ :int ], :int attach_function :strerror, [ :int ], :string attach_function :execv, [ :string, :buffer_in ], :intNot sure if this is the best solution, however. In fact, on Ubuntu, it appears that libc.so FFI would load is a linker script, so this won't do.
Wayne might have a better idea.