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

Bundle integration fails when Toys itself is a dependency #48

Closed
dazuma opened this issue Jul 9, 2020 · 19 comments · Fixed by #49
Closed

Bundle integration fails when Toys itself is a dependency #48

dazuma opened this issue Jul 9, 2020 · 19 comments · Fixed by #49
Assignees
Labels
bug Something isn't working

Comments

@dazuma
Copy link
Owner

dazuma commented Jul 9, 2020

We recommend that Toys not be listed in a Gemfile or as a development dependency when using bundler integration, but that doesn't help when Toys itself (or toys-core) is a runtime dependency of the library being developed. As a result, Toys is in the bundle, and its version can clash with the actual running version of Toys.

Two possible approaches to solving this:

  • Convince Bundler that the running version of Toys is not a gem, and therefore doesn't clash with the Toys in the bundle. Bundler will happily activate whatever version of Toys is in the bundle, and then the bundler integration code will re-layer the current running Toys on top. However, this has the downside that there are still two versions of Toys in the load path and it is still possible for them to interfere with each other. Additionally, the active version of Toys may not actually be compatible with what the bundle calls for, and bundler won't know about it so it could manifest weirdly.
  • Add the current running version of Toys to the bundle's set of dependencies before resolving. This has the advantage of failing fast if the current Toys is not compatible with the bundle.

See #23 for earlier discussion.

@dazuma dazuma self-assigned this Jul 9, 2020
@dazuma dazuma added the bug Something isn't working label Jul 9, 2020
@dazuma dazuma reopened this Jul 11, 2020
@dazuma
Copy link
Owner Author

dazuma commented Jul 11, 2020

Re-opening to keep discussion alive for the moment.

@AlexWayfer
Copy link
Contributor

> gem i toys
Successfully installed toys-0.10.4
Parsing documentation for toys-0.10.4
Installing ri documentation for toys-0.10.4
Done installing documentation for toys after 1 seconds
1 gem installed

Then with the code:

require 'bundler/setup'
Bundler.setup

Output as earlier:

> toys --version
Gem::LoadError: You have already activated toys-core 0.10.4, but your Gemfile requires toys-core 0.10.3. Prepending `bundle exec` to your command may solve this.
     40: /home/alex/.rbenv/versions/2.7.1/bin/toys:23:in `<main>'
     39: /home/alex/.rbenv/versions/2.7.1/bin/toys:23:in `load'
     38: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-0.10.4/bin/toys:11:in `<top (required)>'
     37: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/cli.rb:423:in `run'
     36: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/errors.rb:90:in `capture'
     35: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/cli.rb:424:in `block in run'
     34: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:139:in `lookup'
     33: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:139:in `loop'
     32: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:140:in `block in lookup'
     31: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:160:in `lookup_specific'
     30: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:276:in `load_for_prefix'
     29: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:276:in `synchronize'
     28: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:280:in `block in load_for_prefix'
     27: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:280:in `each'
     26: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:285:in `block (2 levels) in load_for_prefix'
     25: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:388:in `load_validated_path'
     24: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:397:in `load_relevant_path'
     23: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/input_file.rb:26:in `evaluate'
     22: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/dsl/tool.rb:1694:in `prepare'
     21: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/input_file.rb:27:in `block in evaluate'
     20: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/errors.rb:70:in `capture_path'
     19: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/input_file.rb:29:in `block (2 levels) in evaluate'
     18: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/input_file.rb:29:in `eval'
     17: /home/alex/Projects/ruby/gem_toys/.toys.rb:2:in `__binding'
     16: /home/alex/Projects/ruby/gem_toys/.toys.rb:3:in `<module:M80__toys_rb>'
     15: /home/alex/Projects/ruby/gem_toys/.toys.rb:3:in `class_eval'
     14: /home/alex/Projects/ruby/gem_toys/.toys.rb:4:in `block in <module:M80__toys_rb>'
     13: /home/alex/.rbenv/versions/2.7.1/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
     12: /home/alex/.rbenv/versions/2.7.1/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
     11: /home/alex/.rbenv/versions/2.7.1/lib/ruby/2.7.0/bundler/setup.rb:10:in `<top (required)>'
     10: /home/alex/.rbenv/versions/2.7.1/lib/ruby/2.7.0/bundler/ui/shell.rb:88:in `silence'
      9: /home/alex/.rbenv/versions/2.7.1/lib/ruby/2.7.0/bundler/ui/shell.rb:136:in `with_level'
      8: /home/alex/.rbenv/versions/2.7.1/lib/ruby/2.7.0/bundler/setup.rb:10:in `block in <top (required)>'
      7: /home/alex/.rbenv/versions/2.7.1/lib/ruby/2.7.0/bundler.rb:149:in `setup'
      6: /home/alex/.rbenv/versions/2.7.1/lib/ruby/2.7.0/bundler/runtime.rb:26:in `setup'
      5: /home/alex/.rbenv/versions/2.7.1/lib/ruby/2.7.0/bundler/runtime.rb:26:in `map'
      4: /home/alex/.rbenv/versions/2.7.1/lib/ruby/2.7.0/bundler/spec_set.rb:147:in `each'
      3: /home/alex/.rbenv/versions/2.7.1/lib/ruby/2.7.0/bundler/spec_set.rb:147:in `each'
      2: /home/alex/.rbenv/versions/2.7.1/lib/ruby/2.7.0/bundler/runtime.rb:31:in `block in setup'
      1: /home/alex/.rbenv/versions/2.7.1/lib/ruby/2.7.0/bundler/runtime.rb:312:in `check_for_activated_spec!'
Error while loading Toys config!
    Gem::LoadError: You have already activated toys-core 0.10.4, but your Gemfile requires toys-core 0.10.3. Prepending `bundle exec` to your command may solve this.
    in config file: /home/alex/Projects/ruby/gem_toys/.toys.rb:4

