Bundler与rbenv版本路径文件问题

时间:2016-10-12 19:13:13

标签: ruby bash macos bundler rbenv

所以我使用rbenv来设置我的ruby版本(对于特定的项目我正在研究这个是2.1.1)。问题是bundler无法检测到此更改。我甚至试图在我的gemfile中设置版本:

source "https://my-proxy-address"
ruby "2.1.1"
gem 'fileutils'
gem 'json'
gem 'chef-api'

然而,这会导致在教程结尾处看到here的确切错误消息:

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

The tutorial有问题的解决方案(编辑路径文件),但他们不说要更改的文件。我要更改哪个文件?

$ 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

1 个答案:

答案 0 :(得分:0)

所以我注意到,当我运行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目录的目录中创建pathbundle install目录,其中gems被下载到其中。

我仍然需要调查为什么会发生这种情况,但我认为我的macs终端中的bundle命令在我的系统中某处引用了某种类型的破坏的bundle gem或文件。