chef / ffi-yajl

Ruby FFI gem wrapper around yajl2 library
MIT License
11 stars 21 forks source link

Failing to build with ruby 2.5.0 #94

Closed crsuarez closed 6 years ago

crsuarez commented 6 years ago

Installing ffi-yajl 1.4.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /usr/local/lib/ruby/gems/2.5.0/gems/ffi-yajl-1.4.0/ext/ffi_yajl/ext/encoder
/usr/local/opt/ruby/bin/ruby -r ./siteconf20180313-8919-13slypp.rb extconf.rb
 -I/Users/csuarez/.gem/ruby/2.5.0/gems/libyajl2-1.2.0/lib/libyajl2/vendored-libyajl2/include $(cflags)  -fno-common -pipe
 -L/Users/csuarez/.gem/ruby/2.5.0/gems/libyajl2-1.2.0/lib/libyajl2/vendored-libyajl2/lib -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib
checking for yajl/yajl_tree.h... yes
creating Makefile

current directory: /usr/local/lib/ruby/gems/2.5.0/gems/ffi-yajl-1.4.0/ext/ffi_yajl/ext/encoder
make "DESTDIR=" clean

current directory: /usr/local/lib/ruby/gems/2.5.0/gems/ffi-yajl-1.4.0/ext/ffi_yajl/ext/encoder
make "DESTDIR="
compiling encoder.c
encoder.c:85:15: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
    int len = RSTRING_LEN(str);
        ~~~   ^~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.5.0/include/ruby-2.5.0/ruby/ruby.h:975:6: note: expanded from macro 'RSTRING_LEN'
     RSTRING_EMBED_LEN(str) : \
     ^~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.5.0/include/ruby-2.5.0/ruby/ruby.h:971:6: note: expanded from macro 'RSTRING_EMBED_LEN'
     (long)((RBASIC(str)->flags >> RSTRING_EMBED_LEN_SHIFT) & \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
encoder.c:85:15: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
    int len = RSTRING_LEN(str);
        ~~~   ^~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.5.0/include/ruby-2.5.0/ruby/ruby.h:976:28: note: expanded from macro 'RSTRING_LEN'
     RSTRING(str)->as.heap.len)
     ~~~~~~~~~~~~~~~~~~~~~~^~~
encoder.c:121:15: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
    int len = RSTRING_LEN(str);
        ~~~   ^~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.5.0/include/ruby-2.5.0/ruby/ruby.h:975:6: note: expanded from macro 'RSTRING_LEN'
     RSTRING_EMBED_LEN(str) : \
     ^~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.5.0/include/ruby-2.5.0/ruby/ruby.h:971:6: note: expanded from macro 'RSTRING_EMBED_LEN'
     (long)((RBASIC(str)->flags >> RSTRING_EMBED_LEN_SHIFT) & \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
encoder.c:121:15: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
    int len = RSTRING_LEN(str);
        ~~~   ^~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.5.0/include/ruby-2.5.0/ruby/ruby.h:976:28: note: expanded from macro 'RSTRING_LEN'
     RSTRING(str)->as.heap.len)
     ~~~~~~~~~~~~~~~~~~~~~~^~~
encoder.c:151:15: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
    int len = RSTRING_LEN(str);
        ~~~   ^~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.5.0/include/ruby-2.5.0/ruby/ruby.h:975:6: note: expanded from macro 'RSTRING_LEN'
     RSTRING_EMBED_LEN(str) : \
     ^~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.5.0/include/ruby-2.5.0/ruby/ruby.h:971:6: note: expanded from macro 'RSTRING_EMBED_LEN'
     (long)((RBASIC(str)->flags >> RSTRING_EMBED_LEN_SHIFT) & \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
encoder.c:151:15: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
    int len = RSTRING_LEN(str);
        ~~~   ^~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.5.0/include/ruby-2.5.0/ruby/ruby.h:976:28: note: expanded from macro 'RSTRING_LEN'
     RSTRING(str)->as.heap.len)
     ~~~~~~~~~~~~~~~~~~~~~~^~~
