安装 petergate returns 错误“找不到生成器 'petergate:install'”

Installing petergate returns error `Could not find generator 'petergate:install'`

我一直收到这个错误。全文如下:

$ rails g petergate:install
Running via Spring preloader in process 96515
Could not find generator 'petergate:install'. Maybe you meant 'devise:install', 'responders:install' or 'integration_test'
Run `rails generate --help` for more options.

我已经 运行 bundle install。 gem 安装在我的 gem 目录中。我知道这应该没什么区别,但是 Devise 已经安装并且我的用户模型被称为 user.rb.

奇怪的是,当我尝试重现该问题时,通过创建一个新应用程序并安装 devise 然后安装 petergate,这一代成功了。

我尝试卸载 petergate,将其从我的捆绑包中取出并重新放入,bundle/bundle install/bundle update 的每个组合,将其移动到gem 文件的顶部,尝试 rails generate 而不是 rails g ,重新启动我的计算机,但似乎没有任何效果。

我的Gemfile如下:

source 'https://rubygems.org'
git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.5'
gem 'petergate', '~> 1.8', '>= 1.8.1'
# Use postgresql as the database for Active Record
gem 'pg', '>= 0.18', '< 2.0'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  gem 'pry-byebug'
end
group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '>= 3.0.5', '< 3.2'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'friendly_id', '~> 5.1.0'
gem 'devise', '~> 4.4', '>= 4.4.2'
gem 'bootstrap', '~> 4.0.0'

Gemfile.lock:

GEM
  remote: https://rubygems.org/
  specs:
    actioncable (5.1.6)
      actionpack (= 5.1.6)
      nio4r (~> 2.0)
      websocket-driver (~> 0.6.1)
    actionmailer (5.1.6)
      actionpack (= 5.1.6)
      actionview (= 5.1.6)
      activejob (= 5.1.6)
      mail (~> 2.5, >= 2.5.4)
      rails-dom-testing (~> 2.0)
    actionpack (5.1.6)
      actionview (= 5.1.6)
      activesupport (= 5.1.6)
      rack (~> 2.0)
      rack-test (>= 0.6.3)
      rails-dom-testing (~> 2.0)
      rails-html-sanitizer (~> 1.0, >= 1.0.2)
    actionview (5.1.6)
      activesupport (= 5.1.6)
      builder (~> 3.1)
      erubi (~> 1.4)
      rails-dom-testing (~> 2.0)
      rails-html-sanitizer (~> 1.0, >= 1.0.3)
    activejob (5.1.6)
      activesupport (= 5.1.6)
      globalid (>= 0.3.6)
    activemodel (5.1.6)
      activesupport (= 5.1.6)
    activerecord (5.1.6)
      activemodel (= 5.1.6)
      activesupport (= 5.1.6)
      arel (~> 8.0)
    activesupport (5.1.6)
      concurrent-ruby (~> 1.0, >= 1.0.2)
      i18n (>= 0.7, < 2)
      minitest (~> 5.1)
      tzinfo (~> 1.1)
    arel (8.0.0)
    autoprefixer-rails (8.2.0)
      execjs
    bcrypt (3.1.11)
    bindex (0.5.0)
    bootstrap (4.0.0)
      autoprefixer-rails (>= 6.0.3)
      popper_js (>= 1.12.9, < 2)
      sass (>= 3.5.2)
    builder (3.2.3)
    byebug (10.0.2)
    coderay (1.1.2)
    coffee-rails (4.2.2)
      coffee-script (>= 2.2.0)
      railties (>= 4.0.0)
    coffee-script (2.4.1)
      coffee-script-source
      execjs
    coffee-script-source (1.12.2)
    concurrent-ruby (1.0.5)
    crass (1.0.3)
    devise (4.4.3)
      bcrypt (~> 3.0)
      orm_adapter (~> 0.1)
      railties (>= 4.1.0, < 6.0)
      responders
      warden (~> 1.2.3)
    erubi (1.7.1)
    execjs (2.7.0)
    ffi (1.9.23)
    friendly_id (5.1.0)
      activerecord (>= 4.0.0)
    globalid (0.4.1)
      activesupport (>= 4.2.0)
    i18n (1.0.0)
      concurrent-ruby (~> 1.0)
    jbuilder (2.7.0)
      activesupport (>= 4.2.0)
      multi_json (>= 1.2)
    jquery-rails (4.3.1)
      rails-dom-testing (>= 1, < 3)
      railties (>= 4.2.0)
      thor (>= 0.14, < 2.0)
    listen (3.1.5)
      rb-fsevent (~> 0.9, >= 0.9.4)
      rb-inotify (~> 0.9, >= 0.9.7)
      ruby_dep (~> 1.2)
    loofah (2.2.2)
      crass (~> 1.0.2)
      nokogiri (>= 1.5.9)
    mail (2.7.0)
      mini_mime (>= 0.1.1)
    method_source (0.9.0)
    mini_mime (1.0.0)
    mini_portile2 (2.3.0)
    minitest (5.11.3)
    multi_json (1.13.1)
    nio4r (2.3.0)
    nokogiri (1.8.2)
      mini_portile2 (~> 2.3.0)
    orm_adapter (0.5.0)
    petergate (1.8.1)
      activerecord (> 4.0.0)
    pg (1.0.0)
    popper_js (1.12.9)
    pry (0.11.3)
      coderay (~> 1.1.0)
      method_source (~> 0.9.0)
    pry-byebug (3.6.0)
      byebug (~> 10.0)
      pry (~> 0.10)
    puma (3.11.3)
    rack (2.0.4)
    rack-test (1.0.0)
      rack (>= 1.0, < 3)
    rails (5.1.6)
      actioncable (= 5.1.6)
      actionmailer (= 5.1.6)
      actionpack (= 5.1.6)
      actionview (= 5.1.6)
      activejob (= 5.1.6)
      activemodel (= 5.1.6)
      activerecord (= 5.1.6)
      activesupport (= 5.1.6)
      bundler (>= 1.3.0)
      railties (= 5.1.6)
      sprockets-rails (>= 2.0.0)
    rails-dom-testing (2.0.3)
      activesupport (>= 4.2.0)
      nokogiri (>= 1.6)
    rails-html-sanitizer (1.0.4)
      loofah (~> 2.2, >= 2.2.2)
    railties (5.1.6)
      actionpack (= 5.1.6)
      activesupport (= 5.1.6)
      method_source
      rake (>= 0.8.7)
      thor (>= 0.18.1, < 2.0)
    rake (12.3.1)
    rb-fsevent (0.10.3)
    rb-inotify (0.9.10)
      ffi (>= 0.5.0, < 2)
    responders (2.4.0)
      actionpack (>= 4.2.0, < 5.3)
      railties (>= 4.2.0, < 5.3)
    ruby_dep (1.5.0)
    sass (3.5.6)
      sass-listen (~> 4.0.0)
    sass-listen (4.0.0)
      rb-fsevent (~> 0.9, >= 0.9.4)
      rb-inotify (~> 0.9, >= 0.9.7)
    sass-rails (5.0.7)
      railties (>= 4.0.0, < 6)
      sass (~> 3.1)
      sprockets (>= 2.8, < 4.0)
      sprockets-rails (>= 2.0, < 4.0)
      tilt (>= 1.1, < 3)
    spring (2.0.2)
      activesupport (>= 4.2)
    spring-watcher-listen (2.0.1)
      listen (>= 2.7, < 4.0)
      spring (>= 1.2, < 3.0)
    sprockets (3.7.1)
      concurrent-ruby (~> 1.0)
      rack (> 1, < 3)
    sprockets-rails (3.2.1)
      actionpack (>= 4.0)
      activesupport (>= 4.0)
      sprockets (>= 3.0.0)
    thor (0.20.0)
    thread_safe (0.3.6)
    tilt (2.0.8)
    turbolinks (5.1.0)
      turbolinks-source (~> 5.1)
    turbolinks-source (5.1.0)
    tzinfo (1.2.5)
      thread_safe (~> 0.1)
    uglifier (4.1.8)
      execjs (>= 0.3.0, < 3)
    warden (1.2.7)
      rack (>= 1.0)
    web-console (3.5.1)
      actionview (>= 5.0)
      activemodel (>= 5.0)
      bindex (>= 0.4.0)
      railties (>= 5.0)
    websocket-driver (0.6.5)
      websocket-extensions (>= 0.1.0)
    websocket-extensions (0.1.3)

