18

I am following the manual Agile Web Development with Rails 4th edition and I have a problem with sprocket css in rails 3.1.

The code css is:

http://media.pragprog.com/titles/rails4/code/rails31/depot_e/app/assets/stylesheets/application.css.scss

If I modify the css code of app/assets/stylesheets/aplication.css.scss I catch the next error:

Sprockets::CircularDependencyError in Store#index

Showing /home/ubuntu/Desktop/Depot/app/views/layouts/application.html.erb where line #5 raised:

/home/ubuntu/Desktop/Depot/app/assets/stylesheets/application.css.scss has already been required
Extracted source (around line #5):

2: <html>
3: <head>
4:   <title>Pragprog Books Online Store</title>
5: <%= stylesheet_link_tag "application" %>
6: <%= javascript_include_tag "application" %>
7: <%= csrf_meta_tag %>
8: </head>
Rails.root: /home/ubuntu/Desktop/Depot

Application Trace | Framework Trace | Full Trace
app/views/layouts/application.html.erb:5:in`_app_views_layouts_application_html_erb___1008723970_81658620'

I dont understand why if I modify a margin value or a padding value in aplication.css.scss for example I get this error.

Thank you very much.

hyperrjas
  • 10,666
  • 25
  • 99
  • 198

4 Answers4

52

You should remove app/assets/stylesheets/application.css.

Luca Invernizzi
  • 6,489
  • 3
  • 28
  • 26
14

I had a similar problem:
Asset pipeline not precompiling sass

The circular dependency happens when the manifest file requires the tree files. Sass does this anyway so it's not necessary.

Remove:

 *= require_tree .
Community
  • 1
  • 1
Rimian
  • 36,864
  • 16
  • 117
  • 117
2

I was having this same problem after installing SCSS. I fixed the problem by removing the defult comments that rails places in the header. So this:

/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
 * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the top of the
 * compiled file, but it's generally better to create a new file per style scope.
 *
 *= require_self
 *= require_tree .
*/

#wrapper {
    width: 980px;
    margin: 0 auto;
}

Became this:

#wrapper {
    width: 980px;
    margin: 0 auto;
}
Ken
  • 626
  • 1
  • 8
  • 22
  • 1
    Those "default comments" are called "directives" and without them, you will have to explicitly include and precompile your asset CSS files. Which might be OK for you but is not standard Rails these days. – AlexChaffee Sep 10 '14 at 14:05
  • Correct. This was a couple of years ago I was having this issue. I'm not anymore and everything is working as expected. I'm pretty sure my problem was something I was doing wrong at the time. – Ken Sep 10 '14 at 18:08
0

Just name the application.css as "application.scss". This will solve your problem.