如何激活或设置默认耙? [英] how do you activate or set the default rake?

查看:84
本文介绍了如何激活或设置默认耙?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到很多

 您已经激活了rake 0.9.x,但是您的Gemfile需要rake 0.xx 

错误。



当然,可以通过以下方法(暂时或始终)解决它们。

  bundle exec rake 

以上方法有效,但您始终必须输入

也可以通过

 捆绑更新来解决

但是捆绑更新也会更新您的其他宝石。



有人说可以通过以下方式解决

  gem uninstall nobody_rake_version 

pre>

是的,可以安装不需要的耙子,但它仍被标记为已激活,因此仍然出现错误。



一种解决方案是在Gemfile中明确指定rake版本,但这不是问题。它是关于如何设置默认的rake版本,或如何在rvm或其他类型的ruby安装中激活该特定版本的?

解决方案

可以通过提供可选的第一个参数(即gem版本)来激活较新版本的rake。



$耙0.9.2



如果您使用的是较旧版本的rake,则可以手动更新rake脚本以包括此参数(或指定所需的任何特定版本)。



rake脚本通常位于/ usr / bin / rake(如果使用rvm,则为〜/ .rvm / gems / ruby​​-#{ruby-name} / rake)。并规定了解析参数之前要加载的gem版本。



在我的系统上看起来像这样。

  $ cat〜/ .rvm / gems / ruby​​-1.9.2-p180 / bin / rake 

#!/ home / tomcat / .rvm / rubies / ruby-1.9.2-p180 / bin / ruby​​

#该文件由RubyGems生成。

#应用程序 rake是作为gem的一部分安装的,而
#此文件在此处是为了便于运行。


需要'rubygems'

version => = 0

如果ARGV.first =〜/ ^ _ (。*)_ $ /和Gem :: Version。正确吗? $ 1然后
版本= $ 1
ARGV.shift
结束

gem'rake',版本
load Gem.bin_path('rake','rake ',版本)

重要的一点是 gem'rake',版本更改版本将强制耙到特定版本的系统/ rvm范围。



有关更多信息信息,Katz 文章解释很好的二进制文件如何在rubygems下运行


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.

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.

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?

解决方案

The newer versions of rake can be activated by supplying an optional first argument, that is the gem version.

$ 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).

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.

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.

For more info, Katz' article explains nicely how binaries run under rubygems

这篇关于如何激活或设置默认耙?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