【问题标题】:Bundler with rbenv version pathfile issue具有 rbenv 版本路径文件问题的 Bundler
【发布时间】:2017-02-21 17:27:33
【问题描述】:

所以我使用 rbenv 来设置我的 ruby​​ 版本(对于我正在处理的特定项目是 2.1.1)。问题是捆绑程序无法检测到此更改。我什至尝试在我的 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

【问题讨论】:

  • 你试过rbenv rehash 吗?
  • 我试过没有变化
  • 您能否显示您的 $PATH 变量值 (echo $PATH) 以及 rbenv 命令的输出?
  • rbenv rehash 没有输出,这是我的 $PATH /Users/$MYUSER/.rbenv/shims:/Users/$MYUSER/.rbenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
  • 命令只是rbenv 没有“rehash”

标签: ruby bash macos bundler rbenv


【解决方案1】:

所以我注意到当我运行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 中创建了一个别名,覆盖了不正确的捆绑命令。

alias bundle=/Users/alexcohen/.gems/gems/bundler-1.13.3/exe/bundle

这个 gem 的唯一副作用(无论好坏)是它会在我运行 bundle install 的目录中创建 .bundlepath 目录,并将 gem 下载到该目录中。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-21
    • 2013-06-06
    • 2010-10-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多