With suggested by you code:

require 'toys/utils/gems'
Toys::Utils::Gems.new.bundle(search_dirs: Dir.getwd)

It works!

> toys --version
Resolving dependencies...
0.10.4

But, honestly, I'm not sure about Resolving dependencies... each call…

@AlexWayfer
Copy link
Contributor

AlexWayfer commented Jul 11, 2020

And maybe :search_dirs should have a default, as Dir.getwd? It will shorten a third-party code in most cases, I think.

@dazuma
Copy link
Owner Author

dazuma commented Jul 11, 2020

Instead of Bundler.setup or require "bundler/setup" (or the two-line workaround with Toys::Utils::Gems.new.bundle) do this instead:

include :bundler, static: true

I added static: true in 0.10.4, which sets up the bundle immediately rather than waiting until the tool runs. So using that will do the correct Toys-Bundler integration, and will provide the usual defaults for search_dirs, etc.

As for Resolving dependencies... that's bundler's output. I think it's possible to add an option to suppress it.

@AlexWayfer
Copy link
Contributor

include :bundler, static: true

OK, thank you, this is laconic.

As for Resolving dependencies... that's bundler's output. I think it's possible to add an option to suppress it.

That's strange, I don't see this via bundle exec. It's something internal, I guess.

@AlexWayfer
Copy link
Contributor

AlexWayfer commented Jul 11, 2020

Also there is a strange output when you have a later version of some dependency in the Gemfile than in Gemfile.lock:

> toys --version
Your bundle requires additional gems. Install? (Y/n) y
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/.
Bundler::GemNotFound: You have requested:
  rubocop ~> 0.87.0

The bundle currently has rubocop locked at 0.85.1.
Try running `bundle update rubocop`

If you are updating multiple gems in your Gemfile at once,
try passing them all to `bundle update`
     63: /home/alex/.rbenv/versions/2.7.1/bin/toys:23:in `<main>'
     62: /home/alex/.rbenv/versions/2.7.1/bin/toys:23:in `load'
     61: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-0.10.4/bin/toys:11:in `<top (required)>'
     60: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/cli.rb:423:in `run'
     59: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/errors.rb:90:in `capture'
     58: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/cli.rb:424:in `block in run'
     57: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:139:in `lookup'
     56: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:139:in `loop'
     55: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:140:in `block in lookup'
     54: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:160:in `lookup_specific'
     53: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:276:in `load_for_prefix'
     52: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:276:in `synchronize'
     51: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:280:in `block in load_for_prefix'
     50: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:280:in `each'
     49: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:285:in `block (2 levels) in load_for_prefix'
     48: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:388:in `load_validated_path'
     47: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:397:in `load_relevant_path'
     46: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/input_file.rb:26:in `evaluate'
     45: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/dsl/tool.rb:1694:in `prepare'
     44: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/input_file.rb:27:in `block in evaluate'
     43: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/errors.rb:70:in `capture_path'
     42: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/input_file.rb:29:in `block (2 levels) in evaluate'
     41: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/input_file.rb:29:in `eval'
     40: /home/alex/Projects/ruby/crowdin_toys/.toys.rb:in `__binding'
     39: /home/alex/Projects/ruby/crowdin_toys/.toys.rb:1:in `<module:M80__toys_rb>'
     38: /home/alex/Projects/ruby/crowdin_toys/.toys.rb:1:in `class_eval'
     37: /home/alex/Projects/ruby/crowdin_toys/.toys.rb:3:in `block in <module:M80__toys_rb>'
     36: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/dsl/tool.rb:1482:in `include'
     35: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/dsl/tool.rb:1482:in `class_exec'
     34: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/standard_mixins/bundler.rb:66:in `block in <module:Bundler>'
     33: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/standard_mixins/bundler.rb:109:in `setup_bundle'
     32: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/utils/gems.rb:153:in `bundle'
     31: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/utils/gems.rb:167:in `synchronize'
     30: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/utils/gems.rb:167:in `synchronize'
     29: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/utils/gems.rb:158:in `block in bundle'
     28: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/utils/gems.rb:259:in `setup_bundle'
     27: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/utils/gems.rb:264:in `rescue in setup_bundle'
     26: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/utils/gems.rb:322:in `install_bundle'
     25: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in `start'
     24: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:in `start'
     23: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in `dispatch'
     22: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'
     21: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
     20: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
     19: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli.rb:255:in `install'
     18: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/settings.rb:124:in `temporary'
     17: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli.rb:256:in `block in install'
     16: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli/install.rb:66:in `run'
     15: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/installer.rb:25:in `install'
     14: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/installer.rb:73:in `run'
     13: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/process_lock.rb:9:in `lock'
     12: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/process_lock.rb:9:in `open'
     11: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/process_lock.rb:12:in `block in lock'
     10: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/installer.rb:84:in `block in run'
      9: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/installer.rb:303:in `resolve_if_needed'
      8: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/definition.rb:158:in `resolve_remotely!'
      7: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/definition.rb:170:in `specs'
      6: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/definition.rb:258:in `resolve'
      5: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/resolver.rb:22:in `resolve'
      4: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/resolver.rb:49:in `start'
      3: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/resolver.rb:258:in `verify_gemfile_dependencies_are_found!'
      2: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/resolver.rb:258:in `each'
      1: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/resolver.rb:290:in `block in verify_gemfile_dependencies_are_found!'
Error while loading Toys config!
    Bundler::GemNotFound: You have requested:
  rubocop ~> 0.87.0

The bundle currently has rubocop locked at 0.85.1.
Try running `bundle update rubocop`

If you are updating multiple gems in your Gemfile at once,
try passing them all to `bundle update`
    in config file: /home/alex/Projects/ruby/crowdin_toys/.toys.rb:3

I don't know, maybe we can somehow reload bundle after this action.

@AlexWayfer
Copy link
Contributor

Also I found a strange warning (also it's somewhy wrote in red, as error, and not in yellow or orange, as regular warning):

WARNING: Unable to integrate your Gemfile into the Toys runtime.
When using the Toys Bundler integration features, do NOT list
the toys or toys-core gems directly in your Gemfile. They can be
dependencies of another gem, but cannot be listed directly.

So, if I have a project like an application, with toys for many actions, and many *_toys dependencies too — I cant define toys as dependency? I need for it. Yes, it's like dependency of dependencies, but what if I want to use a fork?

@dazuma
Copy link
Owner Author

dazuma commented Jul 13, 2020

Hi Alex,

Thanks much for the reports! I've figured out how to suppress the Resolving dependencies... output. Regarding the warning: I think I've found a workaround that will let you list toys (or toys-core) directly in a Gemfile, as long as the version is compatible with the version of toys that is running. So those fixes will be in the next update.

I'm having trouble reproducing the error you're seeing when the Gemfile has a later dependency than Gemfile.lock, however. Is the rubocop dependency listed directly in your Gemfile, or is it listed indirectly in a gemspec? (And if the latter, is it a normal dependency or a development dependency?) Can you provide the files involved (Gemfile, Gemfile.lock, any gemspecs involved) and a list of the relevant gems that were or were not installed when this was run?

@AlexWayfer
Copy link
Contributor

Thanks much for the reports! I've figured out how to suppress the Resolving dependencies... output. Regarding the warning: I think I've found a workaround that will let you list toys (or toys-core) directly in a Gemfile, as long as the version is compatible with the version of toys that is running. So those fixes will be in the next update.

Thank you!

I'm having trouble reproducing the error you're seeing when the Gemfile has a later dependency than Gemfile.lock, however.

I suggest to edit Gemfile.lock manually, each rubocop (or another gem) entry, to lower version.

Is the rubocop dependency listed directly in your Gemfile, or is it listed indirectly in a gemspec?

gemspec, but I think it doesn't matter..

(And if the latter, is it a normal dependency or a development dependency?)

Development, but I think it doesn't matter too.

Can you provide the files involved (Gemfile, Gemfile.lock, any gemspecs involved)

For example, such line in a gemspec file:

spec.add_development_dependency 'rubocop', '~> 0.87.0'

Gemfile:

# frozen_string_literal: true

source 'https://rubygems.org'

gemspec

And such lines in Gemfile.lock:

    rubocop (0.87.1)
      parallel (~> 1.10)
      parser (>= 2.7.1.1)
      rainbow (>= 2.2.2, < 4.0)
      regexp_parser (>= 1.7)
      rexml
      rubocop-ast (>= 0.1.0, < 1.0)
      ruby-progressbar (~> 1.7)
      unicode-display_width (>= 1.4.0, < 2.0)

toys rubocop works:

> toys rubocop
Resolving dependencies...
[2020-07-13 16:52:50   ANY]  rubocop
Inspecting 12 files
............

12 files inspected, no offenses detected

By the way, here is a tool:

tool :rubocop do
  def run
    exec 'rubocop'
  end
end

And then I'm editing gemspec, rubocop to 0.88.0.

And now we're getting:

> toys rubocop
Your bundle requires additional gems. Install? (Y/n) 

If you're choosing no:

Your bundle requires additional gems. Install? (Y/n) n
Toys::Utils::Gems::BundleNotInstalledError: Your bundle is not installed. Consider running `cd /home/alex/Projects/ruby/flame_generate_toys && bundle install`
     38: /home/alex/.rbenv/versions/2.7.1/bin/toys:23:in `<main>'
     37: /home/alex/.rbenv/versions/2.7.1/bin/toys:23:in `load'
     36: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-0.10.4/bin/toys:11:in `<top (required)>'
     35: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/cli.rb:423:in `run'
     34: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/errors.rb:90:in `capture'
     33: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/cli.rb:424:in `block in run'
     32: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:139:in `lookup'
     31: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:139:in `loop'
     30: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:140:in `block in lookup'
     29: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:160:in `lookup_specific'
     28: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:276:in `load_for_prefix'
     27: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:276:in `synchronize'
     26: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:280:in `block in load_for_prefix'
     25: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:280:in `each'
     24: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:285:in `block (2 levels) in load_for_prefix'
     23: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:388:in `load_validated_path'
     22: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:397:in `load_relevant_path'
     21: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/input_file.rb:26:in `evaluate'
     20: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/dsl/tool.rb:1694:in `prepare'
     19: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/input_file.rb:27:in `block in evaluate'
     18: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/errors.rb:70:in `capture_path'
     17: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/input_file.rb:29:in `block (2 levels) in evaluate'
     16: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/input_file.rb:29:in `eval'
     15: /home/alex/Projects/ruby/flame_generate_toys/.toys.rb:in `__binding'
     14: /home/alex/Projects/ruby/flame_generate_toys/.toys.rb:1:in `<module:M80__toys_rb>'
     13: /home/alex/Projects/ruby/flame_generate_toys/.toys.rb:1:in `class_eval'
     12: /home/alex/Projects/ruby/flame_generate_toys/.toys.rb:3:in `block in <module:M80__toys_rb>'
     11: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/dsl/tool.rb:1482:in `include'
     10: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/dsl/tool.rb:1482:in `class_exec'
      9: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/standard_mixins/bundler.rb:66:in `block in <module:Bundler>'
      8: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/standard_mixins/bundler.rb:109:in `setup_bundle'
      7: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/utils/gems.rb:153:in `bundle'
      6: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/utils/gems.rb:167:in `synchronize'
      5: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/utils/gems.rb:167:in `synchronize'
      4: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/utils/gems.rb:158:in `block in bundle'
      3: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/utils/gems.rb:259:in `setup_bundle'
      2: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/utils/gems.rb:264:in `rescue in setup_bundle'
      1: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/utils/gems.rb:317:in `install_bundle'
Error while loading Toys config!
    Toys::Utils::Gems::BundleNotInstalledError: Your bundle is not installed. Consider running `cd /home/alex/Projects/ruby/flame_generate_toys && bundle install`
    in config file: /home/alex/Projects/ruby/flame_generate_toys/.toys.rb:3

If yes — it takes more time, but there is the error too:

Your bundle requires additional gems. Install? (Y/n) y
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/.
Bundler::GemNotFound: You have requested:
  rubocop ~> 0.88.0

The bundle currently has rubocop locked at 0.87.1.
Try running `bundle update rubocop`

If you are updating multiple gems in your Gemfile at once,
try passing them all to `bundle update`
     63: /home/alex/.rbenv/versions/2.7.1/bin/toys:23:in `<main>'
     62: /home/alex/.rbenv/versions/2.7.1/bin/toys:23:in `load'
     61: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-0.10.4/bin/toys:11:in `<top (required)>'
     60: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/cli.rb:423:in `run'
     59: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/errors.rb:90:in `capture'
     58: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/cli.rb:424:in `block in run'
     57: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:139:in `lookup'
     56: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:139:in `loop'
     55: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:140:in `block in lookup'
     54: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:160:in `lookup_specific'
     53: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:276:in `load_for_prefix'
     52: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:276:in `synchronize'
     51: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:280:in `block in load_for_prefix'
     50: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:280:in `each'
     49: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:285:in `block (2 levels) in load_for_prefix'
     48: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:388:in `load_validated_path'
     47: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:397:in `load_relevant_path'
     46: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/input_file.rb:26:in `evaluate'
     45: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/dsl/tool.rb:1694:in `prepare'
     44: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/input_file.rb:27:in `block in evaluate'
     43: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/errors.rb:70:in `capture_path'
     42: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/input_file.rb:29:in `block (2 levels) in evaluate'
     41: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/input_file.rb:29:in `eval'
     40: /home/alex/Projects/ruby/flame_generate_toys/.toys.rb:in `__binding'
     39: /home/alex/Projects/ruby/flame_generate_toys/.toys.rb:1:in `<module:M80__toys_rb>'
     38: /home/alex/Projects/ruby/flame_generate_toys/.toys.rb:1:in `class_eval'
     37: /home/alex/Projects/ruby/flame_generate_toys/.toys.rb:3:in `block in <module:M80__toys_rb>'
     36: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/dsl/tool.rb:1482:in `include'
     35: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/dsl/tool.rb:1482:in `class_exec'
     34: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/standard_mixins/bundler.rb:66:in `block in <module:Bundler>'
     33: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/standard_mixins/bundler.rb:109:in `setup_bundle'
     32: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/utils/gems.rb:153:in `bundle'
     31: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/utils/gems.rb:167:in `synchronize'
     30: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/utils/gems.rb:167:in `synchronize'
     29: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/utils/gems.rb:158:in `block in bundle'
     28: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/utils/gems.rb:259:in `setup_bundle'
     27: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/utils/gems.rb:264:in `rescue in setup_bundle'
     26: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/utils/gems.rb:322:in `install_bundle'
     25: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in `start'
     24: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:in `start'
     23: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in `dispatch'
     22: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'
     21: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
     20: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
     19: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli.rb:255:in `install'
     18: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/settings.rb:124:in `temporary'
     17: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli.rb:256:in `block in install'
     16: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli/install.rb:66:in `run'
     15: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/installer.rb:25:in `install'
     14: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/installer.rb:73:in `run'
     13: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/process_lock.rb:9:in `lock'
     12: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/process_lock.rb:9:in `open'
     11: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/process_lock.rb:12:in `block in lock'
     10: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/installer.rb:84:in `block in run'
      9: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/installer.rb:303:in `resolve_if_needed'
      8: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/definition.rb:158:in `resolve_remotely!'
      7: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/definition.rb:170:in `specs'
      6: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/definition.rb:258:in `resolve'
      5: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/resolver.rb:22:in `resolve'
      4: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/resolver.rb:49:in `start'
      3: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/resolver.rb:258:in `verify_gemfile_dependencies_are_found!'
      2: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/resolver.rb:258:in `each'
      1: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/resolver.rb:290:in `block in verify_gemfile_dependencies_are_found!'
Error while loading Toys config!
    Bundler::GemNotFound: You have requested:
  rubocop ~> 0.88.0

The bundle currently has rubocop locked at 0.87.1.
Try running `bundle update rubocop`

If you are updating multiple gems in your Gemfile at once,
try passing them all to `bundle update`
    in config file: /home/alex/Projects/ruby/flame_generate_toys/.toys.rb:3

@AlexWayfer
Copy link
Contributor

Also I've got a strange error, seems fully from toys, while tried to execute nonexistent tool:

> toys rubocop
WARNING: Unable to integrate your Gemfile into the Toys runtime.
When using the Toys Bundler integration features, do NOT list
the toys or toys-core gems directly in your Gemfile. They can be
dependencies of another gem, but cannot be listed directly.
LoadError: cannot load such file -- did_you_mean
     13: /home/alex/.rbenv/versions/2.6.6/bin/toys:23:in `<main>'
     12: /home/alex/.rbenv/versions/2.6.6/bin/toys:23:in `load'
     11: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-0.10.4/bin/toys:11:in `<top (required)>'
     10: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.10.4/lib/toys/cli.rb:426:in `run'
      9: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.10.4/lib/toys/errors.rb:70:in `capture_path'
      8: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.10.4/lib/toys/cli.rb:434:in `block in run'
      7: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.10.4/lib/toys/cli.rb:455:in `run_tool'
      6: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.10.4/lib/toys/arg_parser.rb:409:in `finish'
      5: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.10.4/lib/toys/arg_parser.rb:584:in `finish_arg_defs'
      4: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.10.4/lib/toys/compat.rb:45:in `suggestions'
      3: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.10.4/lib/toys/compat.rb:32:in `supports_suggestions?'
      2: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.10.4/lib/toys/compat.rb:36:in `rescue in supports_suggestions?'
      1: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.10.4/lib/toys/compat.rb:36:in `require'
Error during tool execution!
    LoadError: cannot load such file -- did_you_mean
    while executing tool: ""
    with arguments: ["rubocop"]

@dazuma
Copy link
Owner Author

dazuma commented Jul 13, 2020

Hi,

I found and fixed the did_you_mean issue. It happens on Ruby 2.6 or earlier, when you use a bundle (that does not include the did_you_mean gem) and you try to execute a nonexistent tool. For now I'm just going to prevent the error (but it will disable the suggestions feature for this case). That will be in the next release.

I still can't reproduce your rubocop GemNotFound error, though. Your instructions seemed pretty clear, and I followed them, but for me the installation works fine, the new rubocop gets installed, and the Gemfile.lock gets updated. I've been looking through the Bundler source, and it looks like it wouldn't show the error you're seeing unless it couldn't download the specs for the new version of rubocop.

If you have time to do a bit of troubleshooting, can you answer some questions:

  • Do you have any Bundler configs set? (i.e. what is the output of bundle config, and do you have any bundler-related environment variables?)
  • What is the output if you set the environment variable DEBUG=true when running this? (i.e. DEBUG=true toys rubocop). This environment variable turns on Bundler's debug output, so it will be useful to see more of what Bundler is doing internally.
  • Does this happen for any gems other than rubocop?

@AlexWayfer
Copy link
Contributor

I still can't reproduce your rubocop GemNotFound error, though. Your instructions seemed pretty clear, and I followed them, but for me the installation works fine, the new rubocop gets installed, and the Gemfile.lock gets updated.

There are also other dependencies, like bundler itself, so here an example of project: https://github.com/AlexWayfer/gem_toys

So, to reproduce with current (fef23e) version I'm doing:

  1. Change 'rubocop', '~> 0.88.0' to 0.87.0 in the gem_toys.gespec file.
  2. Execute bundle update (getting Using rubocop 0.87.1 (was 0.88.0)).
  3. Change 'rubocop', '~> 0.87.0' back to 0.88.0.
  4. Execute toys rubocop.

The same result.

Do you have any Bundler configs set? (i.e. what is the output of bundle config

> bundle config
Settings are listed in order of priority. The top value will be used.
gem.test
Set for the current user (/home/alex/.bundle/config): "rspec"

gem.mit
Set for the current user (/home/alex/.bundle/config): true

gem.coc
Set for the current user (/home/alex/.bundle/config): false

github.https
Set for the current user (/home/alex/.bundle/config): "true"

and do you have any bundler-related environment variables?

Outputs of env | grep '^BUNDLE' and env | grep '^GEM' commands are empty.

What is the output if you set the environment variable DEBUG=true when running this? (i.e. DEBUG=true toys rubocop).

> env DEBUG=true toys rubocop
Found changes from the lockfile, re-resolving dependencies because bundler is unlocking gems: (toys-core, toys)
Your bundle requires additional gems. Install? (Y/n) y
Running `bundle install` with bundler 2.1.4
Found changes from the lockfile, re-resolving dependencies because the dependencies in your gemfile changed
HTTP GET https://index.rubygems.org/versions
HTTP 206 Partial Content https://index.rubygems.org/versions
Fetching gem metadata from https://rubygems.org/
Looking up gems ["pry-byebug", "bundler", "toys", "codecov", "rspec", "simplecov", "rubocop", "rubocop-performance", "rubocop-rspec"]
Looking up gems ["term-ansicolor", "rainbow", "parser", "backports", "powerpack", "json", "ruby-progressbar", "astrolabe", "tins", "unicode-display_width", "parallel", "jaro_winkler", "psych", "rexml", "rubocop-ast", "regexp_parser", "toys-core", "rspec-core", "rspec-expectations", "rspec-mocks", "url", "colorize", "byebug", "pry", "simplecov-html", "multi_json", "docile", "lockfile"]
Looking up gems ["rake", "rspec-support", "columnize", "debugger-linecache", "slop", "rb-readline", "sexp_processor", "ast", "sync", "highline", "hoe", "jar-dependencies", "diff-lcs", "ruby_parser", "method_source", "coderay", "win32console", "yard", "spoon"]
Looking up gems ["termios", "ruby-maven", "ffi", "ruby_core_source", "debugger-ruby_core_source", "erubis", "ParseTree", "rubyforge", "RubyInline", "gemcutter"]
Looking up gems ["thor", "maven-tools", "ruby-maven-libs", "abstract", "net-scp", "json_pure", "archive-tar-minitar", "ZenTest", "SexpProcessor"]
Looking up gems ["virtus", "spruz", "minitar", "minitar-cli", "net-ssh"]
Looking up gems ["descendants_tracker", "axiom-types", "coercible", "equalizer", "needle", "jruby-pageant", "bcrypt_pbkdf", "rbnacl", "rbnacl-libsodium", "powerbar"]
Looking up gems ["ice_nine", "thread_safe", "adamantium", "ansi", "hashie"]
Looking up gems ["memoizable", "atomic"]
Double checking for ["bundler"] in rubygems repository https://rubygems.org/ or installed locally
Fetching gem metadata from https://rubygems.org/
Looking up gems ["bundler"]
Bundler::GemNotFound: You have requested:
  rubocop ~> 0.88.0

The bundle currently has rubocop locked at 0.87.1.
Try running `bundle update rubocop`

If you are updating multiple gems in your Gemfile at once,
try passing them all to `bundle update`
     63: /home/alex/.rbenv/versions/2.7.1/bin/toys:23:in `<main>'
     62: /home/alex/.rbenv/versions/2.7.1/bin/toys:23:in `load'
     61: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-0.10.4/bin/toys:11:in `<top (required)>'
     60: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/cli.rb:423:in `run'
     59: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/errors.rb:90:in `capture'
     58: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/cli.rb:424:in `block in run'
     57: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:139:in `lookup'
     56: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:139:in `loop'
     55: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:140:in `block in lookup'
     54: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:160:in `lookup_specific'
     53: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:276:in `load_for_prefix'
     52: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:276:in `synchronize'
     51: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:280:in `block in load_for_prefix'
     50: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:280:in `each'
     49: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:285:in `block (2 levels) in load_for_prefix'
     48: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:388:in `load_validated_path'
     47: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/loader.rb:397:in `load_relevant_path'
     46: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/input_file.rb:26:in `evaluate'
     45: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/dsl/tool.rb:1694:in `prepare'
     44: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/input_file.rb:27:in `block in evaluate'
     43: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/errors.rb:70:in `capture_path'
     42: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/input_file.rb:29:in `block (2 levels) in evaluate'
     41: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/input_file.rb:29:in `eval'
     40: /home/alex/Projects/ruby/gem_toys/.toys.rb:in `__binding'
     39: /home/alex/Projects/ruby/gem_toys/.toys.rb:1:in `<module:M80__toys_rb>'
     38: /home/alex/Projects/ruby/gem_toys/.toys.rb:1:in `class_eval'
     37: /home/alex/Projects/ruby/gem_toys/.toys.rb:3:in `block in <module:M80__toys_rb>'
     36: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/dsl/tool.rb:1482:in `include'
     35: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/dsl/tool.rb:1482:in `class_exec'
     34: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/standard_mixins/bundler.rb:66:in `block in <module:Bundler>'
     33: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/standard_mixins/bundler.rb:109:in `setup_bundle'
     32: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/utils/gems.rb:153:in `bundle'
     31: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/utils/gems.rb:167:in `synchronize'
     30: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/utils/gems.rb:167:in `synchronize'
     29: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/utils/gems.rb:158:in `block in bundle'
     28: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/utils/gems.rb:259:in `setup_bundle'
     27: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/utils/gems.rb:264:in `rescue in setup_bundle'
     26: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.4/lib/toys/utils/gems.rb:322:in `install_bundle'
     25: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in `start'
     24: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:in `start'
     23: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in `dispatch'
     22: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'
     21: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
     20: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
     19: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli.rb:255:in `install'
     18: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/settings.rb:124:in `temporary'
     17: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli.rb:256:in `block in install'
     16: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli/install.rb:66:in `run'
     15: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/installer.rb:25:in `install'
     14: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/installer.rb:73:in `run'
     13: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/process_lock.rb:9:in `lock'
     12: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/process_lock.rb:9:in `open'
     11: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/process_lock.rb:12:in `block in lock'
     10: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/installer.rb:84:in `block in run'
      9: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/installer.rb:303:in `resolve_if_needed'
      8: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/definition.rb:158:in `resolve_remotely!'
      7: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/definition.rb:170:in `specs'
      6: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/definition.rb:258:in `resolve'
      5: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/resolver.rb:22:in `resolve'
      4: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/resolver.rb:49:in `start'
      3: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/resolver.rb:258:in `verify_gemfile_dependencies_are_found!'
      2: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/resolver.rb:258:in `each'
      1: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/resolver.rb:290:in `block in verify_gemfile_dependencies_are_found!'
Error while loading Toys config!
    Bundler::GemNotFound: You have requested:
  rubocop ~> 0.88.0

The bundle currently has rubocop locked at 0.87.1.
Try running `bundle update rubocop`

If you are updating multiple gems in your Gemfile at once,
try passing them all to `bundle update`
    in config file: /home/alex/Projects/ruby/gem_toys/.toys.rb:3

Does this happen for any gems other than rubocop?

The same when I changed 'simplecov', '~> 0.18.0' to 0.17.0 and back.

@dazuma
Copy link
Owner Author

dazuma commented Jul 16, 2020

Hi,

Thanks for the additional info! I'm finally able to reproduce it now. It seems to happen only if there is another gem in the bundle that depends on the gem that you're updating. (In this case, rubocop-spec and rubocop-performance both depend on rubocop, so updating rubocop exhibits the issue. If you remove both rubocop-spec and rubocop-performance from the bundle, the issue goes away. Similarly, simplecov exhibits the issue because codecov depends on it. But if you tried updating codecov, you would not see the issue.)

Anyway, now I can construct a test case, so I'll work on a fix (which will probably involve calling bundle update if the install fails in this way). I'm going to be a bit busy for the next couple days, but I expect to work on this on the weekend, and will release an update then.

Thanks for the help on this one.

@AlexWayfer
Copy link
Contributor

Anyway, now I can construct a test case, so I'll work on a fix (which will probably involve calling bundle update if the install fails in this way). I'm going to be a bit busy for the next couple days, but I expect to work on this on the weekend, and will release an update then.

Thank you much!

Thanks for the help on this one.

No problem, I glad to help you with such good project.

@dazuma
Copy link
Owner Author

dazuma commented Jul 19, 2020

Released version 0.10.5

@AlexWayfer
Copy link
Contributor

Released version 0.10.5

Thank you! It works great with "yes" answer. But with "no" answer there is still an exception with a large backtrace:

> toys rubocop
Your bundle requires additional gems. Install? (Y/n) n
Toys::Utils::Gems::BundleNotInstalledError: Your bundle is not installed. Consider running `cd /home/alex/Projects/ruby/flame-r18n && bundle install`
     38: /home/alex/.rbenv/versions/2.7.1/bin/toys:23:in `<main>'
     37: /home/alex/.rbenv/versions/2.7.1/bin/toys:23:in `load'
     36: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-0.10.5/bin/toys:11:in `<top (required)>'
     35: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.5/lib/toys/cli.rb:423:in `run'
     34: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.5/lib/toys/errors.rb:90:in `capture'
     33: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.5/lib/toys/cli.rb:424:in `block in run'
     32: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.5/lib/toys/loader.rb:139:in `lookup'
     31: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.5/lib/toys/loader.rb:139:in `loop'
     30: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.5/lib/toys/loader.rb:140:in `block in lookup'
     29: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.5/lib/toys/loader.rb:160:in `lookup_specific'
     28: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.5/lib/toys/loader.rb:276:in `load_for_prefix'
     27: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.5/lib/toys/loader.rb:276:in `synchronize'
     26: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.5/lib/toys/loader.rb:280:in `block in load_for_prefix'
     25: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.5/lib/toys/loader.rb:280:in `each'
     24: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.5/lib/toys/loader.rb:285:in `block (2 levels) in load_for_prefix'
     23: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.5/lib/toys/loader.rb:388:in `load_validated_path'
     22: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.5/lib/toys/loader.rb:397:in `load_relevant_path'
     21: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.5/lib/toys/input_file.rb:26:in `evaluate'
     20: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.5/lib/toys/dsl/tool.rb:1694:in `prepare'
     19: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.5/lib/toys/input_file.rb:27:in `block in evaluate'
     18: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.5/lib/toys/errors.rb:70:in `capture_path'
     17: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.5/lib/toys/input_file.rb:29:in `block (2 levels) in evaluate'
     16: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.5/lib/toys/input_file.rb:29:in `eval'
     15: /home/alex/Projects/ruby/flame-r18n/.toys.rb:in `__binding'
     14: /home/alex/Projects/ruby/flame-r18n/.toys.rb:1:in `<module:M80__toys_rb>'
     13: /home/alex/Projects/ruby/flame-r18n/.toys.rb:1:in `class_eval'
     12: /home/alex/Projects/ruby/flame-r18n/.toys.rb:3:in `block in <module:M80__toys_rb>'
     11: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.5/lib/toys/dsl/tool.rb:1482:in `include'
     10: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.5/lib/toys/dsl/tool.rb:1482:in `class_exec'
      9: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.5/lib/toys/standard_mixins/bundler.rb:66:in `block in <module:Bundler>'
      8: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.5/lib/toys/standard_mixins/bundler.rb:109:in `setup_bundle'
      7: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.5/lib/toys/utils/gems.rb:160:in `bundle'
      6: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.5/lib/toys/utils/gems.rb:174:in `synchronize'
      5: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.5/lib/toys/utils/gems.rb:174:in `synchronize'
      4: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.5/lib/toys/utils/gems.rb:165:in `block in bundle'
      3: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.5/lib/toys/utils/gems.rb:266:in `setup_bundle'
      2: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.5/lib/toys/utils/gems.rb:271:in `rescue in setup_bundle'
      1: /home/alex/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/toys-core-0.10.5/lib/toys/utils/gems.rb:338:in `install_bundle'
Error while loading Toys config!
    Toys::Utils::Gems::BundleNotInstalledError: Your bundle is not installed. Consider running `cd /home/alex/Projects/ruby/flame-r18n && bundle install`
    in config file: /home/alex/Projects/ruby/flame-r18n/.toys.rb:3

Is it expected or maybe we should print more readable (human) error?

@AlexWayfer
Copy link
Contributor

I'm not sure is it related:

Gem::LoadError: You have already activated toys-core 0.11.1, but your Gemfile requires toys-core 0.11.0. Prepending `bundle exec` to your command may solve this.
     48: /home/alex/.rbenv/versions/2.6.6/bin/toys:23:in `<main>'
     47: /home/alex/.rbenv/versions/2.6.6/bin/toys:23:in `load'
     46: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-0.11.1/bin/toys:11:in `<top (required)>'
     45: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.11.0/lib/toys/cli.rb:423:in `run'
     44: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.11.0/lib/toys/errors.rb:90:in `capture'
     43: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.11.0/lib/toys/cli.rb:424:in `block in run'
     42: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.11.0/lib/toys/loader.rb:144:in `lookup'
     41: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.11.0/lib/toys/loader.rb:144:in `loop'
     40: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.11.0/lib/toys/loader.rb:145:in `block in lookup'
     39: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.11.0/lib/toys/loader.rb:165:in `lookup_specific'
     38: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.11.0/lib/toys/loader.rb:296:in `load_for_prefix'
     37: /home/alex/.rbenv/versions/2.6.6/lib/ruby/2.6.0/monitor.rb:235:in `mon_synchronize'
     36: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.11.0/lib/toys/loader.rb:300:in `block in load_for_prefix'
     35: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.11.0/lib/toys/loader.rb:300:in `each'
     34: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.11.0/lib/toys/loader.rb:306:in `block (2 levels) in load_for_prefix'
     33: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.11.0/lib/toys/loader.rb:418:in `load_validated_path'
     32: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.11.0/lib/toys/loader.rb:431:in `load_relevant_path'
     31: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.11.0/lib/toys/loader.rb:441:in `load_index_in'
     30: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.11.0/lib/toys/loader.rb:428:in `load_relevant_path'
     29: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.11.0/lib/toys/input_file.rb:26:in `evaluate'
     28: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.11.0/lib/toys/dsl/tool.rb:1711:in `prepare'
     27: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.11.0/lib/toys/input_file.rb:27:in `block in evaluate'
     26: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.11.0/lib/toys/errors.rb:70:in `capture_path'
     25: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.11.0/lib/toys/input_file.rb:29:in `block (2 levels) in evaluate'
     24: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.11.0/lib/toys/input_file.rb:29:in `eval'
     23: /home/alex/Projects/ruby/flame-cli/foo_bar/.toys/.toys.rb:2:in `__binding'
     22: /home/alex/Projects/ruby/flame-cli/foo_bar/.toys/.toys.rb:3:in `<module:M47320563349360__toys_rb>'
     21: /home/alex/Projects/ruby/flame-cli/foo_bar/.toys/.toys.rb:3:in `class_eval'
     20: /home/alex/Projects/ruby/flame-cli/foo_bar/.toys/.toys.rb:6:in `block in <module:M47320563349360__toys_rb>'
     19: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.11.0/lib/toys/dsl/tool.rb:1482:in `include'
     18: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.11.0/lib/toys/dsl/tool.rb:1482:in `class_exec'
     17: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.11.0/lib/toys/standard_mixins/bundler.rb:77:in `block in <module:Bundler>'
     16: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.11.0/lib/toys/standard_mixins/bundler.rb:114:in `setup_bundle'
     15: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.11.0/lib/toys/utils/gems.rb:184:in `bundle'
     14: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.11.0/lib/toys/utils/gems.rb:207:in `synchronize'
     13: /home/alex/.rbenv/versions/2.6.6/lib/ruby/2.6.0/monitor.rb:235:in `mon_synchronize'
     12: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.11.0/lib/toys/utils/gems.rb:188:in `block in bundle'
     11: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.11.0/lib/toys/utils/gems.rb:293:in `setup_bundle'
     10: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/ui/shell.rb:88:in `silence'
      9: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/ui/shell.rb:136:in `with_level'
      8: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/toys-core-0.11.0/lib/toys/utils/gems.rb:293:in `block in setup_bundle'
      7: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler.rb:149:in `setup'
      6: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:26:in `setup'
      5: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:26:in `map'
      4: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/spec_set.rb:147:in `each'
      3: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/spec_set.rb:147:in `each'
      2: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:31:in `block in setup'
      1: /home/alex/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:312:in `check_for_activated_spec!'

How to reproduce:

  1. Checkout to Update template, split toys into gems AlexWayfer/flame-cli#57
  2. Have installed toys and toys-core versions 0.11.0, but not 0.11.1.
  3. Run toys rspec.

The second run is successful.

@AlexWayfer
Copy link
Contributor

I have a similar error as the last one, but in another (private) project with GitLab CI.

# Gemfile.lock

# ...
toys (0.11.3)
      toys-core (= 0.11.3)
    toys-core (0.11.3)
# ...
# .toys/.toys.rb

# frozen_string_literal: true

include :bundler, static: true

expand :rubocop

# ...
# .gitlab-ci.yml

rubocop:
  before_script:
    # Bundler and Toys are not installed with the image
    - gem install bundler toys --no-document
    # Install dependencies into ./vendor/ruby
    - bundle install -j $(nproc) --path vendor
  script:
    - toys rubocop

The latest version of toys installed in before_script, 0.11.3 currently, but there 0.11.2 in the Gemfile.lock (it's an application project, not a gem).

So, the output is like:

Successfully installed bundler-2.1.4
Successfully installed toys-core-0.11.3
Successfully installed toys-0.11.3
3 gems installed
[DEPRECATED] The `--path` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set path 'vendor'`, and stop using this flag
Fetching gem metadata from https://rubygems.org/.......
# ...
Fetching toys-core 0.11.2
Installing toys-core 0.11.2
# ...
Fetching toys 0.11.2
Installing toys 0.11.2
# ...
Bundle complete! 28 Gemfile dependencies, 76 gems now installed.
Bundled gems are installed into `./vendor`
$ toys rubocop
Your bundle requires additional gems. Install? (Y/n) Using public_suffix 4.0.5
# ...
Using toys-core 0.11.2
# ...
Using toys 0.11.2
# ...
Bundle complete! 28 Gemfile dependencies, 76 gems now installed.
Bundled gems are installed into `./vendor`
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/spec_set.rb:86:in `block in materialize': Could not find toys-core-0.11.3 in any of the sources (Bundler::GemNotFound)
	from /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/spec_set.rb:80:in `map!'
	from /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/spec_set.rb:80:in `materialize'
	from /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/definition.rb:170:in `specs'
	from /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/definition.rb:237:in `specs_for'
	from /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/definition.rb:226:in `requested_specs'
	from /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/runtime.rb:101:in `block in definition_method'
	from /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/runtime.rb:20:in `setup'
	from /usr/local/bundle/gems/bundler-2.1.4/lib/bundler.rb:149:in `setup'
	from /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/setup.rb:20:in `block in <top (required)>'
	from /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/ui/shell.rb:136:in `with_level'
	from /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/ui/shell.rb:88:in `silence'
	from /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/setup.rb:20:in `<top (required)>'
	from /usr/local/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
	from /usr/local/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
[2020-09-14 01:29:21 ERROR]  RuboCop failed!
ERROR: Job failed: exit code 1

@dazuma
Copy link
Owner Author

dazuma commented Jul 19, 2021

I'm going to close this, as it's kind of morphed into a dumping ground for different issues, and so is no longer actionable. Some of the latest issues reported in this thread may have been fixed in recent commits (targeting version 0.12), especially issues involving installing into a custom bundle path (such as ./vendor) for which there was a recent critical fix.

Please open new issues for any additional problems.

@dazuma dazuma closed this as completed Jul 19, 2021
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.

2 participants