2012-09-16 38 views
1

我有两个版本的指南针,0.12和0.13.alpha。默认版本是0.13.alpha,但有时我需要切换到0.12。如何切换指南针版本?

什么命令将允许这一点,好吗?

+0

,比如版本什么? –

+0

不需要downvote球员。看起来像是一个合法的问题。 – corroded

回答

2

如果您正在切换不同项目的版本,我推荐使用RVM(红宝石)或virtualenvsome help(Python)或类似的东西来管理宝石和版本。 Bundler将有助于使任一解决方案更易于维护。

如果你是在一个项目中切换的版本,我建议重新考虑你的方法。

1

更改Gemfile中,加入一个版本参数。

3

老话题,但我只是碰到有2个项目的问题就来了。一个使用指南针版本0.12和另一个1.0

罗盘的新版本依靠青菜新的主要版本,许多废弃警告和兼容性问题试图运行在老项目的新的指南针时都经历过。


好了,现在到了解决方案:

红宝石宝石已经支持具有安装了多个版本。并考虑看看到compass可执行文件后,原来存在于指定要使用的罗盘版本(由RubyGems的生成的文件,看看http://pastebin.com/HeZnE0T5如果你是好奇)

与我们现在可以有多种方式一次安装指南针的版本。例如:

gem install compass -pre // currently version 1.0.0.alpha.19 
gem install compass // currently version 0.12.6 

,现在我们可以通过指定哪个版本使用它们的使用方法:

$ compass version 
Compass 1.0.0.alpha.19 
Copyright (c) 2008-2014 Chris Eppstein 
Released under the MIT License. 
Compass is charityware. 
Please make a tax deductable donation for a worthy cause: http://umdf.org/compass 

$ compass _0.12.6_ version 
Compass 0.12.6 (Alnilam) 
Copyright (c) 2008-2014 Chris Eppstein 
Released under the MIT License. 
Compass is charityware. 
Please make a tax deductable donation for a worthy cause: http://umdf.org/compass 

这显然也适用于其他罗盘命令,例如watch

$ compass _0.12.6_ watch . 
>>> Compass is watching for changes. Press Ctrl-C to Stop. 

编辑:当然版本切换可以在Gemfile中进行,但对我来说,它不是一个Ruby项目和指南针是通过命令行启动

2

使用捆绑器这非常简单。

安装捆绑:

$ gem install bundler 

在项目中创建的Gemfile,如果你不已经有一个:

$ bundle init 

指定你的Gemfile你想要的版本/需要:

gem 'compass', '~>0.12.2' 
gem 'sass', '3.2.8' 

安装您在Gemfile中定义的特定宝石和依赖关系:

$ bundle install 

当执行一个宝石,你现在可以使用捆绑执行基于你的Gemfile哪个版本控制:

$ bundle exec compass watch 

这就是它!

这是很有帮助的留在你的Gemfile告诉其他开发人员如何使用打捆评论:

# Now that you're using Bundler, you need to run `bundle exec compass watch` instead of simply `compass watch`. 

了解更多关于http://bundler.io/v1.6/gemfile.html