asciidoctor / asciidoctor-mathematical

An extension for Asciidoctor that converts the content of STEM blocks and inline macros using Mathematical.
MIT License
49 stars 44 forks source link

Error loading liblasem in Ubuntu #30

Closed jorgeas80 closed 5 years ago

jorgeas80 commented 7 years ago

I installed the package via gem, as proposed. Now, trying to generate a PDF, I'm getting this error (in Ubuntu 16.04 with Ruby 2.3.1p112)

/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': liblasem.so: cannot open shared object file: No such file or directory - /var/lib/gems/2.3.0/gems/mathematical-1.6
.9/lib/mathematical/mathematical.so (LoadError)
        from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /var/lib/gems/2.3.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
        from /var/lib/gems/2.3.0/gems/mathematical-1.6.9/lib/mathematical.rb:1:in `<top (required)>'
        from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /var/lib/gems/2.3.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
        from /var/lib/gems/2.3.0/gems/asciidoctor-mathematical-0.2.2/lib/asciidoctor-mathematical/extension.rb:23:in `process'
        from /usr/lib/ruby/vendor_ruby/asciidoctor/document.rb:478:in `[]'
        from /usr/lib/ruby/vendor_ruby/asciidoctor/document.rb:478:in `block in parse'
        from /usr/lib/ruby/vendor_ruby/asciidoctor/document.rb:477:in `each'
        from /usr/lib/ruby/vendor_ruby/asciidoctor/document.rb:477:in `parse'
        from /usr/lib/ruby/vendor_ruby/asciidoctor.rb:1344:in `load'
        from /usr/lib/ruby/vendor_ruby/asciidoctor.rb:1462:in `convert'
        from /usr/lib/ruby/vendor_ruby/asciidoctor/cli/invoker.rb:94:in `block in invoke!'
        from /usr/lib/ruby/vendor_ruby/asciidoctor/cli/invoker.rb:86:in `each'
        from /usr/lib/ruby/vendor_ruby/asciidoctor/cli/invoker.rb:86:in `invoke!'
        from /var/lib/gems/2.3.0/gems/asciidoctor-pdf-1.5.0.alpha.15/bin/asciidoctor-pdf:31:in `<top (required)>'
        from /usr/local/bin/asciidoctor-pdf:23:in `load'
        from /usr/local/bin/asciidoctor-pdf:23:in `<main>'

I installed mathematical after asciidoctor-mathematical, and I think that's the problem. I probably need to rebuild asciidoctor-mathematical again, against the installed mathematical package, but I can't do it. I uninstall and install again asciidoctor-mathematical, but it takes just a couple of seconds. So, I guess is using any type of cache. I also tried with gem cleanup, to clean that cache, and with gem build, using the .gem file in this repo, but no effect. Getting the same error.

By the way, the missing file, liblasem.so, already exists:

/var/lib/gems/2.3.0/gems/mathematical-1.6.9/ext/mathematical/lasem/build/liblasem.so
/var/lib/gems/2.3.0/gems/mathematical-1.6.9/ext/mathematical/lib/liblasem.dylib
/var/lib/gems/2.3.0/gems/mathematical-1.6.9/ext/mathematical/lib/liblasem.so

Any clues?

ProgramFan commented 7 years ago

It seems that mathematical is not correctly installed. What is the result when you reinstall mathematical?

jorgeas80 commented 7 years ago

Same problem. Uninstalled and installed mathematical again. But, like happens with asciidoctor-mathematical, installing it again just takes a couple of seconds. The first time I installed both libraries, it took several minutes. So, I suspect the gem is using compiled packages all the time. And I need to force a recompile.

Anyway, I installed another version of Ruby with rvm, and installed both libraries in the right order. It worked. So, I think it's fine (it was my fault).

tweenk commented 7 years ago

I encountered the same error on Ubuntu 16.04.2, reinstalling the packages in a different order does not seem to help. What did help was the following:

sudo ln -s /var/lib/gems/2.3.0/gems/mathematical-1.6.9/ext/mathematical/lib/liblasem.so /usr/lib/liblasem.so
sudo ldconfig

Looks like the path to liblasem.so is not configured properly for some reason.

ProgramFan commented 7 years ago

The error occurs on Fedora 26, too. But it is an error in mathematical itself. tweenk's @tweenk approach works. Another approach would be change mathematical to hard code the shared object path: (https://github.com/gjtorikian/mathematical/blob/39167da8e364f840d176cedaf3cf68641da39953/ext/mathematical/extconf.rb#L91)

$LIBS << '-Wl,-rpath,#{LASEM_LIB_DIR} -llasem'

Would someone report directly to mathematical?

ProgramFan commented 7 years ago

@gjtorikian Would you please check in mathematical?

gjtorikian commented 7 years ago

I can make that $LIBS change ('-Wl,-rpath,#{LASEM_LIB_DIR} -llasem') if you're certain it works. I don't have a Fedora machine to test with unfortunately.

ProgramFan commented 7 years ago

@gjtorikian I have tested it on Fedora 26 and use LIBS << ' -Wl,-rpath,#{LASEM_LIB_DIR} -llasem' does fix the problem by embeding the library path in mathematical.so. So would you please make a fix in mathematical?

oM3fC commented 6 years ago

Update on #32 asciidoctor-mathematical-0.2.2 will not recognize mathematical-1.6.9

Success. PDF renders latexmath and compiles without error.

ln -s /var/lib/gems/2.3.0/gems/mathematical-1.6.9/lib/mathematical/mathematical.so /usr/lib/mathematical.so ln -s /var/lib/gems/2.3.0/gems/mathematical-1.6.9/ext/mathematical/lib/liblasem.so /usr/lib/liblasem.so

mojavelinux commented 5 years ago

I don't have a Fedora machine to test with unfortunately.

This is not really an excuse in the age of Docker:

docker run --entrypoint=bash -it --rm fedora
gjtorikian commented 5 years ago

Yes, which is why this issue was fixed over a year ago.

mojavelinux commented 5 years ago

In that event, a belated :tada: is in order! Thanks!