encoder.c:174:15: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
    int len = RSTRING_LEN(str);
        ~~~   ^~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.5.0/include/ruby-2.5.0/ruby/ruby.h:975:6: note: expanded from macro 'RSTRING_LEN'
     RSTRING_EMBED_LEN(str) : \
     ^~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.5.0/include/ruby-2.5.0/ruby/ruby.h:971:6: note: expanded from macro 'RSTRING_EMBED_LEN'
     (long)((RBASIC(str)->flags >> RSTRING_EMBED_LEN_SHIFT) & \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
encoder.c:174:15: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
    int len = RSTRING_LEN(str);
        ~~~   ^~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.5.0/include/ruby-2.5.0/ruby/ruby.h:976:28: note: expanded from macro 'RSTRING_LEN'
     RSTRING(str)->as.heap.len)
     ~~~~~~~~~~~~~~~~~~~~~~^~~
encoder.c:197:15: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
    int len = RSTRING_LEN(str);
        ~~~   ^~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.5.0/include/ruby-2.5.0/ruby/ruby.h:975:6: note: expanded from macro 'RSTRING_LEN'
     RSTRING_EMBED_LEN(str) : \
     ^~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.5.0/include/ruby-2.5.0/ruby/ruby.h:971:6: note: expanded from macro 'RSTRING_EMBED_LEN'
     (long)((RBASIC(str)->flags >> RSTRING_EMBED_LEN_SHIFT) & \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
encoder.c:197:15: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
    int len = RSTRING_LEN(str);
        ~~~   ^~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.5.0/include/ruby-2.5.0/ruby/ruby.h:976:28: note: expanded from macro 'RSTRING_LEN'
     RSTRING(str)->as.heap.len)
     ~~~~~~~~~~~~~~~~~~~~~~^~~
encoder.c:216:13: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  int len = RSTRING_LEN(str);
      ~~~   ^~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.5.0/include/ruby-2.5.0/ruby/ruby.h:975:6: note: expanded from macro 'RSTRING_LEN'
     RSTRING_EMBED_LEN(str) : \
     ^~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.5.0/include/ruby-2.5.0/ruby/ruby.h:971:6: note: expanded from macro 'RSTRING_EMBED_LEN'
     (long)((RBASIC(str)->flags >> RSTRING_EMBED_LEN_SHIFT) & \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
encoder.c:216:13: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  int len = RSTRING_LEN(str);
      ~~~   ^~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.5.0/include/ruby-2.5.0/ruby/ruby.h:976:28: note: expanded from macro 'RSTRING_LEN'
     RSTRING(str)->as.heap.len)
     ~~~~~~~~~~~~~~~~~~~~~~^~~
encoder.c:241:13: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  int len = RSTRING_LEN(str);
      ~~~   ^~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.5.0/include/ruby-2.5.0/ruby/ruby.h:975:6: note: expanded from macro 'RSTRING_LEN'
     RSTRING_EMBED_LEN(str) : \
     ^~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.5.0/include/ruby-2.5.0/ruby/ruby.h:971:6: note: expanded from macro 'RSTRING_EMBED_LEN'
     (long)((RBASIC(str)->flags >> RSTRING_EMBED_LEN_SHIFT) & \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
encoder.c:241:13: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  int len = RSTRING_LEN(str);
      ~~~   ^~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.5.0/include/ruby-2.5.0/ruby/ruby.h:976:28: note: expanded from macro 'RSTRING_LEN'
     RSTRING(str)->as.heap.len)
     ~~~~~~~~~~~~~~~~~~~~~~^~~
encoder.c:266:13: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  int len = RSTRING_LEN(str);
      ~~~   ^~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.5.0/include/ruby-2.5.0/ruby/ruby.h:975:6: note: expanded from macro 'RSTRING_LEN'
     RSTRING_EMBED_LEN(str) : \
     ^~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.5.0/include/ruby-2.5.0/ruby/ruby.h:971:6: note: expanded from macro 'RSTRING_EMBED_LEN'
     (long)((RBASIC(str)->flags >> RSTRING_EMBED_LEN_SHIFT) & \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
encoder.c:266:13: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  int len = RSTRING_LEN(str);
      ~~~   ^~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.5.0/include/ruby-2.5.0/ruby/ruby.h:976:28: note: expanded from macro 'RSTRING_LEN'
     RSTRING(str)->as.heap.len)
     ~~~~~~~~~~~~~~~~~~~~~~^~~
