【问题标题】:How Can I get Rake to use RVM's Ruby?如何让 Rake 使用 RVM 的 Ruby?
【发布时间】:2015-04-14 16:22:37
【问题描述】:

我正在尝试在 Ubuntu 上安装一个使用 ruby​​ 的应用程序。我安装了 RVM 和 Ruby 2.0 并运行了rake install,但 Rake 尝试使用旧系统版本的 Ruby。所以我卸载了系统版本并再次尝试运行 Rake。这次它说“没有这样的文件”。如何让 Rake 使用 RVM 的 ruby​​?下面是不同命令的输出。

 $ rake install
sudo bundle --without production staging test levelbuilder --quiet
sudo: unable to execute /usr/local/bin/bundle: No such file or directory
rake aborted!
...
/home/ubuntu/../rake_utils.rb:33:in `system'
..
/home/ubuntu/../rake_utils.rb:43:in `bundle_install'
/home/ubuntu/../Rakefile:198:in `block (3 levels) in <top (required)>'
..
/home/ubuntu/.rvm/gems/ruby-2.0.0-p643/bin/ruby_executable_hooks:15:in `eval'
...

路径和版本看起来正确:

$ echo $PATH
/home/ubuntu/.rvm/gems/ruby-2.0.0-p643/bin:/home/ubuntu/.rvm/gems/ruby-2.0.0-p643@global/bin:/home/ubuntu/.rvm/rubies/ruby-2.0.0-p643/bin:/home/ubuntu/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

$ ruby -v
ruby 2.0.0p643 (2015-02-25 revision 49749) [x86_64-linux]

$ which ruby
/home/ubuntu/.rvm/rubies/ruby-2.0.0-p643/bin/ruby

这是我的 .bash_profile:

[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile    

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

这是 .bashrc 的底部:

export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting.

【问题讨论】:

  • 如果您使用 RVM 提供的 gem 安装了 rake,则这不是问题。 which rake 说什么?这是正确的道路吗?
  • gem install rakewhich rake。它输出:/home/ubuntu/.rvm/gems/ruby-2.0.0-p643/bin/rake。但 rake install 仍然会导致同样的错误。
  • bundle exec rake install 有效吗?通常你只需要 bundle install 这取决于 which bundle 是否正确。
  • 实际运行会导致Could not locate Gemfile or .bundle/ directory,因为 gemfile 位于子目录中。
  • 您需要从目录中触发它,否则它不知道该做什么。

标签: ruby bash ubuntu rake .bash-profile


【解决方案1】:

执行source ~/.bash_profile

【讨论】:

  • 尝试使用 rvm gemsets。除非您创建了任务rake install,否则它不存在。如果您没有 Gemfile,请创建它。 gemfile
  • 考虑进一步解释为什么这可能是一个答案。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-07-21
  • 1970-01-01
  • 2014-08-05
  • 2023-04-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多