首页 > 解决方案 > Gem::Specification:Class 的未定义方法 `stubs_for' (NoMethodError)

问题描述

这些天来,我尝试使用最小错误主题来构建我的 github 博客。

在最后的快速指南中有说

bundle exec jekyll serve

结果

`find_name': undefined method `stubs_for' for Gem::Specification:Class (NoMethodError)

具体的

C:\Users\all7j\Documents\project\elephantoid.github.io>bundle exec jekyll serve
Traceback (most recent call last):
        21: from C:/Ruby26-x64/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        20: from C:/Ruby26-x64/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        19: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/setup.rb:10:in `<top (required)>'
        18: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/ui/shell.rb:88:in `silence'
        17: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/ui/shell.rb:136:in `with_level'
        16: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/setup.rb:10:in `block in <top (required)>'
        15: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler.rb:149:in `setup'
        14: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:20:in `setup'
        13: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:101:in `block in definition_method'
        12: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/definition.rb:226:in `requested_specs'
        11: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/definition.rb:237:in `specs_for'
        10: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/definition.rb:170:in `specs'
         9: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/definition.rb:258:in `resolve'
         8: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/definition.rb:268:in `index'
         7: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/index.rb:11:in `build'
         6: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/definition.rb:271:in `block in index'
         5: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/definition.rb:271:in `each'
         4: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/definition.rb:273:in `block (2 levels) in index'
         3: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/source/metadata.rb:7:in `specs'
         2: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/index.rb:11:in `build'
         1: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/source/metadata.rb:28:in `block in specs'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/rubygems_integration.rb:623:in `find_name': undefined method `stubs_for' for Gem::Specification:Class (NoMethodError)
Did you mean?  stubs

我找不到 stubs_for 的内容。

而且我不知道是什么问题...我只是按照快速指南的步骤进行操作。

我在 Windows 上安装了 gem、ruby、bundler。并 fork GitHub,更新 _config.yml 等等……

标签: rubyrubygemsgithub-pages

解决方案


我有一个类似的案例是通过以下方式带给我的passenger.log

[ 2020-12-07 20:13:44.4960 18738/7f0b659e8700 agents/HelperAgent/RequestHandler.h:2306 ]: [Client 19] Cannot checkout session because a spawning error occurred. The identifier of the error is e907d6aa. Please see earlier logs for details about the error.
App 19579 stdout: 
App 19579 stdout: 
[ 2020-12-07 20:13:54.2571 18738/7f0b67e7c700 Pool2/Implementation.cpp:287 ]: Could not spawn process for application /data/appname/current: An error occured while starting up the preloader.
  Error ID: 61ed637e
  Error details saved to: /tmp/passenger-error-x96ujc.html
  Message from application: undefined method `stubs_for' for Gem::Specification:Class (NoMethodError)

就我而言,这是一个 ruby​​gems 版本更改。根据您的应用程序和预期版本,您希望在下面适当地替换它:

gem install -v 2.7.7 rubygems-update && gem update --system 2.7.7

您可能还想在重新安装之前卸载以前的 ruby​​gems-update:

gem uninstall rubygems-update

Select gem to uninstall:
 1. rubygems-update-2.4.8
 2. rubygems-update-2.6.13
 3. All versions
> 3
Successfully uninstalled rubygems-update-2.4.8
Remove executables:
    update_rubygems

in addition to the gem? [Yn]  y
Removing update_rubygems
Successfully uninstalled rubygems-update-2.6.13

并清理相应的文件夹:

rm -f /usr/local/bin/update_rubygems

您想将这些翻译到您的 Windows 机器位置/命令


推荐阅读