Dmytro
Dmytro

Reputation: 2227

Problems with ffi on windows 8 x64

First tried to use berkshelf gem, but it says

bundle exec berks coolbook test_cookbook
    D:/dev/vagrant/vagrant/embedded/gems/gems/chef-10.16.2/lib/chef/win32/api.rb:20:
    in `require': cannot load such file -- ffi (LoadError)
            from D:/dev/vagrant/vagrant/embedded/gems/gems/chef-10.16.2/lib/chef/win
    32/api.rb:20:in `<top (required)>'
            from D:/dev/vagrant/vagrant/embedded/gems/gems/chef-10.16.2/lib/chef/win
    32/api/security.rb:19:in `require'
            from D:/dev/vagrant/vagrant/embedded/gems/gems/chef-10.16.2/lib/chef/win
    32/api/security.rb:19:in `<top (required)>'
            from D:/dev/vagrant/vagrant/embedded/gems/gems/chef-10.16.2/lib/chef/win
    32/security.rb:19:in `require'
            from D:/dev/vagrant/vagrant/embedded/gems/gems/chef-10.16.2/lib/chef/win
    32/security.rb:19:in `<top (required)>'
            from D:/dev/vagrant/vagrant/embedded/gems/gems/chef-10.16.2/lib/chef/fil
    e_access_control/windows.rb:20:in `require'
            from D:/dev/vagrant/vagrant/embedded/gems/gems/chef-10.16.2/lib/chef/fil
    e_access_control/windows.rb:20:in `<top (required)>'
            from D:/dev/vagrant/vagrant/embedded/gems/gems/chef-10.16.2/lib/chef/fil
    e_access_control.rb:30:in `require'
            from D:/dev/vagrant/vagrant/embedded/gems/gems/chef-10.16.2/lib/chef/fil
    e_access_control.rb:30:in `<class:FileAccessControl>'
            from D:/dev/vagrant/vagrant/embedded/gems/gems/chef-10.16.2/lib/chef/fil
    e_access_control.rb:27:in `<class:Chef>'
            from D:/dev/vagrant/vagrant/embedded/gems/gems/chef-10.16.2/lib/chef/fil
    e_access_control.rb:22:in `<top (required)>'
            from D:/dev/vagrant/vagrant/embedded/gems/gems/chef-10.16.2/lib/chef/mix
    in/enforce_ownership_and_permissions.rb:19:in `require'
            from D:/dev/vagrant/vagrant/embedded/gems/gems/chef-10.16.2/lib/chef/mix
    in/enforce_ownership_and_permissions.rb:19:in `<top (required)>'
            from D:/dev/vagrant/vagrant/embedded/gems/gems/chef-10.16.2/lib/chef/pro
    vider.rb:23:in `require'
            from D:/dev/vagrant/vagrant/embedded/gems/gems/chef-10.16.2/lib/chef/pro
    vider.rb:23:in `<top (required)>'
            from D:/dev/vagrant/vagrant/embedded/gems/gems/chef-10.16.2/lib/chef/pla
    tform.rb:26:in `require'
            from D:/dev/vagrant/vagrant/embedded/gems/gems/chef-10.16.2/lib/chef/pla
    tform.rb:26:in `<top (required)>'
            from D:/dev/vagrant/vagrant/embedded/gems/gems/berkshelf-1.1.6/lib/berks
    helf.rb:2:in `require'
            from D:/dev/vagrant/vagrant/embedded/gems/gems/berkshelf-1.1.6/lib/berks
    helf.rb:2:in `<top (required)>'
            from D:/dev/vagrant/vagrant/embedded/gems/gems/berkshelf-1.1.6/bin/berks
    :3:in `require'
            from D:/dev/vagrant/vagrant/embedded/gems/gems/berkshelf-1.1.6/bin/berks
    :3:in `<top (required)>'
            from D:/dev/vagrant/vagrant/embedded/gems/bin/berks:23:in `load'
            from D:/dev/vagrant/vagrant/embedded/gems/bin/berks:23:in `<main>'

Then tried to reinstall ffi gem with different versions

gem uninstall ffi
gem install ffi -v 1.0.9

gem uninstall ffi
gem install ffi

It installs well, but something fails while installing documentation

1 gem installed
Installing ri documentation for ffi-1.3.1-x86-mingw32...
Enclosing class/module 'moduleFFI' for class AbstractMemory not known
Enclosing class/module 'moduleFFI' for class NullPointerError not known
Enclosing class/module "classMemory" for alias put_" #name, "put_" #old); \
    rb_define_alias(classMemory, "get_" #name, "get_" #old); \
    rb_define_alias(classMemory, "put_u" #name, "put_u" #old); \
    rb_define_alias(classMemory, "get_u" #name, "get_u" #old); \
    rb_define_alias(classMemory, "write_" #name, "write_" #old); \
    rb_define_alias(classMemory, "read_" #name, "read_" #old); \
    rb_define_alias(classMemory, "write_u" #name, "write_u" #old); \
    rb_define_alias(classMemory, "read_u" #name, "read_u" #old); \
    rb_define_alias(classMemory, "put_array_of_" #name, "put_array_of_" #old); \

    rb_define_alias(classMemory, "get_array_of_" #name, "get_array_of_" #old); \

    rb_define_alias(classMemory, "put_array_of_u" #name, "put_array_of_u" #old);
 \
    rb_define_alias(classMemory, "get_array_of_u" #name, "get_array_of_u" #old);
 \
    rb_define_alias(classMemory, "write_array_of_" #name, "write_array_of_" #old
); \
    rb_define_alias(classMemory, "read_array_of_" #name, "read_array_of_" #old);
 \
    rb_define_alias(classMemory, "write_array_of_u" #name, "write_array_of_u" #o
ld); \
    rb_define_alias(classMemory, "read_array_of_u" #name, "read_array_of_u" #old
);

    ALIAS(char, int8);
    ALIAS(short, int16);
    ALIAS(int, int32);
    ALIAS(long_long, int64);

    /*
     * Document-method: put_float32
     * call-seq: memory.put_float32offset, value)
     * @param [Numeric] offset
     * @param [Numeric] value
     * @return [self]
     * Put +value+ as a 32-bit float in memory at offset +offset+ (alias: #put_f
loat).
     */
    rb_define_method(classMemory, "put_float32", memory_put_float32, 2);
    /*
     * Document-method: get_float32
     * call-seq: memory.get_float32(offset)
     * @param [Numeric] offset
     * @return [Float]
     * Get a 32-bit float from memory at offset +offset+ (alias: #get_float).
     */
    rb_define_method(classMemory, "get_float32", memory_get_float32, 1);
    rb_define_alias(classMemory, "put_float put_float32 not known
Enclosing class/module "classMemory" for alias get_float get_float32 not known
Enclosing class/module "classMemory" for alias put_array_of_float put_array_of_f
loat32 not known
Enclosing class/module "classMemory" for alias get_array_of_float get_array_of_f
loat32 not known
Enclosing class/module "classMemory" for alias put_double put_float64 not known
Enclosing class/module "classMemory" for alias get_double get_float64 not known
Enclosing class/module "classMemory" for alias put_array_of_double put_array_of_
float64 not known
Enclosing class/module "classMemory" for alias get_array_of_double get_array_of_
float64 not known
Enclosing class/module "classMemory" for alias size total not known
Enclosing class/module 'moduleFFI' for class ArrayType not known
Enclosing class/module 'moduleFFI' for class Buffer not known
Enclosing class/module "BufferClass" for alias length total not known
Enclosing class/module 'moduleFFI' for module DataConverter not known
Enclosing class/module 'moduleFFI' for class DynamicLibrary not known
Enclosing class/module 'LibraryClass' for class Symbol not known
Enclosing class/module 'rbffi_TypeClass' for class Mapped not known
Enclosing class/module 'rbffi_StructLayoutClass' for class CharArray not known
Enclosing class/module "rbffi_StructLayoutCharArrayClass" for alias to_str to_s
not known
Installing RDoc documentation for ffi-1.3.1-x86-mingw32...
Enclosing class/module 'moduleFFI' for class AbstractMemory not known
Enclosing class/module 'moduleFFI' for class NullPointerError not known
Enclosing class/module "classMemory" for alias put_" #name, "put_" #old); \
    rb_define_alias(classMemory, "get_" #name, "get_" #old); \
    rb_define_alias(classMemory, "put_u" #name, "put_u" #old); \
    rb_define_alias(classMemory, "get_u" #name, "get_u" #old); \
    rb_define_alias(classMemory, "write_" #name, "write_" #old); \
    rb_define_alias(classMemory, "read_" #name, "read_" #old); \
    rb_define_alias(classMemory, "write_u" #name, "write_u" #old); \
    rb_define_alias(classMemory, "read_u" #name, "read_u" #old); \
    rb_define_alias(classMemory, "put_array_of_" #name, "put_array_of_" #old); \

    rb_define_alias(classMemory, "get_array_of_" #name, "get_array_of_" #old); \

    rb_define_alias(classMemory, "put_array_of_u" #name, "put_array_of_u" #old);
 \
    rb_define_alias(classMemory, "get_array_of_u" #name, "get_array_of_u" #old);
 \
    rb_define_alias(classMemory, "write_array_of_" #name, "write_array_of_" #old
); \
    rb_define_alias(classMemory, "read_array_of_" #name, "read_array_of_" #old);
 \
    rb_define_alias(classMemory, "write_array_of_u" #name, "write_array_of_u" #o
ld); \
    rb_define_alias(classMemory, "read_array_of_u" #name, "read_array_of_u" #old
);

    ALIAS(char, int8);
    ALIAS(short, int16);
    ALIAS(int, int32);
    ALIAS(long_long, int64);

    /*
     * Document-method: put_float32
     * call-seq: memory.put_float32offset, value)
     * @param [Numeric] offset
     * @param [Numeric] value
     * @return [self]
     * Put +value+ as a 32-bit float in memory at offset +offset+ (alias: #put_f
loat).
     */
    rb_define_method(classMemory, "put_float32", memory_put_float32, 2);
    /*
     * Document-method: get_float32
     * call-seq: memory.get_float32(offset)
     * @param [Numeric] offset
     * @return [Float]
     * Get a 32-bit float from memory at offset +offset+ (alias: #get_float).
     */
    rb_define_method(classMemory, "get_float32", memory_get_float32, 1);
    rb_define_alias(classMemory, "put_float put_float32 not known
Enclosing class/module "classMemory" for alias get_float get_float32 not known
Enclosing class/module "classMemory" for alias put_array_of_float put_array_of_f
loat32 not known
Enclosing class/module "classMemory" for alias get_array_of_float get_array_of_f
loat32 not known
Enclosing class/module "classMemory" for alias put_double put_float64 not known
Enclosing class/module "classMemory" for alias get_double get_float64 not known
Enclosing class/module "classMemory" for alias put_array_of_double put_array_of_
float64 not known
Enclosing class/module "classMemory" for alias get_array_of_double get_array_of_
float64 not known
Enclosing class/module "classMemory" for alias size total not known
Enclosing class/module 'moduleFFI' for class ArrayType not known
Enclosing class/module 'moduleFFI' for class Buffer not known
Enclosing class/module "BufferClass" for alias length total not known
Enclosing class/module 'moduleFFI' for module DataConverter not known
Enclosing class/module 'moduleFFI' for class DynamicLibrary not known
Enclosing class/module 'LibraryClass' for class Symbol not known
Enclosing class/module 'rbffi_TypeClass' for class Mapped not known
Enclosing class/module 'rbffi_StructLayoutClass' for class CharArray not known
Enclosing class/module "rbffi_StructLayoutCharArrayClass" for alias to_str to_s
not known


gem uninstall ffi
gem install ffi

But no ffi installation has fix the main problem with berkshelf.

Upvotes: 0

Views: 738

Answers (2)

Zohar Misinai-Basil
Zohar Misinai-Basil

Reputation: 1

I had a similar problem for ruby version 1.9.3 ruby 1.9.3p551 and 64-bit linux as well. Install of libffi-dev was the first step, as in answer numbe 1.

gem uninstall ffi
gem install ffi

still had the same problem. Only after adding the install of rdoc gem:

gem install rdoc
gem uninstall ffi
gem install ffi

worked with no errors.

Upvotes: 0

Matt S
Matt S

Reputation: 33

I had a similar problem installing another gem under 64-bit Linux. When compiling the gem I would get the exact same error regarding the ffi gem. My fix was to install libffi-dev package and it worked. There is an X86-64 for Windows/MingW version of this package so I would recommend making sure you have installed this.

Upvotes: 1

Related Questions