ruby Jekyll - 找不到命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8146249/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Jekyll - command not found
提问by DADU
I am trying to get Jekyllrunning but I have no experience with Ruby.
As far as I can tell the installation of Jekyll has succeeded.
However:
我试图让Jekyll运行,但我没有使用 Ruby 的经验。
据我所知,Jekyll 的安装已经成功。
然而:
$ jekyll
Gives an error:
给出一个错误:
-bash: jekyll: command not found
This is the gem envresult:
这是gem env结果:
- RUBYGEMS VERSION: 1.3.4
- RUBY VERSION: 1.8.7 (2010-01-10 patchlevel 249) [universal-darwin10.0]
- INSTALLATION DIRECTORY: /Volumes/HDD/DADU/gems
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
- EXECUTABLE DIRECTORY: /Volumes/HDD/DADU/gems/bin
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-10
- GEM PATHS:
- /Volumes/HDD/DADU/gems
- /Volumes/HDD/DADU/.gem/ruby/1.8
- /Library/Ruby/Gems/1.8
- /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://gems.rubyforge.org/
And I found the following paths leading to "something" Jekyll:
我发现了以下通向“某物” Jekyll 的路径:
~.gem/ruby/1.8/gems/jekyll-0.11.0/lib/jekyll.rb~.gem/ruby/1.8/gems/bin/jekyll(exec file)
~.gem/ruby/1.8/gems/jekyll-0.11.0/lib/jekyll.rb~.gem/ruby/1.8/gems/bin/jekyll(执行文件)
采纳答案by Kassym Dorsel
The easiest method of doing this is to use RVM. It manages Ruby and all its gems for you and it's easy to use. See this linkfor using it.
最简单的方法是使用 RVM。它为您管理 Ruby 及其所有 gem,并且易于使用。请参阅此链接以使用它。
If you did not want to use that you will need to modify your PATH variables so it can find your gems. I have found this to be tedious and reverted to RVM, but here are the general steps.
如果您不想使用它,您将需要修改您的 PATH 变量,以便它可以找到您的宝石。我发现这很乏味并恢复到 RVM,但这里是一般步骤。
You will need to find out where your gems are getting installed. If you did gem install ...the gems will be in ~/.gem/ruby/1.8/gems/bin, if you used sudo gem install ...the gems will be somewhere in /System/Library/Frameworks/Ruby.framework/Versions/1.8/Resources
您将需要找出您的 gem 安装在哪里。如果你做gem install ...了,宝石会在~/.gem/ruby/1.8/gems/bin,如果你用过sudo gem install ...,宝石会在某处/System/Library/Frameworks/Ruby.framework/Versions/1.8/Resources
You have to add this path to your PATH variable. Easiest way to do this is by running :
echo 'PATH=$PATH:above/path/to/gems' >> ~/.bash_profile
您必须将此路径添加到 PATH 变量中。最简单的方法是运行:
echo 'PATH=$PATH:above/path/to/gems' >> ~/.bash_profile
回答by another
If you are using MacOS, from the Troubleshooting guide:
如果您使用的是 MacOS,请参阅故障排除指南:
Jekyll & Mac OS X 10.11Permalink
With the introduction of System Integrity Protection, several directories that were previously writable are now considered system locations and are no longer available. Given these changes, there are a couple of simple ways to get up and running. One option is to change the location where the gem will be installed (again, using sudo only if necessary):
$ gem install -n /usr/local/bin jekyll
Jekyll 和 Mac OS X 10.11 永久链接
随着系统完整性保护的引入,以前可写的几个目录现在被视为系统位置并且不再可用。鉴于这些变化,有几种简单的方法可以启动和运行。一种选择是更改将安装 gem 的位置(同样,仅在必要时使用 sudo):
$ gem install -n /usr/local/bin jekyll
回答by coderigo
For others coming here with the following set up:
对于使用以下设置来到这里的其他人:
OS X+ brewedinstall of ruby + (possibly) zsh
OS X+ brewed安装 ruby +(可能)zsh
I figured the problem is that after installing jekyllas per their instructions, gem installs the jekyll gem in the brewcellar, not where the OS usually expects it (somehwere in a gem directory for ruby).
我认为问题在于,在按照他们的说明安装jekyll之后,gem 将 jekyll gem 安装在brew地窖中,而不是操作系统通常期望的位置(一些在 ruby 的 gem 目录中)。
So, all that was needed here was to find out where the brewinstall of ruby installs gems, locate the jekyll binary, and create a symbolic link to it in /usr/bin.
所以,这里需要做的就是找出ruby的brewinstall在哪里安装 gems,找到 jekyll 二进制文件,并在/usr/bin.
Here is are the steps I took to fix it:
以下是我修复它的步骤:
Type
gem envand look for GEM PATHS. For me it was:/usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1.Make sure you can see the
jekyllbinary in the directory from 1above and copy its path (if you can't, search any other paths listed in GEM PATHSfor it). For me it was:/usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/jekyll-1.4.3/bin/jekyllUse the path from step 2above to create a symlink to
/usr/bin/jekyll. I did it by typing this (you might needsudoto create the symlink):cd /usr/bin && ln -s /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/jekyll-1.4.3/bin/jekyll jekyll
输入
gem env并寻找GEM PATHS。对我来说是:/usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1.确保您可以
jekyll在上面1的目录中看到二进制文件并复制其路径(如果不能,请搜索GEM PATHS 中列出的任何其他路径)。对我来说是:/usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/jekyll-1.4.3/bin/jekyll使用上面第2步中的路径创建指向
/usr/bin/jekyll. 我是通过输入这个来完成的(你可能需要sudo创建符号链接):cd /usr/bin && ln -s /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/jekyll-1.4.3/bin/jekyll jekyll
Now all should be merry if you type jekyll.
现在,如果您键入 ,一切都应该很愉快jekyll。
回答by Scro
If you are using RBENV instead of RVM you simply need to run rehashin the command line after installing jekyll:
如果你使用 RBENV 而不是 RVM,你只需要rehash在安装 jekyll 后在命令行中运行:
rbenv rehash
回答by Guedes
Maybe a little late, but...
I had some trouble to install Jekyll on Ubuntu and tried everything that people answered in this thread - unfortunately nothing worked.
Then, I watched a video on Jekyll's site and after installing the whole ruby package again, sudo gem install jekyllworked.
也许有点晚了,但是......我在 Ubuntu 上安装 Jekyll 时遇到了一些麻烦,并尝试了人们在此线程中回答的所有内容 - 不幸的是没有任何效果。
然后,我在 Jekyll 的网站上观看了一段视频,在再次安装了整个 ruby 包后,sudo gem install jekyll工作正常。
Try it before anything else:
先试试看:
sudo apt-get update
sudo apt-get install ruby-full
sudo gem install jekyll
jekyll -v
It seems pretty simple, but it works on Ubuntu.
这看起来很简单,但它适用于 Ubuntu。
回答by OutOfFoodException
I installed my ruby2.6.0and gemvia brew on MacOS 10.14.
For me, add the following line to my ~/.zshrcsolved this issue.
我在 MacOS 10.14 上安装了我的ruby2.6.0和gem通过 brew。
对我来说,将以下行添加到我~/.zshrc解决的这个问题中。
export PATH=/usr/local/lib/ruby/gems/2.6.0/bin:$PATH
I found jekyll executable file with command locate jekyll.
我用命令找到了 jekyll 可执行文件locate jekyll。
回答by Santa Zhang
One solution would be editing your ~/.bashrcfile and add this line:
一种解决方案是编辑您的~/.bashrc文件并添加以下行:
PATH=$PATH:~/.gem/ruby/1.8/gems/bin
PATH=$PATH:~/.gem/ruby/1.8/gems/bin
This will add ~/.gem/ruby/1.8/gems/binin Bash's lookup path.
这将添加~/.gem/ruby/1.8/gems/bin到 Bash 的查找路径中。
Reopen the terminal and it should work. Or you can use the following command:
重新打开终端,它应该可以工作。或者您可以使用以下命令:
. ~/.bashrc
. ~/.bashrc
回答by Ashwin Aggarwal
Following steps solved my problem
以下步骤解决了我的问题
gem uninstall jekyll
sudo gem install jekyll
Open ~/.bash_profile and add this code in the last line,
打开 ~/.bash_profile 并在最后一行添加此代码,
export PATH=$PATH:/usr/local/lib/ruby/gems/1.9.1/gems/jekyll-2.5.2/bin
Save and close the .bash_profile
保存并关闭 .bash_profile
Close and reopen the mac terminal, try running jekyllnow, it should work
关闭并重新打开 mac 终端,jekyll现在尝试运行,它应该可以工作
回答by Jenny Ly
回答by Charles
Easier than creating a symlink just install it correctly. If you got permission errors like a lot of people are getting when trying to use
比创建符号链接更容易,只需正确安装即可。如果您遇到很多人在尝试使用时遇到的权限错误
gem install jekyll
instead use
而是使用
sudo gem install jekyll

