rails / thor

Thor is a toolkit for building powerful command-line interfaces.
http://whatisthor.com/
MIT License
5.12k stars 553 forks source link

trouble with different thor versions in system and in used gem #723

Closed nvoynov closed 4 years ago

nvoynov commented 4 years ago

Hi,

help me please with my problem with different thor versions - latest thor gem installed and thor version used in my own gem.

this is that I see in my terminal

C:/ruby/Ruby26/lib/ruby/site_ruby/2.6.0/rubygems/specification.rb:2243:in `raise_if_conflicts': Unable to activate clerq-0.3.1, because thor-1.0.1 conflicts with thor (~> 0.20.3) (Gem::ConflictError)

I'm using my own gem clerq that is a toolkit that provides a few command through thor (v0.20.3 in gemspec).

I decided to make a few custom local commands through thor and these commands get data through my clerq gem

require 'clerq'
require 'thor'
require 'tmpdir'
require_relative 'lib/colonize_repo'
include Clerq::Repositories
include Clerq::Entities
include Clerq::Services

class ClerqDoc < Thor
  include Thor::Actions
  namespace 'clerq:doc'.to_sym

  desc 'docx', 'Publish final deliverables in Docx'
  def docx
    # ....
  end
end

Now in my system are two thor versions - 1.0.1 and 0.20.3. And when I run my command I have the following errors

thor clerq:doc:docx
Traceback (most recent call last):
        16: from C:/ruby/Ruby26/bin/thor:23:in `<main>'
        15: from C:/ruby/Ruby26/bin/thor:23:in `load'
        14: from C:/ruby/Ruby26/lib/ruby/gems/2.6.0/gems/thor-1.0.1/bin/thor:6:in `<top (required)>'
        13: from C:/ruby/Ruby26/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/base.rb:485:in `start'
        12: from C:/ruby/Ruby26/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
        11: from C:/ruby/Ruby26/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
        10: from C:/ruby/Ruby26/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/command.rb:135:in `run'
         9: from C:/ruby/Ruby26/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/command.rb:29:in `run'
         8: from C:/ruby/Ruby26/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/runner.rb:39:in `method_missing'
         7: from C:/ruby/Ruby26/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/runner.rb:216:in `initialize_thorfiles'
         6: from C:/ruby/Ruby26/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/runner.rb:216:in `each'
         5: from C:/ruby/Ruby26/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/runner.rb:217:in `block in initialize_thorfiles'
         4: from C:/ruby/Ruby26/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/util.rb:156:in `load_thorfile'
         3: from C:/ruby/Ruby26/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/util.rb:156:in `class_eval'
         2: from C:/Users/User/Documents/idhub/mercedes/src/matching-tool/clerq_doc.thor:1:in `load_thorfile'
         1: from C:/ruby/Ruby26/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:92:in `require'
C:/ruby/Ruby26/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:92:in `require': cannot load such file -- clerq (LoadError)
        19: from C:/ruby/Ruby26/bin/thor:23:in `<main>'
        18: from C:/ruby/Ruby26/bin/thor:23:in `load'
        17: from C:/ruby/Ruby26/lib/ruby/gems/2.6.0/gems/thor-1.0.1/bin/thor:6:in `<top (required)>'
        16: from C:/ruby/Ruby26/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/base.rb:485:in `start'
        15: from C:/ruby/Ruby26/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
        14: from C:/ruby/Ruby26/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
        13: from C:/ruby/Ruby26/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/command.rb:135:in `run'
        12: from C:/ruby/Ruby26/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/command.rb:29:in `run'
        11: from C:/ruby/Ruby26/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/runner.rb:39:in `method_missing'
        10: from C:/ruby/Ruby26/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/runner.rb:216:in `initialize_thorfiles'
         9: from C:/ruby/Ruby26/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/runner.rb:216:in `each'
         8: from C:/ruby/Ruby26/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/runner.rb:217:in `block in initialize_thorfiles'
         7: from C:/ruby/Ruby26/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/util.rb:156:in `load_thorfile'
         6: from C:/ruby/Ruby26/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/util.rb:156:in `class_eval'
         5: from C:/Users/User/Documents/idhub/mercedes/src/matching-tool/clerq_doc.thor:1:in `load_thorfile'
         4: from C:/ruby/Ruby26/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:156:in `require'
         3: from C:/ruby/Ruby26/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:161:in `rescue in require'
         2: from C:/ruby/Ruby26/lib/ruby/site_ruby/2.6.0/rubygems.rb:209:in `try_activate'
         1: from C:/ruby/Ruby26/lib/ruby/site_ruby/2.6.0/rubygems/specification.rb:1371:in `activate'
C:/ruby/Ruby26/lib/ruby/site_ruby/2.6.0/rubygems/specification.rb:2243:in `raise_if_conflicts': Unable to activate clerq-0.3.1, because thor-1.0.1 conflicts with thor (~> 0.20.3) (Gem::ConflictError)
        20: from C:/ruby/Ruby26/bin/thor:23:in `<main>'
        19: from C:/ruby/Ruby26/bin/thor:23:in `load'
        18: from C:/ruby/Ruby26/lib/ruby/gems/2.6.0/gems/thor-1.0.1/bin/thor:6:in `<top (required)>'
        17: from C:/ruby/Ruby26/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/base.rb:485:in `start'
        16: from C:/ruby/Ruby26/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
        15: from C:/ruby/Ruby26/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
        14: from C:/ruby/Ruby26/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/command.rb:135:in `run'
        13: from C:/ruby/Ruby26/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/command.rb:29:in `run'
        12: from C:/ruby/Ruby26/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/runner.rb:39:in `method_missing'
        11: from C:/ruby/Ruby26/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/runner.rb:216:in `initialize_thorfiles'
        10: from C:/ruby/Ruby26/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/runner.rb:216:in `each'
         9: from C:/ruby/Ruby26/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/runner.rb:217:in `block in initialize_thorfiles'
         8: from C:/ruby/Ruby26/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/util.rb:156:in `load_thorfile'
         7: from C:/ruby/Ruby26/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/util.rb:156:in `class_eval'
         6: from C:/Users/User/Documents/idhub/mercedes/src/matching-tool/clerq_doc.thor:1:in `load_thorfile'
         5: from C:/ruby/Ruby26/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:156:in `require'
         4: from C:/ruby/Ruby26/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:161:in `rescue in require'
         3: from C:/ruby/Ruby26/lib/ruby/site_ruby/2.6.0/rubygems.rb:208:in `try_activate'
         2: from C:/ruby/Ruby26/lib/ruby/site_ruby/2.6.0/rubygems.rb:215:in `rescue in try_activate'
         1: from C:/ruby/Ruby26/lib/ruby/site_ruby/2.6.0/rubygems/specification.rb:1371:in `activate'
C:/ruby/Ruby26/lib/ruby/site_ruby/2.6.0/rubygems/specification.rb:2243:in `raise_if_conflicts': Unable to activate clerq-0.3.1, because thor-1.0.1 conflicts with thor (~> 0.20.3) (Gem::ConflictError)
deivid-rodriguez commented 4 years ago

You should use a Gemfile, like

source "https://rubygems.org"

gem "clerq"
gem "thor"
gem "tmpdir"

And then run your program through bundle exec thor clerq:doc:docx.

nvoynov commented 4 years ago

Thanks for the reply, but is the solution with Gemfile the only way or there are alternatives? I see Bundler as an unnecessary dependency for my purpose although understand this is the simpliest way.

deivid-rodriguez commented 4 years ago

An alternative solution would be to remove thor 1.0.1 from your system, but your going to need to manually make sure that the highest version of all your dependencies is the one that your application is using, or you'll get getting this mismatches with other dependencies.

nvoynov commented 4 years ago

Thanks for quick response!