Error when running Jekyll: cannot load such file — google/api_client (LoadError)

谁都会走 提交于 2019-12-12 00:14:58

问题


I had to reinstall OS X Yosemite 10.10.5 and now I get the following error when running my Jekyll site (previously it was working fine):

MacBook-Pro-Svetlana:iloveip svetlana$ jekyll serve
WARN: Unresolved specs during Gem::Specification.reset:
      pygments.rb (~> 0.6.0)
      redcarpet (~> 3.1)
      jekyll-watch (~> 1.1)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
Configuration file: /Users/svetlana/Desktop/iloveip/_config.yml
/Users/svetlana/Desktop/iloveip/_plugins/page_view.rb:4:in `require': cannot load such file -- google/api_client (LoadError)
    from /Users/svetlana/Desktop/iloveip/_plugins/page_view.rb:4:in `<top (required)>'
    from /usr/local/lib/ruby/gems/2.2.0/gems/jekyll-2.5.3/lib/jekyll/plugin_manager.rb:74:in `require'
    from /usr/local/lib/ruby/gems/2.2.0/gems/jekyll-2.5.3/lib/jekyll/plugin_manager.rb:74:in `block (2 levels) in require_plugin_files'
    from /usr/local/lib/ruby/gems/2.2.0/gems/jekyll-2.5.3/lib/jekyll/plugin_manager.rb:73:in `each'
    from /usr/local/lib/ruby/gems/2.2.0/gems/jekyll-2.5.3/lib/jekyll/plugin_manager.rb:73:in `block in require_plugin_files'
    from /usr/local/lib/ruby/gems/2.2.0/gems/jekyll-2.5.3/lib/jekyll/plugin_manager.rb:72:in `each'
    from /usr/local/lib/ruby/gems/2.2.0/gems/jekyll-2.5.3/lib/jekyll/plugin_manager.rb:72:in `require_plugin_files'
    from /usr/local/lib/ruby/gems/2.2.0/gems/jekyll-2.5.3/lib/jekyll/plugin_manager.rb:18:in `conscientious_require'
    from /usr/local/lib/ruby/gems/2.2.0/gems/jekyll-2.5.3/lib/jekyll/site.rb:79:in `setup'
    from /usr/local/lib/ruby/gems/2.2.0/gems/jekyll-2.5.3/lib/jekyll/site.rb:41:in `initialize'
    from /usr/local/lib/ruby/gems/2.2.0/gems/jekyll-2.5.3/lib/jekyll/commands/build.rb:29:in `new'
    from /usr/local/lib/ruby/gems/2.2.0/gems/jekyll-2.5.3/lib/jekyll/commands/build.rb:29:in `process'
    from /usr/local/lib/ruby/gems/2.2.0/gems/jekyll-2.5.3/lib/jekyll/commands/serve.rb:26:in `block (2 levels) in init_with_program'
    from /usr/local/lib/ruby/gems/2.2.0/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `call'
    from /usr/local/lib/ruby/gems/2.2.0/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `block in execute'
    from /usr/local/lib/ruby/gems/2.2.0/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `each'
    from /usr/local/lib/ruby/gems/2.2.0/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `execute'
    from /usr/local/lib/ruby/gems/2.2.0/gems/mercenary-0.3.5/lib/mercenary/program.rb:42:in `go'
    from /usr/local/lib/ruby/gems/2.2.0/gems/mercenary-0.3.5/lib/mercenary.rb:19:in `program'
    from /usr/local/lib/ruby/gems/2.2.0/gems/jekyll-2.5.3/bin/jekyll:20:in `<top (required)>'
    from /usr/local/bin/jekyll:23:in `load'
    from /usr/local/bin/jekyll:23:in `<main>'

I have 'google-api-client' gem installed for one of my plugins. And Ruby was installed using Homebrew brew install ruby. When I check Ruby version I get:

MacBook-Pro-Svetlana:iloveip svetlana$ ruby -v
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]

But when I run $ gem list google-api-client -d I get:

MacBook-Pro-Svetlana:iloveip svetlana$ gem list google-api-client -d

*** LOCAL GEMS ***

google-api-client (0.8.6)
    Authors: Bob Aman, Steven Bazyl
    Homepage: https://github.com/google/google-api-ruby-client/
    License: Apache-2.0
    Installed at: /usr/local/lib/ruby/gems/2.2.0

    The Google API Ruby Client makes it trivial to discover and access
    Google's REST APIs.

I guess it has to do something with different Ruby versions installed on my computer. As the gem was installed with $ sudo gem install google-api-client. How can I fix that?

(Previously Ruby was installed using RVM, but I got some errors installing Jekyll, so I uninstalled RVM.)

Here's information about my gem environment:

MacBook-Pro-Svetlana:~ svetlana$ gem environment
RubyGems Environment:
  - RUBYGEMS VERSION: 2.4.5.1
  - RUBY VERSION: 2.2.3 (2015-08-18 patchlevel 173) [x86_64-darwin14]
  - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.2.0
  - RUBY EXECUTABLE: /usr/local/opt/ruby/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/local/bin
  - SPEC CACHE DIRECTORY: /Users/svetlana/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /usr/local/Cellar/ruby/2.2.3/etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-14
  - GEM PATHS:
     - /usr/local/lib/ruby/gems/2.2.0
     - /Users/svetlana/.gem/ruby/2.2.0
     - /usr/local/Cellar/ruby/2.2.3/lib/ruby/gems/2.2.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - :sources => ["https://rubygems.org/"]
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /Users/svetlana/.rvm/bin

回答1:


Mmmm. I've been looking for this problem. I've found several links with the same or similar. Try this:

In _plugins/page_view.rb file, line 4, put

require "google/api_client"

instead of

require "google-api-client"

It seems there is an erroneous require.



来源:https://stackoverflow.com/questions/32677409/error-when-running-jekyll-cannot-load-such-file-google-api-client-loaderror

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!