简体   繁体   中英

Rails gem install error - coccon

I got this error while installing coccon gem. Does anyone has the same problem? I'm using Ruby 2.0.0p353, Rails 4.0 and RVM

ERROR:  Error installing cocoon:
ERROR: Failed to build gem native extension.

    /home/user/.rvm/rubies/ruby-2.0.0-p353/bin/ruby extconf.rb
checking for st.h... yes
creating Makefile

make
compiling handler.c
compiling gram.c
compiling token.c
token.re: In function ‘sycklex_yaml_utf8’:
token.re:541:36: warning: variable ‘lvl’ set but not used [-Wunused-but-set-variable]
compiling syck.c
compiling rubyext.c
rubyext.c: In function ‘mktime_do’:
rubyext.c:292:19: warning: unused variable ‘offset’ [-Wunused-variable]
rubyext.c: In function ‘rb_syck_load_handler’:
rubyext.c:664:5: warning: implicit declaration of function ‘rb_hash_size’ [-Wimplicit-       function-declaration]
rubyext.c: In function ‘rb_syck_err_handler’:
rubyext.c:684:12: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘long int’ [-Wformat]
rubyext.c: In function ‘syck_const_find’:
rubyext.c:1047:5: warning: implicit declaration of function ‘rb_ary_size’ [-Wimplicit-function-declaration]
rubyext.c: In function ‘syck_scalar_value_set’:
rubyext.c:1481:27: error: ‘struct RString’ has no member named ‘ptr’
rubyext.c: In function ‘syck_seq_initialize’:
rubyext.c:1509:15: warning: variable ‘node’ set but not used [-Wunused-but-set-variable]
rubyext.c: In function ‘syck_node_type_id_set’:
rubyext.c:1741:25: error: ‘struct RString’ has no member named ‘ptr’
make: *** [rubyext.o] Error 1

The cocoon gem is using Jeweler which emitted Rubinius-specific gem dependencies into the gemspec. The gem created from the gemspec and expected to be installed on MRI then includes those dependencies. I've submitted a pull request to fix this for the cocoon gem: https://github.com/nathanvda/cocoon/pull/184

In general, I'd suggest filing issues on a gem's source repository as the author may not be alerted to an issue posted here.

Cocoon 1.2.4 had a broken gemspec, which was fixed in 1.2.5 which was released shortly after. So this should just work now.

# cd /path/rubysl-yaml-2.0.4
# vi ext/rubysl/syck/rubyext.c

change (RSRING -> RSTRING_PTR)

#define syck_copy_string(val) syck_strndup(RSTRING(val)->ptr, RSTRING_LEN(val))

to

#define syck_copy_string(val) syck_strndup(RSTRING_PTR(val)->ptr, RSTRING_LEN(val))

and gem build and install

# gem build rubysl-yaml.gemspec && gem install rubysl-yaml-2.0.4.gem

good luck

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM