annotate gem rails 配置报错
annotate gem rails configuration give error
Ruby: 2.3.0p0
Rails 版本:4.2.6
注释gem版本:2.7.1
在做 rails g annotate:install
时给我这个错误:
(erb):34:in `template': uninitialized constant AnnotateModels (NameError)
from /Users/newput/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/erb.rb:864:in `eval'
from /Users/newput/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/erb.rb:864:in `result'
from /Users/newput/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions/file_manipulation.rb:116:in `block in template'
from /Users/newput/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:53:in `render'
from /Users/newput/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:62:in `block (2 levels) in invoke!'
from /Users/newput/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:62:in `open'
from /Users/newput/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:62:in `block in invoke!'
from /Users/newput/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions/empty_directory.rb:116:in `invoke_with_conflict_check'
from /Users/newput/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:60:in `invoke!'
from /Users/newput/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions.rb:94:in `action'
from /Users/newput/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:25:in `create_file'
from /Users/newput/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions/file_manipulation.rb:115:in `template'
from /Users/newput/.rvm/gems/ruby-2.3.0/gems/annotate-2.7.1/lib/generators/annotate/install_generator.rb:9:in `copy_tasks'
我不确定这是否解决了您的错误,但我按照以下步骤遇到了同样的错误:
$ rails new hi
$ cd hi
$ echo "gem 'annotate', '2.7.1', require: false" >> Gemfile
$ bundle
$ rails g annotate:install
Running via Spring preloader in process 29328
create lib/tasks/auto_annotate_models.rake
(erb):34:in `template': uninitialized constant AnnotateModels (NameError)
from /home/hibariya/.rbenv/versions/2.3.0/lib/ruby/2.3.0/erb.rb:864:in `eval'
from /home/hibariya/.rbenv/versions/2.3.0/lib/ruby/2.3.0/erb.rb:864:in `result'
from /home/hibariya/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/actions/file_manipulation.rb:116:in `block in template'
...
我认为这个错误可以通过提前要求 annotate-gem 来修复。
因此,当我从 Gemfile 中的 gem 'annotate', '2.7.1', require: false
中删除 require: false
时,错误已修复。
Ruby: 2.3.0p0
Rails 版本:4.2.6
注释gem版本:2.7.1
在做 rails g annotate:install
时给我这个错误:
(erb):34:in `template': uninitialized constant AnnotateModels (NameError)
from /Users/newput/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/erb.rb:864:in `eval'
from /Users/newput/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/erb.rb:864:in `result'
from /Users/newput/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions/file_manipulation.rb:116:in `block in template'
from /Users/newput/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:53:in `render'
from /Users/newput/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:62:in `block (2 levels) in invoke!'
from /Users/newput/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:62:in `open'
from /Users/newput/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:62:in `block in invoke!'
from /Users/newput/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions/empty_directory.rb:116:in `invoke_with_conflict_check'
from /Users/newput/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:60:in `invoke!'
from /Users/newput/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions.rb:94:in `action'
from /Users/newput/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:25:in `create_file'
from /Users/newput/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions/file_manipulation.rb:115:in `template'
from /Users/newput/.rvm/gems/ruby-2.3.0/gems/annotate-2.7.1/lib/generators/annotate/install_generator.rb:9:in `copy_tasks'
我不确定这是否解决了您的错误,但我按照以下步骤遇到了同样的错误:
$ rails new hi
$ cd hi
$ echo "gem 'annotate', '2.7.1', require: false" >> Gemfile
$ bundle
$ rails g annotate:install
Running via Spring preloader in process 29328
create lib/tasks/auto_annotate_models.rake
(erb):34:in `template': uninitialized constant AnnotateModels (NameError)
from /home/hibariya/.rbenv/versions/2.3.0/lib/ruby/2.3.0/erb.rb:864:in `eval'
from /home/hibariya/.rbenv/versions/2.3.0/lib/ruby/2.3.0/erb.rb:864:in `result'
from /home/hibariya/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/actions/file_manipulation.rb:116:in `block in template'
...
我认为这个错误可以通过提前要求 annotate-gem 来修复。
因此,当我从 Gemfile 中的 gem 'annotate', '2.7.1', require: false
中删除 require: false
时,错误已修复。