lxc/ruby-lxc

Error installing gem with Rubinius

bararchy opened this issue · 11 comments

Command: gem install ruby-lxc

Error:

Fetching: ruby-lxc-1.2.0.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing ruby-lxc:
    ERROR: Failed to build gem native extension.

    /usr/local/rvm/rubies/rbx-2.5.2/bin/rbx -r ./siteconf20160103-7975-gai0k3.rb extconf.rb
checking for lxc_container_new() in -llxc... yes
checking for lxc/lxccontainer.h... yes
checking for rb_thread_call_without_gvl()... no
checking for rb_thread_blocking_region()... no
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling lxc.c
lxc.c:576:11: error: expected parameter declarator
    VALUE rb_stdin, rb_stdout, rb_stderr;
          ^
/usr/local/rvm/rubies/rbx-2.5.2/vm/include/capi/ruby/ruby.h:374:41: note: expanded from macro 'rb_stdin'
#define rb_stdin              rb_gv_get("$stdin")
                                        ^
lxc.c:576:11: error: expected ')'
/usr/local/rvm/rubies/rbx-2.5.2/vm/include/capi/ruby/ruby.h:374:41: note: expanded from macro 'rb_stdin'
#define rb_stdin              rb_gv_get("$stdin")
                                        ^
lxc.c:576:11: note: to match this '('
/usr/local/rvm/rubies/rbx-2.5.2/vm/include/capi/ruby/ruby.h:374:40: note: expanded from macro 'rb_stdin'
#define rb_stdin              rb_gv_get("$stdin")
                                       ^
lxc.c:576:21: error: expected parameter declarator
    VALUE rb_stdin, rb_stdout, rb_stderr;
                    ^
/usr/local/rvm/rubies/rbx-2.5.2/vm/include/capi/ruby/ruby.h:375:41: note: expanded from macro 'rb_stdout'
#define rb_stdout             rb_gv_get("$stdout")
                                        ^
lxc.c:576:21: error: expected ')'
/usr/local/rvm/rubies/rbx-2.5.2/vm/include/capi/ruby/ruby.h:375:41: note: expanded from macro 'rb_stdout'
#define rb_stdout             rb_gv_get("$stdout")
                                        ^
lxc.c:576:21: note: to match this '('
/usr/local/rvm/rubies/rbx-2.5.2/vm/include/capi/ruby/ruby.h:375:40: note: expanded from macro 'rb_stdout'
#define rb_stdout             rb_gv_get("$stdout")
                                       ^
lxc.c:576:32: error: expected parameter declarator
    VALUE rb_stdin, rb_stdout, rb_stderr;
                               ^
/usr/local/rvm/rubies/rbx-2.5.2/vm/include/capi/ruby/ruby.h:376:41: note: expanded from macro 'rb_stderr'
#define rb_stderr             rb_gv_get("$stderr")
                                        ^
lxc.c:576:32: error: expected ')'
/usr/local/rvm/rubies/rbx-2.5.2/vm/include/capi/ruby/ruby.h:376:41: note: expanded from macro 'rb_stderr'
#define rb_stderr             rb_gv_get("$stderr")
                                        ^
lxc.c:576:32: note: to match this '('
/usr/local/rvm/rubies/rbx-2.5.2/vm/include/capi/ruby/ruby.h:376:40: note: expanded from macro 'rb_stderr'
#define rb_stderr             rb_gv_get("$stderr")
                                       ^
lxc.c:649:14: error: expression is not assignable
    rb_stdin = rb_hash_aref(rb_opts, SYMBOL("stdin"));
    ~~~~~~~~ ^
lxc.c:656:15: error: expression is not assignable
    rb_stdout = rb_hash_aref(rb_opts, SYMBOL("stdout"));
    ~~~~~~~~~ ^
lxc.c:663:15: error: expression is not assignable
    rb_stderr = rb_hash_aref(rb_opts, SYMBOL("stderr"));
    ~~~~~~~~~ ^
9 errors generated.
make: *** [lxc.o] Error 1

make failed, exit code 2

Hello Bar

Could you check if you're able to build ruby-lxc with rubinius from git HEAD? I've just commited a change that should fix the error you're seeing.

Cheers!

Indeed :)

