missing nanomsg.bundle

Issue #2 resolved
Don Park created an issue

lib/nanomsg.rb has

require 'nanomsg.bundle'

'nanomsg.bundle' does not appear to be in this repo. Is this file missing from the repo or is it supposed to be generated?

Comments (15)

  1. Don Park reporter

    This is still a problem with 0.3.1 (continuing the bash session from ticket #1, after nanomsg successfully installs)

    donp@wafer:~/nn$ cat > go.rb
    require 'nanomsg'
    donp@wafer:~/nn$ bundle exec ruby go.rb
    /home/donp/nn/gems/ruby/2.0.0/gems/nanomsg-0.3.1/lib/nanomsg.rb:3:in `require': cannot load such file -- nanomsg.bundle (LoadError)
        from /home/donp/nn/gems/ruby/2.0.0/gems/nanomsg-0.3.1/lib/nanomsg.rb:3:in `<top (required)>'
        from go.rb:1:in `require'
        from go.rb:1:in `<main>'
    donp@wafer:~/nn$ ruby -v
    ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
    donp@wafer:~/nn$ uname -a
    Linux wafer 3.8.0-27-generic #40-Ubuntu SMP Tue Jul 9 00:17:05 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
    donp@wafer:~/nn$ 
    
  2. Kaspar Schiess repo owner

    This should be fixed in 0.3.2.

    If you still have trouble loading the library, try running 'ldconfig' as root and then reinstall the gem. This fixed lingering problems here. Normally, after installing nanomsg, you would run ldconfig directly, but hey, who reads readmes, right?

    Let me know how that works out, I'll be happy if the gem works on more than just my machines...

  3. Don Park reporter

    Its close to working. It looks like there is some naming confusing between nanomsg.so and libnanomsg.so.0

    donp@wafer:~/nn$ bundle update
    Fetching gem metadata from https://rubygems.org/..
    Resolving dependencies...
    Installing nanomsg (0.3.2) 
    Using bundler (1.3.5) 
    Your bundle is updated!
    donp@wafer:~/nn$ cat go.rb
    require 'nanomsg'
    donp@wafer:~/nn$ bundle exec ruby go.rb 
    /home/donp/nn/gems/ruby/2.0.0/gems/nanomsg-0.3.2/lib/nanomsg.rb:2:in `require': libnanomsg.so.0: cannot open shared object file: No such file or directory - /home/donp/nn/gems/ruby/2.0.0/gems/nanomsg-0.3.2/ext/nanomsg.so (LoadError)
        from /home/donp/nn/gems/ruby/2.0.0/gems/nanomsg-0.3.2/lib/nanomsg.rb:2:in `<top (required)>'
        from go.rb:1:in `require'
        from go.rb:1:in `<main>'
    

    I tried an experiment by adding a symlink and putting the path in LD_LIBRARY_PATH and got:

    donp@wafer:~/nn$ cd /home/donp/nn/gems/ruby/2.0.0/gems/nanomsg-0.3.2/ext/
    donp@wafer:~/nn/gems/ruby/2.0.0/gems/nanomsg-0.3.2/ext$ ln -s nanomsg.so libnanomsg.so.0
    donp@wafer:~/nn/gems/ruby/2.0.0/gems/nanomsg-0.3.2/ext$ cd ~/nn
    donp@wafer:~/nn$ LD_LIBRARY_PATH=//home/donp/nn/gems/ruby/2.0.0/gems/nanomsg-0.3.2/ext/ bundle exec ruby go.rb 
    ruby: symbol lookup error: /home/donp/nn/gems/ruby/2.0.0/gems/nanomsg-0.3.2/ext/nanomsg.so: undefined symbol: nn_symbol
    
  4. Kaspar Schiess repo owner

    That looks exactly like the error I had when I didn't run 'ldconfig'. Did you run it? As root?

    If yes: Maybe try compiling a simple C program that links towards libnanomsg. Does that work?

  5. Don Park reporter

    I dont think ldconfig is the answer, even if it did work, I've never heard of a gem needing to do that.

    I was comparing this gem to http://tenderlovemaking.com/2009/12/18/writing-ruby-c-extensions-part-1.html

    and I believe the fix is in lib/nanomsg.rb replacing the complicated require with require 'nanomsg/nanomsg'

    there is no need to build the path to the ../ext dir because the extension build process is coping nanomsg.so into lib/nanomsg.so

    also whats funny is ruby is looking inside the ext directory anyways, check out this strace output.

    open("/home/donp/nn/gems/ruby/2.0.0/gems/nanomsg-0.3.2/lib/nanomsg/nanomsg.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
    open("/home/donp/nn/gems/ruby/2.0.0/gems/nanomsg-0.3.2/ext/nanomsg/nanomsg.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
    

    the other piece in the extensions tutorial that is different is in ext/extconf.rb it uses the package name twice. modifying extconf.rb to this create_makefile('nanomsg/nanomsg')

    I believe will create lib/nanomsg/nanomsg.so instead of lib/nanomsg.so, allowing ruby to find the library.

    I would try this myself but the repo is missing manifest.txt so I cant build the gem. Can you add that file?

  6. Don Park reporter

    1) if the base library was not found, the error message would be different

    2) ldconfig refreshes the contents of the existing ld search paths, I have nanomsg installed into a custom directory.

    the error that indicates the base library is not being found is fixed by using LD_LIBRARY_PATH=/custom/nanomsg/lib , which I have tried.

  7. Kaspar Schiess repo owner

    On Ubuntu 12.04, clean installation:

    1. All the install instructions of nanomsg, including ldconfig
    2. gem install nanomsg
    3. irb -r nanomsg works

    I am closing this. If you want me to work on the 'bug', then please open a new ticket specifying operating system, ruby install method (package system or rvm) and other details like the mkmf.log and the configure.log of nanomsg gem / nanomsg library respective.

    Your hypothesis would be easy to test: Just modify the offending require in place (gem which nanomsg...). Or run ldconfig.

  8. Don Park reporter

    I did edit lib/nanomsg.rb in place, thats how I got the strace output which revealed that ruby was looking for lib/nanomsg/nanomsg.so.

    What I couldnt do was get lib/nanomsg.so to live in lib/nanomsg/nanomsg.so without building the gem. The repo is currently not buildable with the missing manifest.txt - is there a way that can be generated locally, or checkd in?

    So I took your advice of modifying it in place. I moved the .so file. It worked (and is not related to updating ldconfig's cache). I believe updating ext/extconf.rb is the fix.

    donp@wafer:~/nn$ mv gems/ruby/2.0.0/gems/nanomsg-0.3.2/lib/nanomsg.so gems/ruby/2.0.0/gems/nanomsg-0.3.2/lib/nanomsg/
    donp@wafer:~/nn$ LD_LIBRARY_PATH=/usr/local/nanomsg/0.1-alpha/lib/ bundle exec ruby go.rb
    donp@wafer:~/nn$  ( no error message )
    

    go.rb simply contains "require 'nanomsg'"

  9. Don Park reporter

    I just cleaned things up in my working directory and it looks like it is working in 0.3.2 using LD_LIBRARY_PATH. It would be cleaner to have nanomsg.so in lib/nanomsg/nanomsg.so but it does seem to be loading.

    thanks. Don

  10. Kaspar Schiess repo owner

    The trouble you're having stems from nanomsg.so not finding libnanomsg.so. Symlinking the former to the latter just confuses the issue. The LD_LIBRARY_PATH you would have to set is the one pointing to libnanomsg.so.

    It is against convention to have C extensions below lib; the guide you link to above also doesn't do that.

    The manifest is checked in, so feel free to hack away for your local experiments.

  11. Don Park reporter

    The symlink was definitely a confusion. Thanks for pointing that out.

    The guide does indeed put the C extension below lib. Check out the directory tree in "Finishing Up", it shows lib/stree/stree.bundle. This makes sense because require 'stree' would be ambiguous if lib/stree.rb and lib/stree.so both existed.

    The resultant tree for nanomsg has both lib/nanomsg.rb and lib/nanomsg.so. While it works, I cant tell if its working because of luck (alphabetical order?) or if ruby looks for .rb first.

    I tried changing the extconf.rb file to create_makefile('nanomsg/nanomsg') but it still generates lib/nanomsg.so instead of lib/nanomsg/nanomsg.so. oh well.

  12. Log in to comment