0

最初に berkshelf gem を使用しようとしましたが、

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>'

次に、異なるバージョンで ffi gem を再インストールしようとしました

gem uninstall ffi
gem install ffi -v 1.0.9

gem uninstall ffi
gem install ffi

うまくインストールできますが、ドキュメントのインストール中に何かが失敗します

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

しかし、ffi をインストールしても berkshelf の主な問題は解決されませんでした。

4

2 に答える 2

1

64 ビット Linux で別の gem をインストールする際にも同様の問題がありました。gem をコンパイルすると、ffi gem に関してまったく同じエラーが発生します。私の修正は libffi-dev パッケージをインストールすることで、うまくいきました。このパッケージの Windows/MingW バージョン用の X86-64 があるので、これがインストールされていることを確認することをお勧めします。

于 2013-09-11T08:44:48.587 に答える
0

ruby バージョン 1.9.3 ruby​​ 1.9.3p551 および 64 ビット Linux でも同様の問題が発生しました。回答番号 1 のように、libffi-dev のインストールが最初のステップでした。

gem uninstall ffi
gem install ffi

まだ同じ問題がありました。rdoc gem のインストールを追加した後でのみ:

gem install rdoc
gem uninstall ffi
gem install ffi

エラーなしで動作しました。

于 2015-05-06T05:42:48.627 に答える