Ruby-on-rails 找不到 OSX bundler 安装命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16950130/
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
OSX bundler install command not found
提问by Al1nuX
I'm getting this error:
我收到此错误:
Could not find i18n-0.6.1 in any of the sources
Run bundle installto install missing gems.
在任何来源中都找不到 i18n-0.6.1 运行bundle install以安装丢失的 gem。
When i try to run bundle install, i get this:
当我尝试运行 bundle install 时,我得到了这个:
-bash: bundle: command not found
-bash: bundle: command not found
I have googled and tried to solve this for a while now with no hope. Please help.
我已经用谷歌搜索并试图解决这个问题一段时间,但没有希望。请帮忙。
回答by l3x
Don't mess with your PATH.
不要弄乱你的路径。
Just use rbenvand ruby-buildto manage and install your ruby version(s).
只需使用rbenv和ruby-build来管理和安装您的 ruby 版本。
And then install the bundlergem and rehash.
然后安装bundlergem 并重新哈希。
Install rbenv (if you haven't already) as follows:
安装rbenv(如果你还没有)如下:
$ brew update
$ brew install rbenv ruby-build
Initialize rbenv as follows:
初始化rbenv如下:
$ rbenv init
Install ruby-build to compile and install different versions of Ruby on UNIX-like systems:
安装 ruby-build 以在类 UNIX 系统上编译和安装不同版本的 Ruby:
brew install ruby-build
Install a specific ruby version, e.g., 1.9.3-p551:
安装特定的 ruby 版本,例如 1.9.3-p551:
$ RUBY_VERSION=1.9.3-p551
$ ruby-build $RUBY_VERSION $HOME/.rbenv/versions/$RUBY_VERSION
Verify it worked:
验证它是否有效:
$ ruby --version
ruby 1.9.3p551 (2014-11-13 revision 48407) [x86_64-darwin14.0.0]
Set that version to be the global/default Ruby version:
将该版本设置为全局/默认 Ruby 版本:
$ rbenv global 1.9.3-p551
Install bundler:
安装捆绑器:
$ gem install bundler
Fetching: bundler-1.7.11.gem (100%)
Successfully installed bundler-1.7.11
1 gem installed
Update rbenv:
更新rbenv:
$ rbenv rehash
Now, bundler will be available in the version of Ruby (1.9.3-p551) that you just installed.
现在,bundler 将在您刚安装的 Ruby (1.9.3-p551) 版本中可用。
Verify RubyGems Environment:
验证 RubyGems 环境:
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.23.2
- RUBY VERSION: 1.9.3 (2014-11-13 patchlevel 551) [x86_64-darwin14.0.0]
- INSTALLATION DIRECTORY: /Users/lex/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /Users/lex/.rbenv/versions/1.9.3-p551/bin/ruby
- EXECUTABLE DIRECTORY: /Users/lex/.rbenv/versions/1.9.3-p551/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-14
- GEM PATHS:
- /Users/lex/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1
- /Users/lex/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-document"
- "install" => "--no-ri --no-rdoc"
- "update" => "--no-ri --no-rdoc"
- :sources => ["http://rubygems.org", "http://gems.github.com", "http://gems.rubyforge.org", "http://gemcutter.org"]
- REMOTE SOURCES:
- http://rubygems.org
- http://gems.github.com
- http://gems.rubyforge.org
- http://gemcutter.org
回答by Madhava Carrillo
try to run
试着跑
gem env
and then you will get something like this:
然后你会得到这样的东西:
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.23
- RUBY VERSION: 1.9.3 (2013-06-27 patchlevel 448) [x86_64-darwin12.5.0]
- INSTALLATION DIRECTORY: /usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /usr/local/Cellar/ruby193/1.9.3-p448/bin/ruby
**- EXECUTABLE DIRECTORY: /usr/local/Cellar/ruby193/1.9.3-p448/bin**
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-12
- GEM PATHS:
- /usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1
- /Users/madhava/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
Just add the executable directory to your PATH variable like this:
只需将可执行目录添加到您的 PATH 变量中,如下所示:
echo PATH=/usr/local/Cellar/ruby193/1.9.3-p448/bin:$PATH >> ~/.bash_profile
Reload your terminal to apply the changes and you will be set!
重新加载您的终端以应用更改,您将被设置!
回答by Jeff Parsons
回答by Deep
I am on Mac OS X Maverics (10.9.2)
我在 Mac OS X Maverics (10.9.2)
Currently my ~/.profilefile reads as follows:
目前我的~/.profile文件如下:
# MacPorts Installer addition on 2014-02-23_at_17:28:39: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
source /usr/local/bin/virtualenvwrapper.sh
. /sw/bin/init.sh
And my PATHvariable ($PATH) is set to
我的PATH变量 ( $PATH) 设置为
/sw/bin:/sw/sbin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin
This is what worked for me.
First I installed bundler using:
gem install bundler
这对我有用。首先,我使用以下方法安装了 bundler:
gem install bundler
However I got error:
但是我得到了错误:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
Hence I ran sudo gem install bundlerand that installed bundlersuccessfully
因此我运行sudo gem install bundler并bundler成功安装
After that when I ran gem envI got the Executable Directory set to /usr/binwhich is already part of my PATHvariable. Hence I didn't make any changes to ~/.profile file.
之后,当我运行时,我gem env将可执行目录设置/usr/bin为已经是我的PATH变量的一部分。因此我没有对 ~/.profile 文件进行任何更改。
and now I am successfully able to run bundle install.
现在我可以成功运行bundle install.
If the path listed in Executable Directoryis not included in your $PATHvariable or ~/.profilefile, you will have to include it.
如果 中列出的路径Executable Directory未包含在您的$PATH变量或~/.profile文件中,则您必须将其包含在内。
回答by grumpit
Note that if you're using rbenv, you should probably just rbenv rehashand not mess with your PATH
请注意,如果您使用的是 rbenv,您可能应该只是rbenv rehash而不是弄乱您的PATH

