找不到OSX bundler install命令

时间:2013-06-05 21:23:10

标签: ruby-on-rails ruby rubygems

我收到了这个错误:

无法在任何来源中找到i18n-0.6.1 运行bundle install以安装缺少的宝石。

当我尝试运行bundle install时,我得到了这个:

-bash: bundle: command not found

我用谷歌搜索并试图解决这个问题一段时间没有希望。请帮忙。

5 个答案:

答案 0 :(得分:11)

不要弄乱你的路径。

只需使用 rbenv ruby​​-build 来管理和安装您的ruby版本。

然后安装 bundler gem并重新散列。

安装rbenv(如果你还没有),如下所示:

$ brew update
$ brew install rbenv ruby-build

安装ruby-build以在类UNIX系统上编译和安装不同版本的Ruby:

brew install ruby-build

安装特定的ruby版本,例如1.9.3-p551:

$ RUBY_VERSION=1.9.3-p551
$ ruby-build $RUBY_VERSION $HOME/.rbenv/versions/$RUBY_VERSION

验证它是否有效:

$ ruby --version
ruby 1.9.3p551 (2014-11-13 revision 48407) [x86_64-darwin14.0.0]

将该版本设置为全局/默认Ruby版本:

$ rbenv global 1.9.3-p551

安装bundler:

$ gem install bundler
Fetching: bundler-1.7.11.gem (100%)
Successfully installed bundler-1.7.11
1 gem installed

更新rbenv:

$ rbenv rehash

现在,bundler将以您刚刚安装的Ruby版本(1.9.3-p551)提供。

验证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

答案 1 :(得分:9)

尝试运行

gem env

然后你会得到这样的东西:

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/

只需将可执行文件目录添加到PATH变量中,如下所示:

echo PATH=/usr/local/Cellar/ruby193/1.9.3-p448/bin:$PATH >> ~/.bash_profile

重新加载终端以应用更改,您将被设置!

答案 2 :(得分:2)

似乎有Sierra,您需要使用它来安装Bundler:

sudo gem install bundler -n /usr/local/bin

参考here指的是El Cap如何引入“SIP(系统完整性保护)。”

答案 3 :(得分:0)

我在Mac OS X Maverics (10.9.2)

目前我的~/.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

我的PATH变量($PATH)设置为

/sw/bin:/sw/sbin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin

这对我有用。 首先我使用以下方法安装了bundler gem install bundler

但是我收到了错误:

ERROR:  While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.

因此我运行了sudo gem install bundler并成功安装了bundler

之后当我运行gem env时,我将可执行目录设置为/usr/bin,这已经是PATH变量的一部分。因此我没有对〜/ .profile文件进行任何更改。

现在我已成功运行bundle install

如果Executable Directory变量或$PATH文件中未包含~/.profile中列出的路径,则必须包含该路径。

答案 4 :(得分:0)

请注意,如果您使用的是rbenv,那么您应该rbenv rehash,而不是弄乱PATH