gem install ruby-lxc-1.2.0.gem 
Building native extensions.  This could take a while...
Successfully installed ruby-lxc-1.2.0
Parsing documentation for ruby-lxc-1.2.0
Installing ri documentation for ruby-lxc-1.2.0
Done installing documentation for ruby-lxc after 0 seconds
1 gem installed

Seems to work great :)

rubinius 2.5.2 (2.1.0 7a5b05b1 2015-01-30 3.4 JI) [x86_64-linux-gnu]

Cool, I'll try to release a new version later today.

On Mon, Jan 4, 2016 at 11:28 AM, Bar Hofesh notifications@github.com
wrote:

Indeed :)

gem install ruby-lxc-1.2.0.gem
Building native extensions. This could take a while...
Successfully installed ruby-lxc-1.2.0
Parsing documentation for ruby-lxc-1.2.0
Installing ri documentation for ruby-lxc-1.2.0
Done installing documentation for ruby-lxc after 0 seconds
1 gem installed

Seems to work great :)

rubinius 2.5.2 (2.1.0 7a5b05b1 2015-01-30 3.4 JI) [x86_64-linux-gnu]


Reply to this email directly or view it on GitHub
#37 (comment).

Amazing, thanks :)

@andrenth It seems we hit a little bit more problems:

Could not open library /usr/local/rvm/gems/rbx-2.5.2/extensions/x86_64-linux/2.1/ruby-lxc-1.2.0/lxc/lxc.so - /usr/local/rvm/gems/rbx-2.5.2/extensions/x86_64-linux/2.1/ruby-lxc-1.2.0/lxc/lxc.so: undefined symbol: lxc_strerror (LoadError::InvalidExtensionError)

Backtrace:

          Rubinius::NativeMethod.load_extension at kernel/common/native_method.rb:26
              Rubinius::CodeLoader#load_library at kernel/delta/code_loader.rb:234
                   Rubinius::CodeLoader#require at kernel/common/code_loader.rb:130
                   Rubinius::CodeLoader.require at kernel/common/code_loader.rb:241
  Kernel(Object)#gem_original_require (require) at kernel/common/kernel.rb:755
                         Kernel(Object)#require at /usr/local/rvm/rubies/rbx-2.5.2/site/rubygems/core_ext/kernel_require.rb:54
                              Object#__script__ at /usr/local/rvm/gems/rbx-2.5.2/gems/ruby-lxc-1.2.0/lib/lxc.rb:2
                   Rubinius::CodeLoader.require at kernel/common/code_loader.rb:247
  Kernel(Object)#gem_original_require (require) at kernel/common/kernel.rb:755
                         Kernel(Object)#require at /usr/local/rvm/rubies/rbx-2.5.2/site/rubygems/core_ext/kernel_require.rb:128
                              Object#__script__ at sphere_run.rb:13
               Rubinius::CodeLoader#load_script at kernel/delta/code_loader.rb:66
               Rubinius::CodeLoader.load_script at kernel/delta/code_loader.rb:152
                        Rubinius::Loader#script at kernel/loader.rb:655
                          Rubinius::Loader#main at kernel/loader.rb:809

Caused by: Could not open library /usr/local/rvm/gems/rbx-2.5.2/extensions/x86_64-linux/2.1/ruby-lxc-1.2.0/lxc/lxc.so - /usr/local/rvm/gems/rbx-2.5.2/extensions/x86_64-linux/2.1/ruby-lxc-1.2.0/lxc/lxc.so: undefined symbol: lxc_strerror (LoadError)

       Rubinius::FFI::DynamicLibrary#initialize at kernel/platform/library.rb:370
          Rubinius::NativeMethod.load_extension at kernel/common/native_method.rb:24
              Rubinius::CodeLoader#load_library at kernel/delta/code_loader.rb:234
                   Rubinius::CodeLoader#require at kernel/common/code_loader.rb:130
                   Rubinius::CodeLoader.require at kernel/common/code_loader.rb:241
  Kernel(Object)#gem_original_require (require) at kernel/common/kernel.rb:755
                         Kernel(Object)#require at /usr/local/rvm/rubies/rbx-2.5.2/site/rubygems/core_ext/kernel_require.rb:54
                              Object#__script__ at /usr/local/rvm/gems/rbx-2.5.2/gems/ruby-lxc-1.2.0/lib/lxc.rb:2
                   Rubinius::CodeLoader.require at kernel/common/code_loader.rb:247
  Kernel(Object)#gem_original_require (require) at kernel/common/kernel.rb:755
                         Kernel(Object)#require at /usr/local/rvm/rubies/rbx-2.5.2/site/rubygems/core_ext/kernel_require.rb:128
                              Object#__script__ at sphere_run.rb:13
               Rubinius::CodeLoader#load_script at kernel/delta/code_loader.rb:66
               Rubinius::CodeLoader.load_script at kernel/delta/code_loader.rb:152
                        Rubinius::Loader#script at kernel/loader.rb:655
                          Rubinius::Loader#main at kernel/loader.rb:809

