I have seen many
我见过很多
You have already activated rake 0.9.x, but your Gemfile requires rake 0.x.x
errors.
错误。
Of course, they can be solved (temporarily or always) by some methods like the following.
当然,它们可以通过以下某些方法(临时或永久)解决。
bundle exec rake
The method above works but you always have to type bundle exec.
上面的方法有效,但你总是要输入bundle exec。
It can also be solved by
它也可以通过解决
bundle update
But bundle update also updates your other gems.
但捆绑更新还会更新您的其他宝石。
Some say it can be solved by
有人说它可以解决
gem uninstall unwanted_rake_version
Yes, the unwanted rake can be installed but it is still marked as activated thus, still giving the error.
是的,可以安装不需要的rake,但它仍然标记为已激活,因此仍然会出错。
One solution would be to explicitly specify the rake version in your Gemfile but, that is not the question. It is on how to set the default rake version, or activate that specific version in rvm or other types of ruby installations?
一种解决方案是在Gemfile中明确指定rake版本,但这不是问题。它是关于如何设置默认rake版本,或在rvm或其他类型的ruby安装中激活该特定版本?
3 个解决方案
#1
8
The newer versions of rake can be activated by supplying an optional first argument, that is the gem version.
可以通过提供可选的第一个参数(即gem版本)来激活较新版本的rake。
$ rake 0.9.2
$ rake 0.9.2
Alternatively, if you have an older version of rake you can update the rake script manually to include this parameter (or specify any specific version you want).
或者,如果您有较旧版本的rake,则可以手动更新rake脚本以包含此参数(或指定所需的任何特定版本)。
The rake script usually lives in /usr/bin/rake (or ~/.rvm/gems/ruby-#{ruby-name}/rake if using rvm). And dictates the version of them gem to load before parsing paramaters.
rake脚本通常位于/ usr / bin / rake(或〜/ .rvm / gems / ruby - #{ruby-name} / rake中,如果使用rvm)。并指出在解析参数之前加载它们的gem的版本。
It looks like this on my system.
在我的系统上看起来像这样。
$ cat ~/.rvm/gems/ruby-1.9.2-p180/bin/rake
#!/home/tomcat/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
#
# This file was generated by RubyGems.
#
# The application 'rake' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'
version = ">= 0"
if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
version = $1
ARGV.shift
end
gem 'rake', version
load Gem.bin_path('rake', 'rake', version)
The important bit is gem 'rake', version
changing version
will force rake to a specific version system/rvm wide.
重要的是gem'rake',版本更改版本将强制rake到特定版本系统/ rvm宽。
For more info, Katz' article explains nicely how binaries run under rubygems
有关更多信息,Katz的文章很好地解释了二进制文件如何在rubygems下运行
#2
4
When I get that error, its usually a result of working between projects that depend on different versions of rake. An easy fix is
当我得到该错误时,它通常是在依赖于不同版本的rake的项目之间工作的结果。一个简单的解决方法
gem uninstall rake
And then in your project directory (assuming you're working with Bundler) simply
然后在您的项目目录中(假设您正在使用Bundler)
bundle
#3
-1
I always uninstall rake first, command like this:
我总是首先卸载rake,命令如下:
gem uninstall rake -v=version
then install another version
然后安装另一个版本
gem install rake -v=version
#1
8
The newer versions of rake can be activated by supplying an optional first argument, that is the gem version.
可以通过提供可选的第一个参数(即gem版本)来激活较新版本的rake。
$ rake 0.9.2
$ rake 0.9.2
Alternatively, if you have an older version of rake you can update the rake script manually to include this parameter (or specify any specific version you want).
或者,如果您有较旧版本的rake,则可以手动更新rake脚本以包含此参数(或指定所需的任何特定版本)。
The rake script usually lives in /usr/bin/rake (or ~/.rvm/gems/ruby-#{ruby-name}/rake if using rvm). And dictates the version of them gem to load before parsing paramaters.
rake脚本通常位于/ usr / bin / rake(或〜/ .rvm / gems / ruby - #{ruby-name} / rake中,如果使用rvm)。并指出在解析参数之前加载它们的gem的版本。
It looks like this on my system.
在我的系统上看起来像这样。
$ cat ~/.rvm/gems/ruby-1.9.2-p180/bin/rake
#!/home/tomcat/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
#
# This file was generated by RubyGems.
#
# The application 'rake' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'
version = ">= 0"
if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
version = $1
ARGV.shift
end
gem 'rake', version
load Gem.bin_path('rake', 'rake', version)
The important bit is gem 'rake', version
changing version
will force rake to a specific version system/rvm wide.
重要的是gem'rake',版本更改版本将强制rake到特定版本系统/ rvm宽。
For more info, Katz' article explains nicely how binaries run under rubygems
有关更多信息,Katz的文章很好地解释了二进制文件如何在rubygems下运行
#2
4
When I get that error, its usually a result of working between projects that depend on different versions of rake. An easy fix is
当我得到该错误时,它通常是在依赖于不同版本的rake的项目之间工作的结果。一个简单的解决方法
gem uninstall rake
And then in your project directory (assuming you're working with Bundler) simply
然后在您的项目目录中(假设您正在使用Bundler)
bundle
#3
-1
I always uninstall rake first, command like this:
我总是首先卸载rake,命令如下:
gem uninstall rake -v=version
then install another version
然后安装另一个版本
gem install rake -v=version