LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Ruby-FFI: `ffi_libraries': no library specified (LoadError) (https://www.linuxquestions.org/questions/linux-server-73/ruby-ffi-%60ffi_libraries-no-library-specified-loaderror-878011/)

quanta 04-30-2011 10:29 AM

Ruby-FFI: `ffi_libraries': no library specified (LoadError)
 
Hi,

As I mentioned in the subject, I got the following error when start tyrantmanager:
Code:

tyrantmanager --help

/usr/lib64/ruby/gems/1.8/gems/loquacious-1.6.4/lib/loquacious/undefined.rb:87: warning: parenthesize argument(s) for future version
/usr/lib64/ruby/gems/1.8/gems/ffi-1.0.0/lib/ffi/library.rb:93:in ffi_libraries': no library specified (LoadError)
from /usr/lib64/ruby/gems/1.8/gems/ffi-1.0.0/lib/ffi/library.rb:129:inattfunc'
from /usr/lib64/ruby/gems/1.8/gems/rufus-tokyo-1.0.7/lib/rufus/tokyo/tyrant/lib.rb:59
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require'
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire'
from /usr/lib64/ruby/gems/1.8/gems/rufus-tokyo-1.0.7/lib/rufus/tokyo/tyrant.rb:32
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require'
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire'
from /usr/lib64/ruby/gems/1.8/gems/tyrantmanager-1.6.0/lib/tyrant_manager/tyrant_instance.rb:2
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require'
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire'
from /usr/lib64/ruby/gems/1.8/gems/tyrantmanager-1.6.0/lib/tyrant_manager.rb:249
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require'
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire'
from /usr/lib64/ruby/gems/1.8/gems/tyrantmanager-1.6.0/bin/tyrantmanager:9
from /usr/bin/tyrantmanager:19:in `load'
from /usr/bin/tyrantmanager:19

It happens with all the versions of ffi: form 0.6.3 to 1.0.7.

The content of library.rb:
Code:

    21        module FFI
    22          CURRENT_PROCESS = USE_THIS_PROCESS_AS_LIBRARY = Object.new
    23       
    24          def self.map_library_name(lib)
    25            # Mangle the library name to reflect the native library naming conventions
    26            lib = lib.to_s unless lib.kind_of?(String)
    27            lib = Library::LIBC if lib == 'c'
    28       
    29            if lib && File.basename(lib) == lib
    30              lib = Platform::LIBPREFIX + lib unless lib =~ /^#{Platform::LIBPREFIX}/
    31              r = Platform::IS_LINUX ? "\\.so($|\\.[1234567890]+)" : "\\.#{Platform::LIBSUFFIX}$"
    32              lib += ".#{Platform::LIBSUFFIX}" unless lib =~ /#{r}/
    33            end
    34       
    35            lib
    36          end
    37       
    38          class NotFoundError < LoadError
    39            def initialize(function, *libraries)
    40              super("Function '#{function}' not found in [#{libraries[0].nil? ? 'current process' : libraries.join(", ")}]")
    41            end
    42          end
    43       
    44          module Library
    45            CURRENT_PROCESS = FFI::CURRENT_PROCESS
    46            LIBC = FFI::Platform::LIBC
    47       
    48            def self.extended(mod)
    49              raise RuntimeError.new("must only be extended by module") unless mod.kind_of?(Module)
    50            end
    51       
    52            def ffi_lib(*names)
    53              lib_flags = defined?(@ffi_lib_flags) ? @ffi_lib_flags : FFI::DynamicLibrary::RTLD_LAZY | FFI::DynamicLibrary::RTLD_LOCAL
    54              ffi_libs = names.map do |name|
    55       
    56                if name == FFI::CURRENT_PROCESS
    57                  FFI::DynamicLibrary.open(nil, FFI::DynamicLibrary::RTLD_LAZY | FFI::DynamicLibrary::RTLD_LOCAL)
    58       
    59                else
    60                  libnames = (name.is_a?(::Array) ? name : [ name ]).map { |n| [ n, FFI.map_library_name(n) ].uniq }.flatten.compact
    61                  lib = nil
    62                  errors = {}
    63       
    64                  libnames.each do |libname|
    65                    begin
    66                      lib = FFI::DynamicLibrary.open(libname, lib_flags)
    67                      break if lib
    68       
    69                    rescue Exception => ex
    70                      errors[libname] = ex
    71                    end
    72                  end
    73       
    74                  if lib.nil?
    75                    raise LoadError.new(errors.values.join('. '))
    76                  end
    77       
    78                  # return the found lib
    79                  lib
    80                end
    81              end
    82       
    83              @ffi_libs = ffi_libs
    84            end
    85       
    86       
    87            def ffi_convention(convention)
    88              @ffi_convention = convention
    89            end
    90       
    91       
    92            def ffi_libraries
    93              raise LoadError.new("no library specified") if !defined?(@ffi_libs) || @ffi_libs.empty?
    94              @ffi_libs
    95            end

Code:

# gem list

*** LOCAL GEMS ***

arrayfields (4.7.4)
fattr (2.2.0)
ffi (1.0.0, 0.6.3)
little-plugger (1.1.2)
logging (1.4.3)
loquacious (1.6.4)
main (4.4.0, 4.2.0)
rake (0.8.7)
rufus-tokyo (1.0.7)
tyrantmanager (1.6.0)

Can anyone help me fix this problem?

knudfl 04-30-2011 03:25 PM

Is libffi installed ? ?

# yum install libffi
If CentOS5 : The Karanbir repo, or
http://rpm.pbone.net/index.php3/stat....i386.rpm.html

Debian : libffi5

Source http://sources.redhat.com/libffi/

..

quanta 04-30-2011 08:31 PM

Quote:

Originally Posted by knudfl (Post 4342207)
Is libffi installed ? ?

# yum install libffi
If CentOS5 : The Karanbir repo, or
http://rpm.pbone.net/index.php3/stat....i386.rpm.html

Debian : libffi5

Source http://sources.redhat.com/libffi/

..

Yes, it is:
Code:

$ rpm -qa | grep libffi
libffi-devel-3.0.9-1.el5.rf
libffi-3.0.9-1.el5.rf



All times are GMT -5. The time now is 07:38 PM.