metanorma / metanorma-docker

Docker container for running the Metanorma toolchain
https://www.metanorma.com
5 stars 3 forks source link

Metanorma compilation shows `[relaton] Error: backend relaton_3gpp not present` #125

Closed ronaldtse closed 2 years ago

ronaldtse commented 2 years ago

I'm getting this error when compiling a document.

[relaton] Error: backend relaton_3gpp not present
ronaldtse commented 2 years ago

@andrew2net do you know why this is the case?

andrew2net commented 2 years ago

@ronaldtse how to reproduce the error? Is relaton-3gpp installed?

ronaldtse commented 2 years ago

If you run a document through Metanorma's docker container, you will see it. You can find instructions to run the container here: https://www.metanorma.org/install/docker/

ronaldtse commented 2 years ago

@andrew2net actually it has nothing to do with Docker -- a normal install of Metanorma already shows this line:

[relaton] Info: detecting backends:
[relaton] Error: backend relaton_3gpp not present
...
ronaldtse commented 2 years ago

Maybe this has to do with "relaton_3gpp" vs "relaton-3gpp" name?

andrew2net commented 2 years ago

@ronaldtse the name relaton_3gpp is correct. It seems an error occurs when the gem is required. It doesn't happen on my comp so we need to explore the error with Docker. I'll add a backtrace and an error message in the relaton gem to the log. So we can see what happened when the relaton-3gpp loading.

ronaldtse commented 2 years ago

Here's the reason for the failure:

irb(main):002:0> require 'relaton_3gpp'
/Users/me/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/relaton-3gpp-1.10.1/lib/relaton_3gpp/data_fetcher.rb:2:in `require': cannot load such file -- net/ftp (LoadError)                                                         
        from /Users/me/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/relaton-3gpp-1.10.1/lib/relaton_3gpp/data_fetcher.rb:2:in `<top (required)>'
        from /Users/me/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/relaton-3gpp-1.10.1/lib/relaton_3gpp.rb:12:in `require_relative'
        from /Users/me/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/relaton-3gpp-1.10.1/lib/relaton_3gpp.rb:12:in `<top (required)>'
        from (irb):2:in `require'                                         
        from (irb):2:in `<main>'                                          
        from /Users/me/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bundler-2.3.4/lib/bundler/cli/console.rb:19:in `run'
        from /Users/me/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bundler-2.3.4/lib/bundler/cli.rb:514:in `console'
        from /Users/me/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bundler-2.3.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
        from /Users/me/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bundler-2.3.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'                                                                         
        from /Users/me/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bundler-2.3.4/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
        from /Users/me/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bundler-2.3.4/lib/bundler/cli.rb:31:in `dispatch'
        from /Users/me/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bundler-2.3.4/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
    from /Users/me/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bundler-2.3.4/lib/bundler/cli.rb:25:in `start'
    from /Users/me/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bundler-2.3.4/exe/bundle:48:in `block in <top (required)>'
    from /Users/me/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bundler-2.3.4/lib/bundler/friendly_errors.rb:103:in `with_friendly_errors'
    from /Users/me/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bundler-2.3.4/exe/bundle:36:in `<top (required)>'
    ... 2 levels...
irb(main):003:0> require 'relaton_cie'
=> true

Looks like the "net/ftp" module is missing.

I'm on Ruby 3.1.

andrew2net commented 2 years ago

I supposed the net-ftp gem should be installed by default. Semms it isn't in Ruby 3.1. Added the dependency to the relaton-3gpp gemspec.

ronaldtse commented 2 years ago

@andrew2net can we only require net/ftp gem for a Ruby version that doesn’t have it? Not sure how the gemspec does that.

andrew2net commented 2 years ago

@ronaldtse all the dependencies from a gemspec are installed when a gem is installed. It works as Gemfile but it allows to use published gems only. The require command a load gem into memory. We can require a dependence when we need to use it but it should be installed in advance.

ronaldtse commented 2 years ago

@andrew2net there's a misunderstanding here.

Ruby < 3.0 includes net/ftp as an "internal gem", so there is no need to include it in gemspec.

Ruby >= 3.0 does not include the net/ftp gem at all (it has been removed from Ruby vanilla), so we need it in gemspec.

I'm asking whether there is a way to specify a dependency depending on the Ruby version. I just don't know what the behavior would be if the Ruby version is < 3.0 but the gemspec requires 'net/ftp'.

andrew2net commented 2 years ago

@ronaldtse if dependency already exists then gemspec does nothing. We don't need to do anything to specify dependency depending on the Ruby version.

ronaldtse commented 2 years ago

@andrew2net agreed, and I tried installing the net-ftp gem on 2.7.3, which just installs the latest one. No problem then.

I also updated the bundle and the error is indeed fixed. Thanks.