29

I have clean new Rails 4 app with Gemfile:

#default gems
gem 'compass-rails'
gem 'zurb-foundation'
gem 'thin'

with style.scss:

@import "compass";
@import "foundation/variables";
$red: rgb(255,0,1);
$green: rgb(51,153,50);
$body-bg: #F4F4F4;
$body-font-color: #7B7B7B;
$primary-color: #999;
$secondary-color: #0CC;
$dark-color: #393939;
$block-container-border-color: rgb(218,218,218);
$block-container-shadow-color: rgb(208,208,208);
// main background
html{
  background:image-url('bckg.jpg');
}
body{
  width:1000px;
  margin:0 auto;
  @include box-shadow(0px 0px 32px -5px #000);
}

And I have this error:

Showing /Users/quatermain/Projects/rails40/app/views/layouts/application.html.erb where line #18 raised:

File to import not found or unreadable: compass.
Load paths:
  /Users/quatermain/Projects/rails40/app/assets/images
  /Users/quatermain/Projects/rails40/app/assets/javascripts
  /Users/quatermain/Projects/rails40/app/assets/stylesheets
  /Users/quatermain/Projects/rails40/vendor/assets/javascripts
  /Users/quatermain/Projects/rails40/vendor/assets/stylesheets
  /usr/local/rvm/gems/ruby-1.9.3-p392/gems/turbolinks-1.2.0/lib/assets/javascripts
  /usr/local/rvm/gems/ruby-1.9.3-p392/gems/jquery-rails-3.0.1/vendor/assets/javascripts
  /usr/local/rvm/gems/ruby-1.9.3-p392/gems/coffee-rails-4.0.0/lib/assets/javascripts
  /usr/local/rvm/gems/ruby-1.9.3-p392/gems/zurb-foundation-4.2.3/scss
  /usr/local/rvm/gems/ruby-1.9.3-p392/gems/zurb-foundation-4.2.3/js
  (in /Users/quatermain/Projects/rails40/app/assets/stylesheets/style.scss:5)

Is Rails 4 not currently supported by compass-rails?

andrewdotnich
  • 16,195
  • 7
  • 38
  • 57
quatermain
  • 1,442
  • 2
  • 18
  • 33
  • 1
    I'm also attempting to create a new rails 4 application with compass-rails and Foundation, and am having no luck. I can't find any evidence that compass-rails does support rails 4 yet, but I can't find any documentation of the contrary either.. – Will Jun 30 '13 at 01:49
  • 3
    I'm the new maintainer of compass-rails. The compass-rails 1.1.x series of gems works on Rails 4. It wasn't getting much attention for a while and people started using unofficial forks to get Rails 4 support. I can assure you that going forward I'll be responsive to issues and continue to release support for upcoming version of Compass and Rails so compass-rails will be as seamless an experience as possible. – craigmcnamara Dec 13 '13 at 21:11

6 Answers6

48

Compass needs to have some key parts rewritten in order to support Rails 4. There is a temporary branch you can use that has hacked together some support:

'gem "compass-rails", github: "milgner/compass-rails", ref: "1749c06f15dc4b058427e7969810457213647fb8"

You can follow https://github.com/Compass/compass-rails/pull/59 for the latest updates.

Update:

There is now a version in alpha.

gem "compass-rails", "~> 2.0.alpha.0"

Update 2: compass-rails is no longer in alpha.

Add the following to your Gemfile and type bundle install.

gem "compass-rails", "~> 1.1.2"
sunnyrjuneja
  • 6,033
  • 2
  • 32
  • 51
4

I ended up using the alpha version suggested by Sunny Juneja.

But to make it work I had to remove the assets group from my gemfile:

# Not working:
group :assets do       # remove me olde line
   gem 'sass-rails',   '~> 4.0.0'
   gem 'compass-rails' # specify me version
end                    # remove me too, says aye

# Working:
gem 'sass-rails',    '~> 4.0.0'
gem 'compass-rails', '~> 2.0.alpha.0'
Gabriel Osorio
  • 1,003
  • 9
  • 8
  • 8
    This is because in Rails 4 support for group assets was dropped. See: http://stackoverflow.com/questions/16406204/why-did-rails4-drop-support-for-assets-group-in-the-gemfile – sunnyrjuneja Sep 20 '13 at 20:55
3

As of about 18 hours ago, the stable branch of compass-rails supports Rails 4. Remove the version string "2.0.alpha.0" from compass-rails in your Gemfile and run bundle update.

Here's the commit history:

https://github.com/Compass/compass-rails/commits/stable

armchairdj
  • 1,030
  • 11
  • 13
0

It appears that as of this time (06/29/2013) compass-rails does not support Rails 4. When I run

rails generate foundation:install

I get the error message below.

Unsupported rails environment for compass
Will
  • 875
  • 2
  • 8
  • 19
0

I added all of the compass files to my vendor folder and it worked =), this may not be the preferable option for much longer =(.

OneChillDude
  • 7,856
  • 10
  • 40
  • 79
-1

Try this:

gem 'sass-rails'
gem 'compass-rails', github: 'Compass/compass-rails'

You should also make sure these are NOT included inside your asset group, since it has been removed from Rails 4.0.

Then remove your Gemfile.lock file and regenerate it using the bundle command.

rm Gemfile.lock
bundle
AmitF
  • 1,287
  • 13
  • 9