encoder.c:304:13: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  int len = RSTRING_LEN(str);
      ~~~   ^~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.5.0/include/ruby-2.5.0/ruby/ruby.h:975:6: note: expanded from macro 'RSTRING_LEN'
     RSTRING_EMBED_LEN(str) : \
     ^~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.5.0/include/ruby-2.5.0/ruby/ruby.h:971:6: note: expanded from macro 'RSTRING_EMBED_LEN'
     (long)((RBASIC(str)->flags >> RSTRING_EMBED_LEN_SHIFT) & \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
encoder.c:304:13: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  int len = RSTRING_LEN(str);
      ~~~   ^~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.5.0/include/ruby-2.5.0/ruby/ruby.h:976:28: note: expanded from macro 'RSTRING_LEN'
     RSTRING(str)->as.heap.len)
     ~~~~~~~~~~~~~~~~~~~~~~^~~
encoder.c:328:13: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  int len = RSTRING_LEN(str);
      ~~~   ^~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.5.0/include/ruby-2.5.0/ruby/ruby.h:975:6: note: expanded from macro 'RSTRING_LEN'
     RSTRING_EMBED_LEN(str) : \
     ^~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.5.0/include/ruby-2.5.0/ruby/ruby.h:971:6: note: expanded from macro 'RSTRING_EMBED_LEN'
     (long)((RBASIC(str)->flags >> RSTRING_EMBED_LEN_SHIFT) & \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
encoder.c:328:13: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  int len = RSTRING_LEN(str);
      ~~~   ^~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.5.0/include/ruby-2.5.0/ruby/ruby.h:976:28: note: expanded from macro 'RSTRING_LEN'
     RSTRING(str)->as.heap.len)
     ~~~~~~~~~~~~~~~~~~~~~~^~~
encoder.c:382:20: error: use of undeclared identifier 'rb_cFixnum'
  rb_define_method(rb_cFixnum, "ffi_yajl", rb_cFixnum_ffi_yajl, 2);
                   ^
encoder.c:383:20: error: use of undeclared identifier 'rb_cBignum'
  rb_define_method(rb_cBignum, "ffi_yajl", rb_cBignum_ffi_yajl, 2);
                   ^
20 warnings and 2 errors generated.
make: *** [encoder.o] Error 1

make failed, exit code 2

Gem files will remain installed in /usr/local/lib/ruby/gems/2.5.0/gems/ffi-yajl-1.4.0 for inspection.
lamont-granquist commented 6 years ago

you're trying to install ffi-yajl 1.4.0, the current version is 2.3.1.

spotlesscoder commented 6 years ago

Also happens with 2.2.2


user@user-VirtualBox:~/chef-browser$ cat /home/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0-static/ffi-yajl-2.2.2/gem_make.out
current directory: /home/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/ffi-yajl-2.2.2/ext/ffi_yajl/ext/encoder
/home/user/.rbenv/versions/2.5.0/bin/ruby -r ./siteconf20180411-11583-1nik0k1.rb extconf.rb
 -I/home/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/libyajl2-1.2.0/lib/libyajl2/vendored-libyajl2/include $(cflags)
 -L/home/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/libyajl2-1.2.0/lib/libyajl2/vendored-libyajl2/lib -L. -L/home/user/.rbenv/versions/2.5.0/lib  -fstack-protector -rdynamic -Wl,-export-dynamic
checking for yajl/yajl_tree.h... yes
creating Makefile

current directory: /home/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/ffi-yajl-2.2.2/ext/ffi_yajl/ext/encoder
make "DESTDIR=" clean

current directory: /home/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/ffi-yajl-2.2.2/ext/ffi_yajl/ext/encoder
make "DESTDIR="
compiling encoder.c
encoder.c: In function ‘gen_number’:
encoder.c:109:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
   char *cptr = RSTRING_PTR(str);
   ^
