Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iruby does not install/work with Ubuntu snap install of ruby? #310

Open
wesinator opened this issue Sep 27, 2021 · 3 comments
Open

iruby does not install/work with Ubuntu snap install of ruby? #310

wesinator opened this issue Sep 27, 2021 · 3 comments

Comments

@wesinator
Copy link

wesinator commented Sep 27, 2021

Thanks for the work on iruby

TL,DR: Does anyone know how to get iruby to work with the snap install of ruby?
(the snap is an official build from rubylang dev team)

So I have Ubuntu 20.04 running ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux] ,
installed from the official snap package https://snapcraft.io/ruby

I followed the install instructions from https://github.com/SciRuby/iruby#ubuntu-17, without apt install ruby packages since they and gem/bundle are already installed from the snap.

/snap/bin/gem
3.2.22

When I try to run iruby:

$ iruby

Command 'iruby' not found, did you mean:

$ find . -name iruby

./.gem/bin/iruby
./.gem/ruby/3.0.0/bin/iruby
./.gem/ruby/3.0.0/doc/iruby-0.7.4/ri/lib/iruby
./.gem/ruby/3.0.0/gems/iruby-0.7.4/bin/iruby
./.gem/ruby/3.0.0/gems/iruby-0.7.4/test/iruby
./.gem/ruby/3.0.0/gems/iruby-0.7.4/lib/iruby
./.gem/doc/iruby-0.7.4/ri/lib/iruby
./.gem/gems/iruby-0.7.4/bin/iruby
./.gem/gems/iruby-0.7.4/test/iruby
./.gem/gems/iruby-0.7.4/lib/iruby

I then ran ./.gem/bin/iruby register --force

After that ruby is an option in jupyter notebook, jupyter lab, but code highlighting doesn't work , and the ruby code cell run indefinitely without output:
image

Kernel started: b29eec45-b6f0-4247-9738-ced8cd296a6b
W, [2021-09-20T08:45:53.031339 #5168]  WARN -- : Could not load bundler: Could not locate Gemfile or .bundle/ directory
Unable to load this gem. The libzmq library (or DLL) could not be found.
If this is a Windows platform, make sure libzmq.dll is on the PATH.
If the DLL was built with mingw, make sure the other two dependent DLLs,
libgcc_s_sjlj-1.dll and libstdc++6.dll, are also on the PATH.
For non-Windows platforms, make sure libzmq is located in this search path:
["/home/w/.gem/gems/ffi-rzmq-core-1.0.7/lib/ffi-rzmq-core/../../ext/libzmq.so", "/home/w/.local/bin/libzmq.so", "/usr/local/sbin/libzmq.so", "/usr/local/bin/libzmq.so", "/usr/sbin/libzmq.so", "/usr/bin/libzmq.so", "/sbin/libzmq.so", "/bin/libzmq.so", "/usr/games/libzmq.so", "/usr/local/games/libzmq.so", "/snap/bin/libzmq.so", "/snap/ruby/220/lib/libzmq.so", "/usr/local/lib/libzmq.so", "/opt/local/lib/libzmq.so", "/usr/lib64/libzmq.so"]
W, [2021-09-20T08:45:53.061577 #5168]  WARN -- : parent process poller thread started.

zeromq is installed through libzmq3-dev

Also, after quitting iruby, (ctrl-c + y to exit), it seemed there was still a ruby child process consuming CPU.

Thanks,

@kojix2
Copy link
Member

kojix2 commented Sep 27, 2021

Hi!
It seems that ffi-rzmq cannot find libzmq.so.

Does the following commands return the same error?
irb -r ffi-rzmq
irb -r ffi-rzmq-core

Note: where ffi-rzmq-core looks for libzmq.so

@wesinator
Copy link
Author

Yes

$ irb -r ffi-rzmq
Unable to load this gem. The libzmq library (or DLL) could not be found.
If this is a Windows platform, make sure libzmq.dll is on the PATH.
If the DLL was built with mingw, make sure the other two dependent DLLs,
libgcc_s_sjlj-1.dll and libstdc++6.dll, are also on the PATH.
For non-Windows platforms, make sure libzmq is located in this search path:
["/home/w/.gem/gems/ffi-rzmq-core-1.0.7/lib/ffi-rzmq-core/../../ext/libzmq.so", "/home/w/.local/bin/libzmq.so", "/usr/local/sbin/libzmq.so", "/usr/local/bin/libzmq.so", "/usr/sbin/libzmq.so", "/usr/bin/libzmq.so", "/sbin/libzmq.so", "/bin/libzmq.so", "/usr/games/libzmq.so", "/usr/local/games/libzmq.so", "/snap/bin/libzmq.so", "/snap/ruby/220/lib/libzmq.so", "/usr/local/lib/libzmq.so", "/opt/local/lib/libzmq.so", "/usr/lib64/libzmq.so"]
/snap/ruby/220/lib/ruby/3.0.0/irb/init.rb:376: warning: LoadError: The libzmq library (or DLL) could not be loaded

still happens after

$ gem install ffi-rzmq
Successfully installed ffi-rzmq-2.0.7
Parsing documentation for ffi-rzmq-2.0.7

Successfully installed ffi-rzmq-core-1.0.7
Parsing documentation for ffi-rzmq-core-1.0.7
Done installing documentation for ffi-rzmq-core after 0 seconds
1 gem installed

@kojix2
Copy link
Member

kojix2 commented Sep 28, 2021

In ffi-rzmq-core, the search for libzmq.so looks like this.
ZMQ_LIB_PATHS is not actually used. So, it is basically the same as the following code.

require 'ffi'

module LibZMQ
  extend FFI::Library
  p ffi_lib(["libzmq"]) # [#<FFI::DynamicLibrary:0x000055958f13e5c8 @name="libzmq.so">]
end

Here, the string libzmq is passed instead of the file path.
Maybe the search for shared libraries is done by libffi side, not by Ruby side.

Do you get any errors running the code above? (You will probably get an error.)

The ffi dlopen seems to search for shared libraries under /usr/lib.
https://man7.org/linux/man-pages/man3/dlopen.3.html

Is libzmq.so installed in the usual place?

`dpkg -L libzmq3-dev | grep libzmq.so`
# /usr/lib/x86_64-linux-gnu/libzmq.so

If you have libzmq.so under /usr/lib
it may be worth updating libffi-dev and reinstalling the ffi gem (requires compilation of the C extension).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants