所以我使用rbenv来设置我的ruby版本(对于我正在处理的特定项目,这是2.1.1(。问题是bundler无法检测到这个更改。我甚至试图在我的gemfile中设置版本:
source "https://my-proxy-address"
ruby "2.1.1"
gem 'fileutils'
gem 'json'
gem 'chef-api'
然而,这会导致准确的错误消息,如教程末尾所示:
username@hostname:~/Desktop/working-bundler-env$ rbenv version
2.1.1 (set by /Users/username/.rbenv/version)
username@hostname:~/Desktop/working-bundler-env$ ruby -v
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin15.0]
username@hostname:~/Desktop/working-bundler-env$ bundle install
Your Ruby version is 2.0.0, but your Gemfile specified 2.1.1
本教程有这个问题的解决方案(编辑路径文件(,但他们没有说明要更改什么文件。我要更改什么文件?
$ rbenv
rbenv 1.0.0
Usage: rbenv <command> [<args>]
Some useful rbenv commands are:
commands List all available rbenv commands
local Set or show the local application-specific Ruby version
global Set or show the global Ruby version
shell Set or show the shell-specific Ruby version
install Install a Ruby version using ruby-build
uninstall Uninstall a specific Ruby version
rehash Rehash rbenv shims (run this after installing executables)
version Show the current Ruby version and its origin
versions List all Ruby versions available to rbenv
which Display the full path to an executable
whence List all Ruby versions that contain the given executable
See `rbenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/rbenv/rbenv#readme
$ which bundle
/usr/local/bin/bundle
所以我注意到当我运行gem bundle install
时,版本是1.13.3
。在运行sudo find / -name bundle
之后,我找到了包含该版本号的两个文件位置。
/Users/myusername/.gems/gems/bundler-1.13.3/exe/bundle
/Users/myusername/.gems/gems/bundler-1.13.3/lib/bundler/man/bundle
在尝试运行/Users/myusername/.gems/gems/bundler-1.13.3/exe/bundle install
之后,它工作得很好。所以我只是在~/.bash_profile
中创建了一个别名,覆盖了不正确的bundle命令。
alias bundle=/Users/alexcohen/.gems/gems/bundler-1.13.3/exe/bundle
这个gem的唯一副作用(无论好坏(是,它在我运行bundle install
的目录中创建了.bundle
和path
目录,这些gem被下载到该目录中。
我仍然需要调查为什么会发生这种情况,但我认为我的macs终端中的bundle
命令引用了我系统中某个类型的损坏的bundler gem或文件。