zsh: command not found: bundle
之后为何gem install bundler
?
我尝试在path=( /usr/local/lib/ruby/gems/2.2/gems/ ~/bin /bin /sbin /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin )
和/etc/zshrc
设置source /etc/zshrc
无效。
root@dev:/home/dev# gem install bundler
Successfully installed bundler-1.7.12
Parsing documentation for bundler-1.7.12
Done installing documentation for bundler after 10 seconds
1 gem installed
root@dev:/home/dev# bundle
zsh: command not found: bundle
root@dev:/home/dev# uname -a
OpenBSD dev.my.domain 5.7 GENERIC#748 amd64
root@dev:/home/dev# gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.5
- RUBY VERSION: 2.2.0 (2014-12-25 patchlevel 0) [x86_64-openbsd]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.2
- RUBY EXECUTABLE: /usr/local/bin/ruby22
- EXECUTABLE DIRECTORY: /usr/local/bin
- SPEC CACHE DIRECTORY: /root/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-openbsd
- GEM PATHS:
- /usr/local/lib/ruby/gems/2.2
- /usr/local/lib/ruby/gems/2.2/gems/
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /usr/local/lib/ruby/gems/2.2/gems/
- /root/bin
- /bin
- /sbin
- /usr/bin
- /usr/sbin
- /usr/local/bin
- /usr/local/sbin
答案 0 :(得分:24)
您似乎是在系统范围内安装bundler
之后。为此,您需要将--no-user-install
标记传递给gem
并使用sudo
执行该标记:
sudo gem install bundler --no-user-install
在此之后,您应该在bundle
中看到/usr/bin/
就好了:
$ ls /usr/bin/bundle
/usr/bin/bundle*
答案 1 :(得分:24)
我使用zsh遇到了同样的问题,并修复了它:
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshenv
$ echo 'eval "$(rbenv init -)"' >> ~/.zshenv
$ echo 'source $HOME/.zshenv' >> ~/.zshrc
$ exec $SHELL
答案 2 :(得分:8)
您可以使用gem environment
检查Rubygems将安装gem可执行文件的目录。
最初的一点应该是EXECUTABLE DIRECTORY
。确保此目录位于$PATH
(列为SHELL PATH
btw)
答案 3 :(得分:6)
安装bundler
后,你会发出以下命令:
rbenv rehash
答案 4 :(得分:2)
设置jekyll时也遇到了相同的错误。我的gem env
显示GEM PATHS
如下:
- GEM PATHS:
- /usr/local/lib/ruby/gems/2.5.0
此目录的内容如下:
bin/ cache/ extensions/ specifications/
build_info/ doc/ gems/
在bin
内,我同时看到jekyll
和bundle
:
$cd /usr/local/lib/ruby/gems/2.5.0/bin/
$ls
bundle jekyll listen safe_yaml sass-convert
bundler kramdown rougify sass scss
如果您发现与我相似的路径和文件,则可以使用以下任何一种方法:
通过以下方式将完整路径/usr/local/lib/ruby/gems/2.5.0/bin/
附加到PATH
:
export PATH="/usr/local/lib/ruby/gems/2.5.0/bin/:$PATH"
通过以下方式在/usr/local/bin
中建立符号链接:
$cd /usr/local/bin
$ln -sf /usr/local/lib/ruby/gems/2.5.0/bin/bundle .
$ln -sf /usr/local/lib/ruby/gems/2.5.0/bin/jekyll .
在.zshrc
(或.bashrc
等)中设置别名:
alias jekyll="/usr/local/lib/ruby/gems/2.5.0/bin/jekyll"
alias bundle="/usr/local/lib/ruby/gems/2.5.0/bin/bundle"
总的来说,我觉得所有这些路径的盲目性使得设置jekyll网站的体验比预期的要困难:(如果其他人有一套可行的步骤(不需要进行故障排除),请发表评论:)>