encoder.c: In function ‘rb_cNilClass_ffi_yajl’:
encoder.c:262:30: warning: passing argument 2 of ‘gen_cstring’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
     gen_cstring(rb_yajl_gen, "", sizeof("")-1);
                              ^
encoder.c:79:7: note: expected ‘char *’ but argument is of type ‘const char *’
 VALUE gen_cstring(VALUE rb_yajl_gen, char *cptr, int len) {
       ^
encoder.c: In function ‘rb_cTrueClass_ffi_yajl’:
encoder.c:272:30: warning: passing argument 2 of ‘gen_cstring’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
     gen_cstring(rb_yajl_gen, "true", sizeof("true")-1);
                              ^
encoder.c:79:7: note: expected ‘char *’ but argument is of type ‘const char *’
 VALUE gen_cstring(VALUE rb_yajl_gen, char *cptr, int len) {
       ^
encoder.c: In function ‘rb_cFalseClass_ffi_yajl’:
encoder.c:282:30: warning: passing argument 2 of ‘gen_cstring’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
     gen_cstring(rb_yajl_gen, "false", sizeof("false")-1);
                              ^
encoder.c:79:7: note: expected ‘char *’ but argument is of type ‘const char *’
 VALUE gen_cstring(VALUE rb_yajl_gen, char *cptr, int len) {
       ^
encoder.c: In function ‘Init_encoder’:
encoder.c:366:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
   ID sym_Date = rb_intern("Date");
   ^
encoder.c:368:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
   ID sym_Time = rb_intern("Time");
   ^
encoder.c:370:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
   ID sym_DateTime = rb_intern("DateTime");
   ^
encoder.c:372:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
   ID sym_StringIO = rb_intern("StringIO");
   ^
encoder.c:380:20: error: ‘rb_cFixnum’ undeclared (first use in this function)
   rb_define_method(rb_cFixnum, "ffi_yajl", rb_cFixnum_ffi_yajl, 2);
                    ^
encoder.c:380:20: note: each undeclared identifier is reported only once for each function it appears in
encoder.c:381:20: error: ‘rb_cBignum’ undeclared (first use in this function)
   rb_define_method(rb_cBignum, "ffi_yajl", rb_cBignum_ffi_yajl, 2);
                    ^
encoder.c: At top level:
cc1: warning: unrecognized command line option ‘-Wno-self-assign’
cc1: warning: unrecognized command line option ‘-Wno-constant-logical-operand’
cc1: warning: unrecognized command line option ‘-Wno-parentheses-equality’
cc1: warning: unrecognized command line option ‘-Wno-tautological-compare’
Makefile:241: recipe for target 'encoder.o' failed
make: *** [encoder.o] Error 1

make failed, exit code 2
lamont-granquist commented 6 years ago

again: "the current version is 2.3.1"

lamont-granquist commented 6 years ago

For people trying to build old versions of chef on a new version or ruby and you feel you're blocked because of ffi-yajl.

You can't do that.

You have to bundle install chef onto the version of chef which it was shipped on.

This is a major reason why we push people towards using the omnibus-chef and omnibus-chefdk packages to sort this out (and the whole point of those is that we can decisively say 'no' to these kinds of support requests).

For consumers as a gem to bundle install you must use the correct ruby version to test against (for any number of reasons) which as an example in travis looks like:

https://github.com/poise/halite/blob/07ccd6d14cda75ce6e78e4ad8055a88bdb89efe5/.travis.yml#L6-L31

A more involved example that we had to use ourselves:

https://github.com/chef-boneyard/compat_resource/blob/master/.travis.yml#L23-L56

This gem install is just the first failure you're likely to hit. You will also be missing the patches that went directly into the chef-client to fix bugs, along with any other issues around gem dependencies. So even if we attempted to fix this repo it wouldn't help you, it would just let you get further down a road that is completely unsupported.

The two solutions are to pin your ruby onto an old version that matches the chef version, or to upgrade your chef version. You can't take old chef and expect to run it on new ruby.