我正在try 将bundler与rbenv结合使用.我一直工作到今天.我唯一能打破它的是gem pristine --allgem cleanup?在try 安装bundler时,我遇到了以下错误.

Antarrs-MacBook-Pro:some-app antarrbyrd$ sudo gem install bundler
Password:
Bundler gave the error "Could not find mail-2.5.4 in any of the sources" while processing "/Users/antarrbyrd/dev/some-app/Gemfile". Perhaps you forgot to run "bundle install"?
Successfully installed bundler-1.7.12
Parsing documentation for bundler-1.7.12
Done installing documentation for bundler after 3 seconds
1 gem installed
Antarrs-MacBook-Pro:some-app antarrbyrd$ bundle install
/Users/antarrbyrd/.rbenv/versions/2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/dependency.rb:315:in `to_specs': Could not find 'bundler' (>= 0) among 8 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=/Users/antarrbyrd/.gem', execute `gem env` for more information
    from /Users/antarrbyrd/.rbenv/versions/2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/dependency.rb:324:in `to_spec'
    from /Users/antarrbyrd/.rbenv/versions/2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_gem.rb:64:in `gem'
    from /usr/local/bin/bundle:22:in `<main>'

当我做rbenv rehashrbenv bundler on时,会得到这个错误

Bundler gave the error "Could not find mail-2.5.4 in any of the sources" while processing "/Users/antarrbyrd/dev/some-app/Gemfile". Perhaps you forgot to run "bundle install"?

~/.bash_简介

export BUNDLER_EDITOR=atom
export PATH=$PATH:/usr/local/opt/android-sdk/build-tools/21.1.2
export HOMEBREW_GITHUB_API_TOKEN=...

export ANDROID_HOME=/usr/local/opt/android-sdk
export PATH="$HOME/.rbenv/bin:$PATH"
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi

# Allow local Gem Managment 
# export GEM_HOME="$HOME/.gem"
# export GEM_PATH="$HOME/.gem"
# export PATH="$HOME/.gem/bin:$PATH"

gem env

RubyGems Environment:
  - RUBYGEMS VERSION: 2.2.2
  - RUBY VERSION: 2.1.2 (2014-05-08 patchlevel 95) [x86_64-darwin14.0]
  - INSTALLATION DIRECTORY: /usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0
  - RUBY EXECUTABLE: /usr/local/var/rbenv/versions/2.1.2/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/local/var/rbenv/versions/2.1.2/bin
  - SPEC CACHE DIRECTORY: /Users/antarrbyrd/.gem/specs
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-14
  - GEM PATHS:
     - /usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0
     - /Users/antarrbyrd/.gem/ruby/2.1.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => false
     - :backtrace => false
     - :bulk_threshold => 1000
     - "gem" => "-n/usr/local/bin"
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /usr/local/var/rbenv/versions/2.1.2/bin
     - /usr/local/Cellar/rbenv/0.4.0/libexec
     - /Users/antarrbyrd/.gem/bin
     - /usr/local/var/rbenv/shims
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /usr/local/var/rbenv/shims
     - /Users/antarrbyrd/.rbenv/bin
     - /Users/antarrbyrd/.rbenv/shims
     - /Users/antarrbyrd/.gem/bin
     - /usr/local/opt/android-sdk/build-tools/21.1.2

update

我通过brew重新安装了rbenv,现在运行bundle install时出现以下错误.

The `bundle' command exists in these Ruby versions:
  2.1.5

response to Joel

Antarrs-MacBook-Pro:myapp antarrbyrd$ command -v ruby
/usr/local/var/rbenv/shims/ruby
Antarrs-MacBook-Pro:myapp antarrbyrd$ command -v bundle
/usr/local/bin/bundle
Antarrs-MacBook-Pro:myapp antarrbyrd$ ruby -v
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin14.0]
Antarrs-MacBook-Pro:myapp antarrbyrd$ bundle -v
Bundler version 1.7.12
Antarrs-MacBook-Pro:myapp antarrbyrd$ 

推荐答案

你的安装陷入了一个循环.

更改到一个不是你的应用程序的目录,并且该目录没有文件.

然后做通常的gem install bundle(如果需要,使用sudo)

然后切换到你的应用程序目录,做通常的bundle install.

这能解决你的问题吗?

如果需要更多帮助,可以运行这些命令,然后将结果粘贴到问题中吗?

 $ command -v ruby
 $ command -v bundle
 $ ruby -v
 $ bundle -v

寻找结果与预期之间的任何不匹配.这将帮助你追踪正在发生的事情.您可能需要更新Gemfile Ruby版本.

(同样,您可能需要考虑从rbenvchruby的变化,因为更好地解决这些路径问题)

Ruby相关问答推荐

获取用于传递参数的变量名称

ri 和 rdoc 有什么区别

Windows 上的 Jekyll:Pygments 不工作

在Ruby中将关键字与常规参数混合?

如何在两个浮点数之间的范围内最好地创建一个随机浮点数

为什么 Matz Select 在 Ruby 中默认使字符串可变?

我如何 expect期望在 RSpec 中引发异常的东西?

按键对哈希进行分组并对值求和

Ruby 输出 Unicode 字符

Ruby Koan 151 引发异常

Ruby注入初始为哈希

判断字符串是否为空的Ruby方法?

有条件的数组的第一个元素

Ruby 中的动态方法调用

Ruby:是否可以在模块中定义类方法?

如何使用 minitest 运行所有测试?

严格将字符串转换为整数(或 nil)

我更改存储库 URL 后 Capistrano 部署失败

将浮点数舍入到Ruby中最接近的整数

Ruby Activerecord IN 子句