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

Error loading gem from metamora-cli #83

Closed
bougyman opened this issue Dec 2, 2020 · 8 comments · Fixed by metanorma/metanorma-cli#230
Closed

Error loading gem from metamora-cli #83

bougyman opened this issue Dec 2, 2020 · 8 comments · Fixed by metanorma/metanorma-cli#230
Assignees
Labels
bug Something isn't working

Comments

@bougyman
Copy link

bougyman commented Dec 2, 2020

When I attempt the sample workflow, I receive the following message:

~/g/mn-samples-ribose/sources/nistir-8214a
 % metanorma --type ribose nistir-8214a-comments.adoc
[metanorma] Error: loading gem `metanorma-ribose` failed. Exiting.

Metanorma version(s):

Metanorma 1.2.1
Metanorma::Cli 1.3.8.1
Metanorma::Standoc 1.6.3/IsoDoc 1.2.8
Metanorma::ISO 1.5.12
Metanorma::Iec 1.2.9
Metanorma::Ietf 2.2.4
Metanorma::Gb 1.5.8
Metanorma::Generic 1.7.3
Metanorma::CC 1.6.0
Metanorma::Csa 1.6.7
Metanorma::IHO 0.2.7
Metanorma::M3AAWG 1.6.0
Metanorma::UN 0.5.7
Metanorma::NIST 1.2.7
Metanorma::Ogc 1.2.7
Metanorma::ITU 1.2.7

And metanorma-ribose verion:

% gem which metanorma-ribose
/Users/<snip>/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/metanorma-ribose-1.6.8/lib/metanorma-ribose.rb

I've attempted to breakpoint metanorma-cli to see where the problem is, but have not succeeded yet. I can load the metanorma-ribose gem fine with ruby -r metanorma-ribose / pry -r metanorma-ribose.

@ronaldtse
Copy link
Contributor

@bougyman thanks for raising this issue! This may indicate a bug in the CLI loading, which I will leave it to @opoudjis to help you triage this.

@ronaldtse ronaldtse added the bug Something isn't working label Dec 2, 2020
@opoudjis
Copy link
Contributor

opoudjis commented Dec 4, 2020

As i've said in my email, I may not be able to pin this down in the general case.

But there's a straightforward way to get this working, at least for me:

Edit the Gemfile of the root of the mn-samples-ribose directory, to add:

gem metanorma-ribose

And then run bundle exec metanorma ...

Let me know if that works.

Ribose is not included in the gemspec of metanorma-cli, and that is deliberate: we aren't able to add all possible flavours in our official release, because some may be created by third parties.

@bougyman
Copy link
Author

bougyman commented Dec 4, 2020

Thanks, using the bundle exec on the cloned git repo did indeed work, but metanorma-cli as an installed gem does not work with the type ribose, even with the metanorma-ribose gem installed as in my initial comment.

@opoudjis
Copy link
Contributor

opoudjis commented Dec 7, 2020

@abunashir, could you please investigate? My dev environment is too dirty for me to, and this is beyond my expertise.

@ronaldtse
Copy link
Contributor

ronaldtse commented Dec 7, 2020

Indeed @bougyman this has been an issue. The expectation is for metanorma-cli to automatically load the proper version of metanorma-whatever (if installed) if it has been requested in the type argument or inside the document as attribute (mn-document-class).

@abunashir can you help with this? As you remember, my previous approach with searching through gems gives very poor performance due to the way Ruby loops through gems/versions...

This task is related to metanorma/metanorma-cli#81

@abunashir
Copy link
Member

Sure, I will look into it and get back to you guys soon 👍

@abunashir
Copy link
Member

abunashir commented Jan 4, 2021

TLDR;

Hey there, my apologies for the long delay. I had a look into this today and looks like there seems to be some issue with the gem dependencies between metanorma-ribose and metanorma-cli and that's being rescued as load error and metanorma throw's out that missing error. Here are the options to fix this:

  1. Pin every gem to exact version to make the cli work with system installed versions
  2. Use a local Gemfile to add private gem and then use bundler to resolve this dependencies.

Based on metanorma dependencies I think it would be super hard to ensure number 1 at any given time, so I would suggest to go with number 2 and let bundler resolve the dependencies for us.

Long Version

