Can't execute `annotate` or `bundle exec annotate` commands
Opened this issue · 2 comments
Hello everyone!
I'm trying to install the annotate
gem in a project running with Rails 6 (6.1.7.2) and Ruby 2 (2.7.7).
I have added the gem in my Gemfile
:
group :development do
gem 'annotate'
end
I have bundle
, bundle install
(and also tried bundle exec rails g annotate:install
).
It seems to be installed:
Successfully installed annotate-3.2.0
Parsing documentation for annotate-3.2.0
Installing ri documentation for annotate-3.2.0
Done installing documentation for annotate after 0 seconds
1 gem installed
I have my auto_annotate_models.rake
file which has been created there: lib/tasks/auto_annotate_models.rake
I'm in the right folder (at the root of the project), but when I try the commands, I have weird errors and I can't understand what's wrong:
➜ PROJECT_NAME git:(some-branch-name) ✗ annotate
Traceback (most recent call last):
9: from /home/kevin/.rbenv/versions/2.7.7/bin/annotate:23:in `<main>'
8: from /home/kevin/.rbenv/versions/2.7.7/bin/annotate:23:in `load'
7: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/annotate-3.2.0/bin/annotate:10:in `<top (required)>'
6: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/bundler-2.4.12/lib/bundler.rb:171:in `setup'
5: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/bundler-2.4.12/lib/bundler/runtime.rb:24:in `setup'
4: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/bundler-2.4.12/lib/bundler/runtime.rb:24:in `map'
3: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/bundler-2.4.12/lib/bundler/spec_set.rb:165:in `each'
2: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/bundler-2.4.12/lib/bundler/spec_set.rb:165:in `each'
1: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/bundler-2.4.12/lib/bundler/runtime.rb:25:in `block in setup'
/home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/bundler-2.4.12/lib/bundler/runtime.rb:304:in `check_for_activated_spec!': You have already activated activesupport 6.1.7.3, but your Gemfile requires activesupport 6.1.7.2. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)
If I try to execute it with bundle exec
as it is recommanded, I have another issue:
➜ PROJECT_NAME git:(some-branch-name) ✗ bundle exec annotate
bundler: failed to load command: annotate (/home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/bin/annotate)
Traceback (most recent call last):
35: from /home/kevin/.rbenv/versions/2.7.7/bin/bundle:23:in `<main>'
34: from /home/kevin/.rbenv/versions/2.7.7/bin/bundle:23:in `load'
33: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/bundler-2.4.12/exe/bundle:33:in `<top (required)>'
32: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/bundler-2.4.12/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
31: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/bundler-2.4.12/exe/bundle:45:in `block in <top (required)>'
30: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/bundler-2.4.12/lib/bundler/cli.rb:28:in `start'
29: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/bundler-2.4.12/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
28: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/bundler-2.4.12/lib/bundler/cli.rb:34:in `dispatch'
27: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/bundler-2.4.12/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
26: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/bundler-2.4.12/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
25: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/bundler-2.4.12/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
24: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/bundler-2.4.12/lib/bundler/cli.rb:492:in `exec'
23: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/bundler-2.4.12/lib/bundler/cli/exec.rb:23:in `run'
22: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/bundler-2.4.12/lib/bundler/cli/exec.rb:58:in `kernel_load'
21: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/bundler-2.4.12/lib/bundler/cli/exec.rb:58:in `load'
20: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/bin/annotate:23:in `<top (required)>'
19: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/bin/annotate:23:in `load'
18: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/annotate-3.2.0/bin/annotate:20:in `<top (required)>'
17: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/annotate-3.2.0/lib/annotate.rb:119:in `bootstrap_rake'
16: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/annotate-3.2.0/lib/annotate.rb:119:in `load'
15: from /home/kevin/Documents/[COMPANY_NAME]/Projets/[PROJECT_NAME]/Rakefile:18:in `<top (required)>'
14: from /home/kevin/Documents/[COMPANY_NAME]/Projets/[PROJECT_NAME]/Rakefile:18:in `load'
13: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/railties-6.1.7.2/lib/rails/tasks/engine.rake:85:in `<top (required)>'
12: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
11: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
10: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
9: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
8: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
7: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
6: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
5: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
4: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/railties-6.1.7.2/lib/rails/tasks/engine.rake:4:in `block in <top (required)>'
3: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/dsl_definition.rb:141:in `namespace'
2: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task_manager.rb:232:in `in_namespace'
1: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/railties-6.1.7.2/lib/rails/tasks/engine.rake:5:in `block (2 levels) in <top (required)>'
/home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/railties-6.1.7.2/lib/rails/tasks/engine.rake:5:in `load': cannot load such file -- /home/kevin/Documents/[COMPANY_NAME]/Projets/[PROJECT_NAME]/test/dummy/Rakefile (LoadError)
It seems test/dummy/Rakefile
is searched by another Rakefile
we have in the root of our project:
The root Rakefile
content:
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
require 'rdoc/task'
RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'PROJECT_NAME::Core'
rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.md')
rdoc.rdoc_files.include('lib/**/*.rb')
end
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__) # see here (I have no clue what this is...)
load 'rails/tasks/engine.rake' # see here (I have no clue what this is... but that APP_RAKEFILE seems to be used by engine.rake)
load 'rails/tasks/statistics.rake'
require 'bundler/gem_tasks'
require 'rake/testtask'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = false
end
task default: :test
If I try to create this strange Rakefile
in /test/dummy/Rakefile
and re-run commands, here is what I get:
➜ PROJECT_NAME git:(some-branch-name) ✗ bundle exec annotate
bundler: failed to load command: annotate (/home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/bin/annotate)
Traceback (most recent call last):
32: from /home/kevin/.rbenv/versions/2.7.7/bin/bundle:23:in `<main>'
31: from /home/kevin/.rbenv/versions/2.7.7/bin/bundle:23:in `load'
30: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/bundler-2.4.12/exe/bundle:33:in `<top (required)>'
29: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/bundler-2.4.12/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
28: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/bundler-2.4.12/exe/bundle:45:in `block in <top (required)>'
27: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/bundler-2.4.12/lib/bundler/cli.rb:28:in `start'
26: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/bundler-2.4.12/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
25: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/bundler-2.4.12/lib/bundler/cli.rb:34:in `dispatch'
24: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/bundler-2.4.12/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
23: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/bundler-2.4.12/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
22: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/bundler-2.4.12/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
21: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/bundler-2.4.12/lib/bundler/cli.rb:492:in `exec'
20: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/bundler-2.4.12/lib/bundler/cli/exec.rb:23:in `run'
19: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/bundler-2.4.12/lib/bundler/cli/exec.rb:58:in `kernel_load'
18: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/bundler-2.4.12/lib/bundler/cli/exec.rb:58:in `load'
17: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/bin/annotate:23:in `<top (required)>'
16: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/bin/annotate:23:in `load'
15: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/annotate-3.2.0/bin/annotate:20:in `<top (required)>'
14: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/annotate-3.2.0/lib/annotate.rb:119:in `bootstrap_rake'
13: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/annotate-3.2.0/lib/annotate.rb:119:in `load'
12: from /home/kevin/Documents/[COMPANY_NAME]/Projets/[PROJECT_NAME]/Rakefile:18:in `<top (required)>'
11: from /home/kevin/Documents/[COMPANY_NAME]/Projets/[PROJECT_NAME]/Rakefile:18:in `load'
10: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/railties-6.1.7.2/lib/rails/tasks/engine.rake:85:in `<top (required)>'
9: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
8: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
7: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
6: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
5: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
4: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
3: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
2: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
1: from /home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/railties-6.1.7.2/lib/rails/tasks/engine.rake:21:in `block in <top (required)>'
/home/kevin/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/railties-6.1.7.2/lib/rails/tasks/engine.rake:78:in `find_engine_path': undefined method `find' for Rails::Engine:Class (NoMethodError)
I have also tried to remove these 2 lines from the main Rakefile but it seems to do nothing then when I execute the command.
Sooo, yeah, I'm stuck and I have no clue on what is going on and what I can do to fix this :D
Am I missing something?
If anyone has some ideas with this, I would be glad to try it!
Thank you!
Do you have an example repo with the problem that you're facing? It might be easier to reproduce. Also, I created a fork that may be worth trying out https://github.com/drwl/annotaterb
Not really :(
But I will give a try to the fork, thanks :)