Do you have liblxc/liblxc-dev installed? Which version? Do you get the error right after require 'lxc'?

It seems to happen exactly after 'require lxc'

pry
[1] pry(main)> require 'lxc'
LoadError::InvalidExtensionError: Could not open library /usr/local/rvm/gems/rbx-2.5.2/extensions/x86_64-linux/2.1/ruby-lxc-1.2.0/lxc/lxc.so - /usr/local/rvm/gems/rbx-2.5.2/extensions/x86_64-linux/2.1/ruby-lxc-1.2.0/lxc/lxc.so: undefined symbol: lxc_strerror
from kernel/common/native_method.rb:26:in `load_extension'
[2] pry(main)> 

lxc-checkconfig:

lxc-checkconfig 
Kernel configuration not found at /proc/config.gz; searching...
Kernel configuration found at /boot/config-3.13.0-74-generic
--- Namespaces ---
Namespaces: enabled
Utsname namespace: enabled
Ipc namespace: enabled
Pid namespace: enabled
User namespace: enabled
Network namespace: enabled
Multiple /dev/pts instances: enabled

--- Control groups ---
Cgroup: enabled
Cgroup clone_children flag: enabled
Cgroup device: enabled
Cgroup sched: enabled
Cgroup cpu account: enabled
Cgroup memory controller: enabled
Cgroup cpuset: enabled

--- Misc ---
Veth pair device: enabled
Macvlan: enabled
Vlan: enabled
Bridges: enabled
Advanced netfilter: enabled
CONFIG_NF_NAT_IPV4: enabled
CONFIG_NF_NAT_IPV6: enabled
CONFIG_IP_NF_TARGET_MASQUERADE: enabled
CONFIG_IP6_NF_TARGET_MASQUERADE: enabled
CONFIG_NETFILTER_XT_TARGET_CHECKSUM: enabled

--- Checkpoint/Restore ---
checkpoint restore: enabled
CONFIG_FHANDLE: enabled
CONFIG_EVENTFD: enabled
CONFIG_EPOLL: enabled
CONFIG_UNIX_DIAG: enabled
CONFIG_INET_DIAG: enabled
CONFIG_PACKET_DIAG: enabled
CONFIG_NETLINK_DIAG: enabled
File capabilities: enabled

Note : Before booting a new kernel, you can check its configuration
usage : CONFIG=/path/to/config /usr/bin/lxc-checkconfig

I'm running Ubuntu 14.04:

apt-get install liblxc1 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
liblxc1 is already the newest version.

apt-get install lxc-dev 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
lxc-dev is already the newest version.

Also on the same machine with ruby-2.2 it works great.

It seems that the symbol for lxc_strerror is indeed not present in liblxc.so. strings /usr/lib/x86_64-linux-gnu/liblxc.so | grep lxc_strerror returns empty for me.

I'm not sure if this is by design or if it's a mistake, since the function is mentioned in lxc.h.

Not sure why the error doesn't happen in MRI.

@andrenth Using MRI I get this:

rvm use ruby
Using /usr/local/rvm/gems/ruby-2.2.1
[1] pry(main)> require 'lxc'
/usr/local/rvm/gems/ruby-2.2.1/gems/ruby-lxc-1.2.0/lib/lxc/version.rb:2: warning: already initialized constant LXC::VERSION
/tmp/ruby-lxc/lib/lxc/version.rb:2: warning: previous definition of VERSION was here
=> true
[2] pry(main)> 

There seems to be something weird with your setup wrt this last error. The warning message mentions version.rb from the gem installation and also from a location in /tmp.

Indeed, it worked on a vanilla installation.

Thanks.