uninitialized constant LIBUSB::Call::FFI (NameError)
pioz opened this issue · 5 comments
Hi, I have this problem under osx lion:
I've installed ffi and libusb gem:
port install libusb
gem install ffi
gem install libusb
When I run this code
require 'libusb'
I've this error:
/Users/pioz/.rvm/gems/ruby-1.9.3-p0/gems/libusb-0.1.3/lib/libusb.rb:24:in `<module:Call>': uninitialized constant LIBUSB::Call::FFI (NameError)
from /Users/pioz/.rvm/gems/ruby-1.9.3-p0/gems/libusb-0.1.3/lib/libusb.rb:23:in `<module:LIBUSB>'
from /Users/pioz/.rvm/gems/ruby-1.9.3-p0/gems/libusb-0.1.3/lib/libusb.rb:20:in `<top (required)>'
from /Users/pioz/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `require'
from /Users/pioz/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `rescue in require'
from /Users/pioz/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
from main.rb:1:in `<main>'
Ruby version 1.9.3, libusb version 1.0.9, libusb gem version 0.1.3, ffi gem version 1.0.11.
Any idea?
Currently no idea. It seems that ffi isn't installed/loaded correctly. You may try
gem install ffi --pre
or do a
gem 'ffi'
require 'libusb'
to ensure, that require 'ffi'
does not load some wrong file.
Ok, with ffi --pre
(v1.1.0.rc4) I've another error:
/Users/pioz/.rvm/gems/ruby-1.9.3-p0/gems/ffi-1.1.0.rc4/lib/ffi/library.rb:121:in `block in ffi_lib': Could not open library 'libusb-1.0': dlopen(libusb-1.0, 5): image not found. (LoadError)
Could not open library 'libusb-1.0.dylib': dlopen(libusb-1.0.dylib, 5): image not found
from /Users/pioz/.rvm/gems/ruby-1.9.3-p0/gems/ffi-1.1.0.rc4/lib/ffi/library.rb:88:in `map'
from /Users/pioz/.rvm/gems/ruby-1.9.3-p0/gems/ffi-1.1.0.rc4/lib/ffi/library.rb:88:in `ffi_lib'
from /Users/pioz/.rvm/gems/ruby-1.9.3-p0/gems/libusb-0.1.3/lib/libusb.rb:29:in `<module:Call>'
from /Users/pioz/.rvm/gems/ruby-1.9.3-p0/gems/libusb-0.1.3/lib/libusb.rb:23:in `<module:LIBUSB>'
from /Users/pioz/.rvm/gems/ruby-1.9.3-p0/gems/libusb-0.1.3/lib/libusb.rb:20:in `<top (required)>'
from /Users/pioz/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `require'
from /Users/pioz/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `rescue in require'
from /Users/pioz/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
I've install libusb with sudo port install libusb
.
$ port list | grep libusb
libusb @1.0.9 devel/libusb
libusb-compat @0.1.4 devel/libusb-compat
libusb-devel @1.0.8.20101017 devel/libusb-devel
libusb-legacy @0.1.12 devel/libusb-legacy
I'm not that familar with OSX. But you need to have libusb installed:
port installed | grep libusb
libusb @1.0.9_0 (active)
Then there should be a file /opt/local/lib/libusb-1.0.dylib
. To ensure that the libusb library file can be found, you could use:
export LD_LIBRARY_PATH=/opt/local/lib
In any case installing libusb through homebrew seemed to solve the issue for me :)