How to switch compass version? - ruby

I have two versions of Compass, 0.12 and 0.13.alpha. The default version is 0.13.alpha but sometimes I need to switch to 0.12.
What command will permit this, please?

old topic, but I just came across the issue of having 2 projects. one using compass version 0.12 and the other 1.0.
as the newer version of compass relies on a new major release of sass, many deprecation warnings and compatibility issues are experienced when trying to run the newer compass on the old project.
well, now to the solution:
ruby gems already support having multiple versions installed. and after taking a look into the compass executable, it turns out there is a way to specify which compass version to use (the file is generated by rubygems, see http://pastebin.com/HeZnE0T5 if you are curious)
with that we can now have multiple versions of compass installed at once. eg:
gem install compass -pre // currently version 1.0.0.alpha.19
gem install compass // currently version 0.12.6
and now we can use them by specifying which version to use:
$ 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
this obviously also works for other compass commands, eg watch:
$ compass _0.12.6_ watch .
>>> Compass is watching for changes. Press Ctrl-C to Stop.
EDIT: of course the version switch can be done in a Gemfile, but in my case its not a ruby project and compass is started via command line

If you are switching versions for different projects, I recommend using either RVM (Ruby) or virtualenv with some help (Python) or something similar to manage gems and versions. Bundler will help make either solution simpler to maintain.
If you are switching versions within a project, I recommend reconsidering your approach.

This is really simple using bundler.
Install bundler:
$ gem install bundler
Create the Gemfile in your project if you don't already have one:
$ bundle init
Specify the version you want/need in your Gemfile:
gem 'compass', '~>0.12.2'
gem 'sass', '3.2.8'
Install the specific gems and dependencies you have defined in your Gemfile:
$ bundle install
When executing a gem, you can now use bundler to control which version to execute based on your Gemfile:
$ bundle exec compass watch
That's it!
It's helpful to leave a comment in your Gemfile telling other developers how to use bundler:
# Now that you're using Bundler, you need to run `bundle exec compass watch` instead of simply `compass watch`.
Read more about versioning at http://bundler.io/v1.6/gemfile.html

Change the gemfile, add in a version parameter.

Related

Find out which version of Sass Compass is using from the command line

I unfortunately have to install two versions of Compass(1.0.3, 0.12.2) and two versions of Sass(3.4.21, 3.2.19) on my computer - I have a newer and an older project that require me to have these two versions installed. I was given the older project recently, so I've only just now installed these older versions.
I'm using "compass watch" to compile, and while they both compile fine, I think the newer Compass (1.0.3) is using the older Sass (3.2.19) for the newer project. Now when I try to compile my newer project, it creates a huge diff if I change a single line (#fff instead of "white", all of the line number comments were changed slightly, stuff like that).
Is there any way to tell which version Compass is using, and furthermore, can I set it to use a specific version without uninstalling Sass everytime?
Use Bundler.
Create a Gemfile for each of your projects.
$ gem install bundler
$ cd project && touch Gemfile
Add to Gemfile:
source 'https://rubygems.org'
gem 'compass', '0.12.2'
Replace with appropriate version.
Now when you start working on a specific project, cd to it and run:
$ bundle install

Upgrading SASS in a way that I can downgrade if needed?

I'm using a very old version of SASS (3.1.15) in the Compass framework, and I want to upgrade to 3.4.3, which is the latest. I'm researching the process of upgrading, and after reading the SASS changelog, I'd like to be able to upgrade, then if I see a lot of errors and whatnot, revert back to the old version since I currently have actual development work to do in parallel with this research. I want to avoid being blocked due to legacy code being incompatible with new SASS, but I also want to see what issues an upgrade would bring, if any. Is there a way to do this?
I believe it would be as simple as this to upgrade:
$ sudo gem uninstall sass
$ sudo gem install sass --version 3.4.3
Then if you want to switch back to the old version:
$ sudo gem uninstall sass
$ sudo gem install sass --version 3.1.15
Both Bundler and RVM allow you to specify gems in their own way. Bundler is project-based, while RVM uses gemsets.

Can't Uninstall Compass

I'm trying to uninstall Compass, so I ran sudo gem uninstall compass and it seemed to go through the uninstall process normally. If I try running sudo gem uninstall compass again it just gives me a new command line.
However, if I run compass -v, it still returns version information:
Compass 0.12.2 (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
So is Compass really uninstalled? If not, how do I uninstall it completely?
If you ask it gem which compass and go there and remove that gem (manually), you should find joy. However, it seems like you have some issues. Perhaps you are using some kind of Ruby environment manager, such as rbenv, chruby or RVM? Or have used one of them. In that case, you may need to not use sudo to remove the gem. (automated, and recommended).
You are attempting to remove the system installed gem, but not the user space installed gem.

Sass syntax error: Invalid CSS after [duplicate]

I have just upgraded to Sass 3.3 so that I can use some of the new features (BEM styled class names, mappings, #at-root, etc). If I compile my project with Sass (via sass --watch), it works just fine. However, if I compile it using Compass (via compass watch), I get an error when using the new Sass features.
I'm using Compass 0.12.
Compass 0.12 explicitly depends on Sass 3.2. Even if you have a newer version of Sass installed, it will still compile with 3.2. In order to use Sass 3.3 or later, you have to be using Compass 1.0 or later.
Running the gem install command normally should get you the latest stable version.
gem install compass
At the time this question was asked, Compass 1.0 was still in beta. To install the latest beta version of a gem, you will need to install it using the --pre flag.
gem install compass --pre
Note that you do not need to install Sass first in order for this to work. Installing Compass will automatically install the latest version of Sass that it is compatible with.
I have Compass 1.0 installed and it still errors
Double check any other dependencies you might have (Compass extensions, etc.), one of them might be specifying an older version of Sass or Compass.
If you're using an application or build tool rather than using the commands directly, make sure they're not referencing older versions of Compass.
Windows users
As a Window user, I got an error when I tried to watch my project using the newer Compass.
LoadError on line ["36"] of C: cannot load such file -- wdm"
To fix that problem:
You must install the ruby DevKit:
Download found here: http://rubyinstaller.org/downloads/
Follow this page to properly install:
https://github.com/oneclick/rubyinstaller/wiki/Development-Kit
Now install wdm:
gem install wdm
There didn't seem to be any one place that contained the whole list of steps required, in order, to make this work, so here they are. This list is for Windows, but it may work fine on other platforms.
Install Ruby -- use 1.9.3 -- http://rubyinstaller.org/downloads .
Download the Ruby DevKit found lower on the same page -- http://rubyinstaller.org/downloads/
run it to extract it somewhere (permanent). Then cd to it, run “ruby dk.rb init” and “ruby dk.rb install” to bind it to ruby installations in your path.
gem install wdm
gem install sass
gem install compass --pre
It now is, in the latest version of Compass. Update compass to get the changes and work with Sass 3.3 and higher
Current Sass compatibility can be found here: https://rubygems.org/gems/compass
To upgrade just run
$gem install compass

Does Bundler have to be installed so that singularity.gs can be installed?

do you have to have Bundler installed to install singularity.gs or can you install like on the video on Viemo?
While you don't need Bundler per se, it is highly recommended that if you are working in any Ruby stack that you use Bundler to ensure that your gem dependencies are locked in place and you don't run into incompatibility issues across gem updates or across team. When singularity 1.2.0 gets a full release, you'll be able to drop the Singularity Sass straight into your project and not need the gem, but if you are compiling with the Ruby compiler it's still recommended to use Bundler.

Resources