升级 Ubuntu/Ruby 后 Jekyll 崩溃

升级 Ubuntu/Ruby 后 Jekyll 崩溃

我在 Ubuntu 笔记本电脑上使用 Jekyll。它适用于 15.10。我升级到 16.04 后收到以下错误消息:

$ jekyll -v
bash: /usr/local/bin/jekyll : /usr/bin/ruby2.1 : bad interpreter: no file or folder

这是已安装的 Ruby 版本:

$ ruby -v
ruby 2.3.0p0 (2015-12-25) [i386-linux-gnu]

我试过了:

$ gem update jekyll
Updating installed gems
Nothing to update

作为which ruby回报/usr/bin/ruby,我已更新/usr/local/bin/jekyll更改#!/usr/bin/ruby2.1#!/usr/bin/ruby

现在我得到:

$ jekyll -v
/usr/lib/ruby/2.3.0/rubygems/dependency.rb:319:in 'to_specs': Could not find 'jekyll' (>= 0) among 11 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=/home/samuel/.gem/ruby/2.3.0:/var/lib/gems/2.3.0:/usr/lib/i386-linux-gnu/rubygems-integration/2.3.0:/usr/share/rubygems-integration/2.3.0:/usr/share/rubygems-integration/all', execute 'gem env` for more information
    from /usr/lib/ruby/2.3.0/rubygems/dependency.rb:328:in 'to_spec'
    from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_gem.rb:65:in 'gem'
    from /usr/local/bin/jekyll:22:in 'main'

返回结果如下gem env

$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 2.5.1
  - RUBY VERSION: 2.3.0 (2015-12-25 patchlevel 0) [i386-linux-gnu]
  - INSTALLATION DIRECTORY: /var/lib/gems/2.3.0
  - USER INSTALLATION DIRECTORY: /home/samuel/.gem/ruby/2.3.0
  - RUBY EXECUTABLE: /usr/bin/ruby2.3
  - EXECUTABLE DIRECTORY: /usr/local/bin
  - SPEC CACHE DIRECTORY: /home/samuel/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-linux
  - GEM PATHS:
     - /var/lib/gems/2.3.0
     - /home/samuel/.gem/ruby/2.3.0
     - /usr/lib/i386-linux-gnu/rubygems-integration/2.3.0
     - /usr/share/rubygems-integration/2.3.0
     - /usr/share/rubygems-integration/all
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /usr/local/sbin
     - /usr/local/bin
     - /usr/sbin
     - /usr/bin
     - /sbin
     - /bin
     - /usr/games
     - /usr/local/games
     - /snap/bin

答案1

我遇到了同样的问题。这是由新 Ubuntu 中的 ruby​​ 更新引起的。只需卸载 jekyll 并重新安装即可:

gem uninstall jekyll
gem install jekyll

答案2

除了@Piotr的回答之外,我还必须卸载并重新安装 gem bundler。也就是说,我跑了,

gem uninstall bundler
gem install bundler
bundle

只有在我从 ubuntu 18.04 升级到 20.04 后,它才bundle exec jekyll serve开始再次工作。

相关内容