我尝试使用Jekyll新命令,但它不起作用并且出现错误。
$ jekyll new myblog
/Library/Ruby/Gems/1.8/gems/commander-4.1.6/lib/commander/runner.rb:385:in `require_program': program version required (Commander::Runner::CommandError)
from /Library/Ruby/Gems/1.8/gems/commander-4.1.6/lib/commander/runner.rb:384:in `each'
from /Library/Ruby/Gems/1.8/gems/commander-4.1.6/lib/commander/runner.rb:384:in `require_program'
from /Library/Ruby/Gems/1.8/gems/commander-4.1.6/lib/commander/runner.rb:52:in `run!'
from /Library/Ruby/Gems/1.8/gems/commander-4.1.6/lib/commander/delegates.rb:8:in `run!'
from /Library/Ruby/Gems/1.8/gems/commander-4.1.6/lib/commander/import.rb:10
from /usr/bin/jekyll:23
/Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:55:in `gem_original_require': no such file to load -- json (LoadError)
from /Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Library/Ruby/Gems/1.8/gems/jekyll-1.4.3/bin/../lib/jekyll/filters.rb:2
from /Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:55:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Library/Ruby/Gems/1.8/gems/jekyll-1.4.3/bin/../lib/jekyll.rb:44
from /Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:55:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Library/Ruby/Gems/1.8/gems/jekyll-1.4.3/bin/jekyll:7
from /usr/bin/jekyll:23:in `load'
from /usr/bin/jekyll:23
我正在使用Mac OS X 10.8.5 Mountain Lion。 我检查了stackoverflow,发现了一个有类似问题的帖子。 Error when running jekyll new command 然后我尝试了下面的命令。
$ sudo gem install json
但它对我的情况不起作用。我卸载并重新安装了json但没有任何反应。 如果您知道任何其他解决方案,请告诉我。自本周开始以来,我一直坚持这个问题......
我的宝石列表&宝石环境如下。
$ gem list
*** LOCAL GEMS ***
bigdecimal (1.2.4)
blankslate (2.1.2.4)
classifier (1.3.4)
colorator (0.1)
commander (4.1.6)
fast-stemmer (1.0.2)
ffi (1.9.3)
highline (1.6.21)
io-console (0.4.2)
jekyll (1.4.3)
json (1.8.1)
liquid (2.5.5)
listen (1.3.1)
maruku (0.7.1)
minitest (4.7.5)
parslet (1.5.0)
posix-spawn (0.3.8)
psych (2.0.3)
pygments.rb (0.5.4)
rake (10.1.0)
rb-fsevent (0.9.4)
rb-inotify (0.9.3)
rb-kqueue (0.2.2)
rdoc (4.1.0)
redcarpet (2.3.0)
safe_yaml (0.9.7)
test-unit (2.1.1.0)
toml (0.1.1)
yajl-ruby (1.1.0)
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.2.2
- RUBY VERSION: 2.1.1 (2014-02-24 patchlevel 76) [x86_64-darwin12.0]
- INSTALLATION DIRECTORY: /usr/local/Cellar/ruby/2.1.1/lib/ruby/gems/2.1.0
- RUBY EXECUTABLE: /usr/local/Cellar/ruby/2.1.1/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/Cellar/ruby/2.1.1/bin
- SPEC CACHE DIRECTORY: /Users/MyName/.gem/specs
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-12
- GEM PATHS:
- /usr/local/Cellar/ruby/2.1.1/lib/ruby/gems/2.1.0
- /Users/MyName/.gem/ruby/2.1.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /usr/local/bin
- /usr/local/bin
- /usr/local/sbin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /usr/local/git/bin
- /Users/MyName/.rvm/bin
请给我建议帮助我。谢谢!
于3月7日更新。
$ rvm list
rvm rubies
# No rvm rubies installed yet. Try 'rvm help install'.
以防万一你希望看到Homebrew列表,
$ brew list
autoconf gmp4 libtool openssl readline
automake libgpg-error libyaml pkg-config ruby
cloog-ppl015 libksba llvm ppl011 ruby-build
gcc46 libmpc08 mpfr2 rbenv
2月3日更新。
$ which ruby
/usr/local/bin/ruby
$ which jekyll
/usr/bin/jekyll
$ ruby --version
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin12.0]
$ echo $PATH
/usr/local/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin:/Users/MyName/.rvm/bin
我记得在安装2.1.1p76之前我的mac已经安装了Ruby 1.8.7。
答案 0 :(得分:9)
您的系统上看起来有多个版本的Ruby(1.8.7和2.1.1),这很常见,部分原因是rvm
和rbenv
等工具被创建了。问题是,当你gem install jekyll
(可能有一个sudo
)和sudo gem install json
时,这些似乎最终会出现在不同的地方并且找不到对方。 /usr/local/bin
位置通常是Homebrew放置的位置(因此,ruby
下列出了brew list
),这是您的Ruby 2.1.1位置。但是,您的jekyll
安装位于Apple安装的Ruby 1.8.7的位置。
第1步:尝试gem uninstall jekyll
,然后gem install jekyll
。这应该可以解决你的问题。
第2步:如果不起作用,请尝试使用rbenv或rvm选择不同版本的Ruby,然后再次尝试第1步。
例如,我的安装位于此处(通过rvm
进行管理):
$ which jekyll
/Users/nicksuch/.rvm/gems/ruby-2.0.0-p247/bin/jekyll
$ which gem
/Users/nicksuch/.rvm/rubies/ruby-2.0.0-p247/bin/gem
$ which ruby
/Users/nicksuch/.rvm/rubies/ruby-2.0.0-p247/bin/ruby
答案 1 :(得分:4)
在我的案例中,Jekyll模板建议使用bundle
实用程序:
bundle exec jekyll build
解决方案是将json
纳入Gemfile
(已经是来源的一部分):
diff --git a/Gemfile b/Gemfile
index 98b29af..b8537cf 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,7 +1,8 @@
source "https://rubygems.org"
+gem "json"
gem "jekyll", "~> 3.0"
gem "jekyll-sitemap"
<强>详情
让我解决的是以下事实:
gem list json
显示json
gem已安装; bundle exec gem list json
命令没有显示任何内容。我还试图运行bundle exec gem install json
- 它没有用。我最好的猜测是bundle
基于Gemfile
为单个运行设置环境,这是在每个bundle exec ...
执行中使一组依赖关系保持一致的唯一方法。