PLATFORMS
  ruby

DEPENDENCIES
  bootstrap (~> 4.0.0)
  byebug
  coffee-rails (~> 4.2)
  devise (~> 4.4, >= 4.4.2)
  friendly_id (~> 5.1.0)
  jbuilder (~> 2.5)
  jquery-rails
  listen (>= 3.0.5, < 3.2)
  petergate (~> 1.8, >= 1.8.1)
  pg (>= 0.18, < 2.0)
  pry-byebug
  puma (~> 3.7)
  rails (~> 5.1.5)
  sass-rails (~> 5.0)
  spring
  spring-watcher-listen (~> 2.0.0)
  turbolinks (~> 5)
  tzinfo-data
  uglifier (>= 1.3.0)
  web-console (>= 3.3.0)

BUNDLED WITH
   1.16.1

有人知道这可能是什么吗?我正在撕扯我的头发。

好的,所以我最终解决了这个问题,方法如下。这是一个非常非常 hacky 的解决方案,但是当所有其他方法都失败时...

因为它正在开发一个全新的应用程序,所以我在 运行 petergate:install 之前和之后提交了这个新应用程序。然后我推到 github 并比较了两者。

更改实际上非常简单 - 一个小的迁移,向您的 User.rb 模型添加了一些文本。所以我做了同样的事情。嘿,很快,它现在可以工作了,并且与 gem 的交互也是如此,所以我不确定问题出在哪里。

在更复杂的 gem 中,您将来可能需要其他 command-line 功能,或者安装会进行大量更改,这更有可能成为问题,但是在像这样的简单 gem 上,它似乎工作正常。

希望这对遇到相同(或类似)问题的任何人有所帮助。