The issue seems to be caused by multiple versions of metanorma-generic gem, Especially installing metanorma-ribose independently installs metanorma-generic-1.8.1, but the current version of the metanorma-cli resolves the same gem to metanorma-generic-1.8.0 and it's coming from metanorma-bipm-1.0.0

So when we are running the compile steps then metanorma tries to load the metanorma-ribose gem but it can't activate this because of the different versions and that is raising a Gem::ConflictError.

/root/.asdf/installs/ruby/2.7.2/lib/ruby/2.7.0/rubygems/specification.rb:2247:in `raise_if_conflicts': Unable to activate metanorma-ribose-1.6.10, because metanorma-generic-1.8.0 conflicts with metanorma-generic (~> 1.8.1) (Gem::ConflictError)
        19: from /root/.asdf/installs/ruby/2.7.2/bin/metanorma:23:in `<main>'
        18: from /root/.asdf/installs/ruby/2.7.2/bin/metanorma:23:in `load'
        17: from /root/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/metanorma-cli-1.4.0/exe/metanorma:20:in `<top (required)>'
        16: from /root/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/metanorma-cli-1.4.0/lib/metanorma/cli.rb:65:in `start'
        15: from /root/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/base.rb:485:in `start'
        14: from /root/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
        13: from /root/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
        12: from /root/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
        11: from /root/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/metanorma-cli-1.4.0/lib/metanorma/cli/command.rb:42:in `compile'
        10: from /root/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/metanorma-cli-1.4.0/lib/metanorma/cli/compiler.rb:35:in `compile'
         9: from /root/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/metanorma-cli-1.4.0/lib/metanorma/cli/compiler.rb:30:in `compile'
         8: from /root/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/metanorma-cli-1.4.0/lib/metanorma/cli/compiler.rb:45:in `compile_file'
         7: from /root/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/metanorma-1.2.2/lib/metanorma/compile.rb:18:in `compile'
         6: from /root/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/metanorma-1.2.2/lib/metanorma/compile.rb:71:in `validate_type'
         5: from /root/.asdf/installs/ruby/2.7.2/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:156:in `require'
         4: from /root/.asdf/installs/ruby/2.7.2/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:161:in `rescue in require'
         3: from /root/.asdf/installs/ruby/2.7.2/lib/ruby/2.7.0/rubygems.rb:210:in `try_activate'
         2: from /root/.asdf/installs/ruby/2.7.2/lib/ruby/2.7.0/rubygems.rb:217:in `rescue in try_activate'
         1: from /root/.asdf/installs/ruby/2.7.2/lib/ruby/2.7.0/rubygems/specification.rb:1369:in `activate'
/root/.asdf/installs/ruby/2.7.2/lib/ruby/2.7.0/rubygems/specification.rb:2247:in `raise_if_conflicts': Unable to activate metanorma-ribose-1.6.10, because metanorma-generic-1.8.0 conflicts with metanorma-generic (~> 1.8.1) (Gem::ConflictError)

Fix: I would follow Nick's suggestion here to use a localGemfile for private gems and let bundler resolve the dependencies correctly. I will also work on adding more specific error to the metanorma gem soon.

@ronaldtse
Copy link
Contributor

@abunashir this suggestion does not actually help the problem except for developers:

Fix: I would follow Nick's suggestion here to use a localGemfile for private gems and let bundler resolve the dependencies correctly. I will also work on adding more specific error to the metanorma gem soon.

Because users of Metanorma are not expected to be familiar with Ruby, and of course they cannot be expected to be familiar with Bundler.

The real issue is this one: metanorma/metanorma-cli#81

abunashir added a commit to metanorma/metanorma-cli that referenced this issue May 5, 2021
There has been a long pending issue with the performance for the
cli, especially if we have multiple version installed. In that case
lots of gem still stays as unresolved, and that could cause some of
the performance issue.

This commit follows some suggestion to explicitly activate those
gems, as it should resolve the dependencies early. This should also
fix the private gem loading issue as we have seen on another repo

Related: metanorma/metanorma-ribose#83
abunashir added a commit to metanorma/metanorma-cli that referenced this issue May 7, 2021
There has been a long pending issue with the performance for the
cli, especially if we have multiple version installed. In that case
lots of gem still stays as unresolved, and that could cause some of
the performance issue.

This commit follows some suggestion to explicitly activate those
gems, as it should resolve the dependencies early. This should also
fix the private gem loading issue as we have seen on another repo

Related: metanorma/metanorma-ribose#83
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants