简体   繁体   English

如何在不使用Bundler的情况下通过CLI使用特定的ruby gem版本

[英]how to use a specific ruby gem version using CLI and without using Bundler

I have two rails projects on my box, one that is using rails 3.0 and as such Bundler handles all it's dependencies.. and the other is a rails 2.3.5 that doesn't use bundler. 我的盒子上有两个Rails项目,一个正在使用rails 3.0,因此Bundler处理它的所有依赖关系.. 另一个使用捆绑程序的rails 2.3.5。

I'm getting this error when running rake: 运行rake时出现此错误:

ERROR: 'rake/rdoctask' is obsolete and no longer supported. Use 'rdoc/task' 
(available in RDoc 2.4.2+) instead.

doing a bit of research it turns out that I have two options 做一点研究 ,结果发现我有两个选择

  • edit the rake file to require rdoc/task rather than rake/rdoctask 编辑rake文件以要求rdoc / task而不是rake / rdoctask
  • upgrade my rake gem to version >=10 将我的rake gem升级到版本> = 10

if I run gem list | grep rake 如果我运行gem list | grep rake gem list | grep rake I get rake (10.1.1, 10.1.0, 0.8.7) , so naturally I have multiple versions of the same gem installed.. my question is how do i ask my rails 2.3.5 project to always use the 0.8.7 version of the gem? gem list | grep rake我得到rake (10.1.1, 10.1.0, 0.8.7) ,所以自然地我安装了同一gem的多个版本。我的问题是我如何要求我的rails 2.3.5项目始终使用0.8 .7版本的宝石?

In environment.rb 在environment.rb中

Rails::Initializer.run do |config|
  #other code
  config.gem "rake", :version => "0.8.7"
end

Should work I think 我认为应该工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM