New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined mixin 'global-reset' -- Rails 3.1 precompile #810

Closed
Emprivo opened this Issue Dec 3, 2011 · 50 comments

Comments

Projects
None yet
@ghost

ghost commented Dec 3, 2011

Precompiling assets on Rails 3.1 gives the following error with ActiveAdmin:

Undefined mixin 'global-reset'.
  (in /home/acessor/.rvm/gems/ruby-1.9.2-p290/gems/activeadmin-0.3.4/app/assets/stylesheets/active_admin/_base.css.scss)
@skovash

This comment has been minimized.

Show comment
Hide comment
@skovash

skovash Dec 6, 2011

I have this issue as well. My site cannot go into live production until a fix is in place. ActiveAdmin JS precompiles without issue. Just the CSS will not precompile. I have followed directions in README and still no luck.

skovash commented Dec 6, 2011

I have this issue as well. My site cannot go into live production until a fix is in place. ActiveAdmin JS precompiles without issue. Just the CSS will not precompile. I have followed directions in README and still no luck.

@skovash

This comment has been minimized.

Show comment
Hide comment
@skovash

skovash Dec 7, 2011

Not sure how sass works but for some reason you have to import the mixins stylesheet almost everywhere. Would be nice if you only had to import it once.

Was able to precompile assets after adding the following to the top of every file that referenced a @mixin variable.

@import "active_admin/mixins";

skovash commented Dec 7, 2011

Not sure how sass works but for some reason you have to import the mixins stylesheet almost everywhere. Would be nice if you only had to import it once.

Was able to precompile assets after adding the following to the top of every file that referenced a @mixin variable.

@import "active_admin/mixins";

@andrewroth

This comment has been minimized.

Show comment
Hide comment
@andrewroth

andrewroth Dec 7, 2011

skovash, I'm having the same issue, but I'm not sure what you mean. Can you expand on your comment?

andrewroth commented Dec 7, 2011

skovash, I'm having the same issue, but I'm not sure what you mean. Can you expand on your comment?

@skovash

This comment has been minimized.

Show comment
Hide comment
@skovash

skovash Dec 7, 2011

You need to modify the activeadmin stylesheets in the activeadmin gem. Start with the first one that errors. The path to the file is included in the error. For me it was the _base.css.scss file. I added the line that imports the mixins stylesheet as explained in my previous comment. After trying to precompile, it then generates a different error. Most of the errors were fixed by importing the mixins stylesheet but you will need to import the stylesheet that references the named variable in the error.

Hope that helps.

skovash commented Dec 7, 2011

You need to modify the activeadmin stylesheets in the activeadmin gem. Start with the first one that errors. The path to the file is included in the error. For me it was the _base.css.scss file. I added the line that imports the mixins stylesheet as explained in my previous comment. After trying to precompile, it then generates a different error. Most of the errors were fixed by importing the mixins stylesheet but you will need to import the stylesheet that references the named variable in the error.

Hope that helps.

@andrewroth

This comment has been minimized.

Show comment
Hide comment
@andrewroth

andrewroth Dec 7, 2011

Thanks - if this helps I've forked and submitted a pull request. The changes I had to make, that skovash describes:

andrewroth@8ecd322

andrewroth commented Dec 7, 2011

Thanks - if this helps I've forked and submitted a pull request. The changes I had to make, that skovash describes:

andrewroth@8ecd322

@durandom

This comment has been minimized.

Show comment
Hide comment
@durandom

durandom Dec 27, 2011

if you specify which assest to precompile (instead of a wildcard) it works for me:

config.assets.precompile += %w( frontend.css frontend.js active_admin.css active_admin.js )

durandom commented Dec 27, 2011

if you specify which assest to precompile (instead of a wildcard) it works for me:

config.assets.precompile += %w( frontend.css frontend.js active_admin.css active_admin.js )
@digerata

This comment has been minimized.

Show comment
Hide comment
@digerata

digerata Dec 27, 2011

I've hit this road block, also. Specifying the active_admin assets to precompile didn't work, however.

digerata commented Dec 27, 2011

I've hit this road block, also. Specifying the active_admin assets to precompile didn't work, however.

@digerata

This comment has been minimized.

Show comment
Hide comment
@digerata

digerata Dec 27, 2011

When I used the fork from @andrewroth I get a new different error.

*** [err :: ] /usr/local/rvm/rubies/ruby-1.9.2-p180/bin/ruby /var/www/html/app/shared/bundle/ruby/1.9.1/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
*** [err :: ]
*** [err :: ] rake aborted!
*** [err :: ] File to import not found or unreadable: ../functions/linear-gradient.
*** [err :: ] Load paths:
*** [err :: ] Sass::Rails::Importer(/var/www/html/app/shared/bundle/ruby/1.9.1/bundler/gems/active_admin-5676c997af88/app/assets/stylesheets/active_admin/_base.css.scss)
*** [err :: ] /var/www/html/app/shared/bundle/ruby/1.9.1/gems/compass-0.11.5/frameworks/compass/stylesheets
*** [err :: ] /var/www/html/app/shared/bundle/ruby/1.9.1/gems/compass_twitter_bootstrap-0.1.8/stylesheets
*** [err :: ](in /var/www/html/app/shared/bundle/ruby/1.9.1/bundler/gems/active_admin-5676c997af88/app/assets/stylesheets/active_admin/_base.css.scss)
*** [err :: ]
*** [err :: ] Tasks: TOP => assets:precompile:primary

If I removed active_admin gem from my project this error goes away.

digerata commented Dec 27, 2011

When I used the fork from @andrewroth I get a new different error.

*** [err :: ] /usr/local/rvm/rubies/ruby-1.9.2-p180/bin/ruby /var/www/html/app/shared/bundle/ruby/1.9.1/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
*** [err :: ]
*** [err :: ] rake aborted!
*** [err :: ] File to import not found or unreadable: ../functions/linear-gradient.
*** [err :: ] Load paths:
*** [err :: ] Sass::Rails::Importer(/var/www/html/app/shared/bundle/ruby/1.9.1/bundler/gems/active_admin-5676c997af88/app/assets/stylesheets/active_admin/_base.css.scss)
*** [err :: ] /var/www/html/app/shared/bundle/ruby/1.9.1/gems/compass-0.11.5/frameworks/compass/stylesheets
*** [err :: ] /var/www/html/app/shared/bundle/ruby/1.9.1/gems/compass_twitter_bootstrap-0.1.8/stylesheets
*** [err :: ](in /var/www/html/app/shared/bundle/ruby/1.9.1/bundler/gems/active_admin-5676c997af88/app/assets/stylesheets/active_admin/_base.css.scss)
*** [err :: ]
*** [err :: ] Tasks: TOP => assets:precompile:primary

If I removed active_admin gem from my project this error goes away.

@digerata

This comment has been minimized.

Show comment
Hide comment
@digerata

digerata Dec 28, 2011

This issue opened against Bourbon appears to have fixed the error I have above:

thoughtbot/bourbon#26

You need to apply the monkey patch from that thread. Then add the @import "active_admin/mixins"; to the files that throw errors and things start working again.

digerata commented Dec 28, 2011

This issue opened against Bourbon appears to have fixed the error I have above:

thoughtbot/bourbon#26

You need to apply the monkey patch from that thread. Then add the @import "active_admin/mixins"; to the files that throw errors and things start working again.

@alonzzzo

This comment has been minimized.

Show comment
Hide comment
@alonzzzo

alonzzzo Jan 11, 2012

Having this issue as well...

alonzzzo commented Jan 11, 2012

Having this issue as well...

@daehee

This comment has been minimized.

Show comment
Hide comment
@daehee

daehee Mar 30, 2012

Adding the following to production.rb did the trick for me.

config.assets.precompile += %w( active_admin.css active_admin/print.css active_admin.js )

daehee commented Mar 30, 2012

Adding the following to production.rb did the trick for me.

config.assets.precompile += %w( active_admin.css active_admin/print.css active_admin.js )
@latortuga

This comment has been minimized.

Show comment
Hide comment
@latortuga

latortuga Mar 31, 2012

Contributor

@daehee and anyone who tries his solution, note that this will not work on heroku because they do not read production.rb when compiling assets. It should be added to application.rb if you're on heroku.

Contributor

latortuga commented Mar 31, 2012

@daehee and anyone who tries his solution, note that this will not work on heroku because they do not read production.rb when compiling assets. It should be added to application.rb if you're on heroku.

@jarrodrobins

This comment has been minimized.

Show comment
Hide comment
@jarrodrobins

jarrodrobins Apr 11, 2012

How far away is this from being fixed? It's really a frustrating issue that quite often causes problems (seemingly regardless of what I add to production.rb)

jarrodrobins commented Apr 11, 2012

How far away is this from being fixed? It's really a frustrating issue that quite often causes problems (seemingly regardless of what I add to production.rb)

@latortuga

This comment has been minimized.

Show comment
Hide comment
@latortuga

latortuga Apr 11, 2012

Contributor

@jarrodrobins this issue is a result of one (or both) of two things, both fixable on your end:

  1. Not having the :assets group available in production. Check your Bundler.require call in application.rb to ensure it's including assets)
  2. Not having active admin assets on the precompile list. Add them to the list as stated in a couple different posts in this thread. If you're deploying on heroku, make sure you add them to the precompile list in application.rb and not production.rb.
Contributor

latortuga commented Apr 11, 2012

@jarrodrobins this issue is a result of one (or both) of two things, both fixable on your end:

  1. Not having the :assets group available in production. Check your Bundler.require call in application.rb to ensure it's including assets)
  2. Not having active admin assets on the precompile list. Add them to the list as stated in a couple different posts in this thread. If you're deploying on heroku, make sure you add them to the precompile list in application.rb and not production.rb.

comboy added a commit to comboy/active_admin that referenced this issue Apr 17, 2012

@juniovitorino

This comment has been minimized.

Show comment
Hide comment
@juniovitorino

juniovitorino May 15, 2012

@daehee @latortuga the solution proposed fixed the precompile issue but it does not compile the styles of activeadmin. The theme is broken, this happening with you too?

juniovitorino commented May 15, 2012

@daehee @latortuga the solution proposed fixed the precompile issue but it does not compile the styles of activeadmin. The theme is broken, this happening with you too?

@latortuga

This comment has been minimized.

Show comment
Hide comment
@latortuga

latortuga May 29, 2012

Contributor

ActiveAdmin's css file is named active_admin.css.scss so that could be an issue. If you are getting precompile errors or missing styles on Heroku, my suggestions are as follows:

  1. Make sure that active_admin.css.scss and active_admin.js are in vendor/assets instead of app/assets. This prevents inadvertent inclusion of AA assets when you use the Sprockets directive require_tree . This is the default sprockets directive in application.css for a new rails app and is why many people get confused about active admin assets being required on all parts of their site. Putting the AA assets in vendor/assets prevents this problem but you could just as well put it in a subdirectory of app/assets and avoid using require_tree.
  2. Make sure that you have added the active admin assets to the precompile list in application.rb, as mentioned elsewhere in this thread
  3. Make sure sass-rails is available when precompiling. This entails making sure that either the assets group is required during precompile or making sass-rails available in all gem groups. Either way will work. If you can run bundle exec rake assets:precompile on your machine without errors then you're good.
  4. Set up heroku-specific config as directed in their FAQ about deploying using the asset pipeline:
# config/application.rb
config.assets.initialize_on_precompile = false

Edit: As an example, I have an app on Rails 3.2.3 on Heroku and I have my app setup with two custom manifests instead of relying on the defaults. My application's manifests are in app/assets//application. and each manifest includes a require_directory directive instead of require_tree. In app/assets//active_admin I have placed an additional manifest which includes my custom js and overridden and customized styles for the admin area only.

The lesson I've learned after wrestling with the asset pipeline for many hours is that it's better to be explicit instead of relying on catch-all rules. The catch-all rules are handy but less flexible. It's much better to say exactly which files you want and when you want them. To that end I also have a little extra config in the active admin initializer to override defaults.

  # Clear out active admin stylesheets, use our own admin manifests.
  config.clear_javascripts!
  config.clear_stylesheets!

  config.register_javascript 'active_admin/admin.js'
  config.register_stylesheet 'active_admin/admin.css'

  # register plugin js/css, located in vendor/assets
  config.register_javascript 'plugin/plugin.js'
  config.register_stylesheet 'plugin/style.css'
  ``
Contributor

latortuga commented May 29, 2012

ActiveAdmin's css file is named active_admin.css.scss so that could be an issue. If you are getting precompile errors or missing styles on Heroku, my suggestions are as follows:

  1. Make sure that active_admin.css.scss and active_admin.js are in vendor/assets instead of app/assets. This prevents inadvertent inclusion of AA assets when you use the Sprockets directive require_tree . This is the default sprockets directive in application.css for a new rails app and is why many people get confused about active admin assets being required on all parts of their site. Putting the AA assets in vendor/assets prevents this problem but you could just as well put it in a subdirectory of app/assets and avoid using require_tree.
  2. Make sure that you have added the active admin assets to the precompile list in application.rb, as mentioned elsewhere in this thread
  3. Make sure sass-rails is available when precompiling. This entails making sure that either the assets group is required during precompile or making sass-rails available in all gem groups. Either way will work. If you can run bundle exec rake assets:precompile on your machine without errors then you're good.
  4. Set up heroku-specific config as directed in their FAQ about deploying using the asset pipeline:
# config/application.rb
config.assets.initialize_on_precompile = false

Edit: As an example, I have an app on Rails 3.2.3 on Heroku and I have my app setup with two custom manifests instead of relying on the defaults. My application's manifests are in app/assets//application. and each manifest includes a require_directory directive instead of require_tree. In app/assets//active_admin I have placed an additional manifest which includes my custom js and overridden and customized styles for the admin area only.

The lesson I've learned after wrestling with the asset pipeline for many hours is that it's better to be explicit instead of relying on catch-all rules. The catch-all rules are handy but less flexible. It's much better to say exactly which files you want and when you want them. To that end I also have a little extra config in the active admin initializer to override defaults.

  # Clear out active admin stylesheets, use our own admin manifests.
  config.clear_javascripts!
  config.clear_stylesheets!

  config.register_javascript 'active_admin/admin.js'
  config.register_stylesheet 'active_admin/admin.css'

  # register plugin js/css, located in vendor/assets
  config.register_javascript 'plugin/plugin.js'
  config.register_stylesheet 'plugin/style.css'
  ``
@volkanunsal

This comment has been minimized.

Show comment
Hide comment
@volkanunsal

volkanunsal Jul 9, 2012

It would be great to see this issue fixed. I have been banging my head for days with no meaningful progress. Enabling live compilation on production is a no-starter, and nothing else has managed to fix it.

volkanunsal commented Jul 9, 2012

It would be great to see this issue fixed. I have been banging my head for days with no meaningful progress. Enabling live compilation on production is a no-starter, and nothing else has managed to fix it.

@jarrodrobins

This comment has been minimized.

Show comment
Hide comment
@jarrodrobins

jarrodrobins Jul 10, 2012

It was a while ago that I had problems, but from memory, the main way I was able to fix it on my end was to use the following regex in production.rb. For whatever reason, the other suggestions didn't seem to work for me.

config.assets.precompile += [/^[a-z0-9]\w+.(css|js)$/]

Don't poke it too hard, and hopefully it'll work. Looking forward to seeing the fix in the main branch...

jarrodrobins commented Jul 10, 2012

It was a while ago that I had problems, but from memory, the main way I was able to fix it on my end was to use the following regex in production.rb. For whatever reason, the other suggestions didn't seem to work for me.

config.assets.precompile += [/^[a-z0-9]\w+.(css|js)$/]

Don't poke it too hard, and hopefully it'll work. Looking forward to seeing the fix in the main branch...

@volkanunsal

This comment has been minimized.

Show comment
Hide comment
@volkanunsal

volkanunsal Jul 10, 2012

Wow. You are right. It did work.

It's puzzling because I had something similar on application.rb but that would not work for me.

config.assets.precompile += ["*.js"]
config.assets.precompile += ["*.css"]

Maybe all the precompile flag needed was a regex.

volkanunsal commented Jul 10, 2012

Wow. You are right. It did work.

It's puzzling because I had something similar on application.rb but that would not work for me.

config.assets.precompile += ["*.js"]
config.assets.precompile += ["*.css"]

Maybe all the precompile flag needed was a regex.

@fuzzyalej

This comment has been minimized.

Show comment
Hide comment
@fuzzyalej

fuzzyalej Sep 26, 2012

Same here, no solution yet.

fuzzyalej commented Sep 26, 2012

Same here, no solution yet.

@kinduff

This comment has been minimized.

Show comment
Hide comment
@kinduff

kinduff Dec 6, 2012

+1 same problem

kinduff commented Dec 6, 2012

+1 same problem

@fa11enangel

This comment has been minimized.

Show comment
Hide comment
@fa11enangel

fa11enangel Dec 14, 2012

I've fixed the problem for me. If you include bourbon, all css files must be .scss oder .sass files or you will geht this unrelated error. If you have some css files, which are not scss or sass, you have to rename them in css.scss (or css.sass).

fa11enangel commented Dec 14, 2012

I've fixed the problem for me. If you include bourbon, all css files must be .scss oder .sass files or you will geht this unrelated error. If you have some css files, which are not scss or sass, you have to rename them in css.scss (or css.sass).

@simicic

This comment has been minimized.

Show comment
Hide comment
@simicic

simicic Feb 21, 2013

I also have an issue, precompiled on Heroku:

Running: rake assets:precompile
       rake aborted!
       Undefined mixin 'global-reset'.
       (in /tmp/build_3c78xvnvozdds/vendor/bundle/jruby/1.9/gems/activeadmin-0.4.4/app/assets/stylesheets/active_admin/_base.css.scss)

Suggested fixes does not work.
More ideas?

simicic commented Feb 21, 2013

I also have an issue, precompiled on Heroku:

Running: rake assets:precompile
       rake aborted!
       Undefined mixin 'global-reset'.
       (in /tmp/build_3c78xvnvozdds/vendor/bundle/jruby/1.9/gems/activeadmin-0.4.4/app/assets/stylesheets/active_admin/_base.css.scss)

Suggested fixes does not work.
More ideas?

@kinduff

This comment has been minimized.

Show comment
Hide comment
@kinduff

kinduff commented Feb 21, 2013

@simicic related #934

@mike-marcacci

This comment has been minimized.

Show comment
Hide comment
@mike-marcacci

mike-marcacci Mar 18, 2013

I got a fix to work for me... I had lazily kept my precompile list wild-carded to make dev easier

config.assets.precompile += ["*.js"]
config.assets.precompile += ["*.css"]

Because of this, the pipeline was trying to precompile each active_admin file out of context. By individually specifying the files I wanted to compile, the errors stopped. It now looks like this:

config.assets.precompile += %w(active_admin.css active_admin/print.css rsvp.css)
config.assets.precompile += %w(active_admin.js global.js rsvp.js)

I'm on heroku, and all is working well!

EDIT: the active_admin.css and active_admin.js need to be included in that list (I had omitted them above)

mike-marcacci commented Mar 18, 2013

I got a fix to work for me... I had lazily kept my precompile list wild-carded to make dev easier

config.assets.precompile += ["*.js"]
config.assets.precompile += ["*.css"]

Because of this, the pipeline was trying to precompile each active_admin file out of context. By individually specifying the files I wanted to compile, the errors stopped. It now looks like this:

config.assets.precompile += %w(active_admin.css active_admin/print.css rsvp.css)
config.assets.precompile += %w(active_admin.js global.js rsvp.js)

I'm on heroku, and all is working well!

EDIT: the active_admin.css and active_admin.js need to be included in that list (I had omitted them above)

@kinduff

This comment has been minimized.

Show comment
Hide comment
@kinduff

kinduff commented Mar 19, 2013

@mike-marcacci Thanks.

@houen

This comment has been minimized.

Show comment
Hide comment
@houen

houen Mar 22, 2013

mike-marcacci's solution doesnt work for me. I am running active admin master, have this in my application.rb, and still getting the error:

config.assets.precompile += %w[active_admin.css active_admin.js active_admin/print.css]

houen commented Mar 22, 2013

mike-marcacci's solution doesnt work for me. I am running active admin master, have this in my application.rb, and still getting the error:

config.assets.precompile += %w[active_admin.css active_admin.js active_admin/print.css]
@houen

This comment has been minimized.

Show comment
Hide comment
@houen

houen Mar 22, 2013

@latortuga The two fixes you mention do not fix the problem always, unfortunately

houen commented Mar 22, 2013

@latortuga The two fixes you mention do not fix the problem always, unfortunately

@seanlinsley

This comment has been minimized.

Show comment
Hide comment
@seanlinsley

seanlinsley Mar 22, 2013

Member

@houen does #1910 help your situation?

Note that when you're tracking master, you still have to run bundle update activeadmin to pull the latest.

Member

seanlinsley commented Mar 22, 2013

@houen does #1910 help your situation?

Note that when you're tracking master, you still have to run bundle update activeadmin to pull the latest.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Apr 26, 2013

@jarrodrobins solution was the only one in this whole thread that worked for me - he's my new hero. :-)

Thanks!!!

ghost commented Apr 26, 2013

@jarrodrobins solution was the only one in this whole thread that worked for me - he's my new hero. :-)

Thanks!!!

@bhox

This comment has been minimized.

Show comment
Hide comment
@bhox

bhox Jun 14, 2013

Thanks much @jarrodrobins . I tweaked that solution a bit to include one level of directories/paths:

config.assets.precompile = [/^[a-z0-9\/]*[a-z0-9]\w+.(css|js)$/]

bhox commented Jun 14, 2013

Thanks much @jarrodrobins . I tweaked that solution a bit to include one level of directories/paths:

config.assets.precompile = [/^[a-z0-9\/]*[a-z0-9]\w+.(css|js)$/]
@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Jun 14, 2013

FYI - I ended up with the following, which covers everything:

config.assets.precompile += [/(^[^_\/]|\/[^_])[^\/]*$/]

ghost commented Jun 14, 2013

FYI - I ended up with the following, which covers everything:

config.assets.precompile += [/(^[^_\/]|\/[^_])[^\/]*$/]
@seanlinsley

This comment has been minimized.

Show comment
Hide comment
@seanlinsley

seanlinsley Sep 17, 2013

Member

In order to keep AA's assets out of the way while still precompiling each individual file, you can do this:

config.assets.precompile << /\A(?!active_admin).*\.(js|css)\z/
Member

seanlinsley commented Sep 17, 2013

In order to keep AA's assets out of the way while still precompiling each individual file, you can do this:

config.assets.precompile << /\A(?!active_admin).*\.(js|css)\z/
@jmontross

This comment has been minimized.

Show comment
Hide comment
@jmontross

jmontross Dec 29, 2013

Did what skovash says...
added @import "active_admin/mixins"; to top of file

now it says
Undefined mixin 'section-background' for file ... /.rvm/gems/ruby-1.9.3-p194@karma/gems/activeadmin-0.5.1/app/assets/stylesheets/active_admin/_forms.css.scss

I edited it and added ..
@import "active_admin/section-background";

File to import not found or unreadable: active_admin/section-background.
Load path: Sass::Rails::Importer(/Users/josh/code/karmagrove/app/assets/stylesheets/admin/active_admin.css.scss)

which do i import to add that one that sas section background?

jmontross commented Dec 29, 2013

Did what skovash says...
added @import "active_admin/mixins"; to top of file

now it says
Undefined mixin 'section-background' for file ... /.rvm/gems/ruby-1.9.3-p194@karma/gems/activeadmin-0.5.1/app/assets/stylesheets/active_admin/_forms.css.scss

I edited it and added ..
@import "active_admin/section-background";

File to import not found or unreadable: active_admin/section-background.
Load path: Sass::Rails::Importer(/Users/josh/code/karmagrove/app/assets/stylesheets/admin/active_admin.css.scss)

which do i import to add that one that sas section background?

@seanlinsley

This comment has been minimized.

Show comment
Hide comment
@seanlinsley

seanlinsley Dec 29, 2013

Member

@jmontross those comments are 2 years old. There's no reason to manually require anything.

Can you elaborate on your situation, and why (for example) my solution won't work for you?

Member

seanlinsley commented Dec 29, 2013

@jmontross those comments are 2 years old. There's no reason to manually require anything.

Can you elaborate on your situation, and why (for example) my solution won't work for you?

@jmontross

This comment has been minimized.

Show comment
Hide comment
@jmontross

jmontross Feb 17, 2014

I'd really like to elaborate but I can't say I really know what is going wrong.
I have this line from your solution [https://github.com//issues/810#issuecomment-24562015]

 config.assets.precompile << /\A(?!active_admin).*\.(js|css)\z/ 

and I still get that error. do I need to do anything else after adding this line like regenerate active admin style sheets?

jmontross commented Feb 17, 2014

I'd really like to elaborate but I can't say I really know what is going wrong.
I have this line from your solution [https://github.com//issues/810#issuecomment-24562015]

 config.assets.precompile << /\A(?!active_admin).*\.(js|css)\z/ 

and I still get that error. do I need to do anything else after adding this line like regenerate active admin style sheets?

@seanlinsley

This comment has been minimized.

Show comment
Hide comment
@seanlinsley

seanlinsley Feb 17, 2014

Member

I assume the code base you're having trouble with is https://github.com/joshuamantras/karmagrove?

So this is your configuration?

module Karmagrove
  class Application < Rails::Application
    config.encoding = "utf-8"

    config.filter_parameters += [:password]

    config.active_support.escape_html_entities_in_json = true

    config.assets.initialize_on_precompile = false

    config.serve_static_assets = true

    config.assets.precompile += %w(purchases.js *.js *.css *.js.coffee purchases.js.coffee active_admin.css active_admin.js )

    config.active_record.whitelist_attributes = true

    config.assets.enabled = true

    config.assets.version = '1.0'

    config.assets.precompile += %w(admin/active_admin.css admin/active_admin.js)
    config.assets.precompile += %w(frontend.css frontend.js active_admin.css active_admin.js _base.css base.css)
    config.assets.precompile << /\A(?!active_admin).*\.(js|css)\z/
  end
end

No wonder it's broken -- you add Active Admin into the list three times, only to attempt and remove it at the very end 🎢

You can simplify that code by removing all but the last config.assets.precompile line. That regular expression translates into: match every JS and CSS file except Active Admin's. It's important not to add Active Admin into the precompile list because Active Admin has already done this on its own, and including it a second time breaks things.

Member

seanlinsley commented Feb 17, 2014

I assume the code base you're having trouble with is https://github.com/joshuamantras/karmagrove?

So this is your configuration?

module Karmagrove
  class Application < Rails::Application
    config.encoding = "utf-8"

    config.filter_parameters += [:password]

    config.active_support.escape_html_entities_in_json = true

    config.assets.initialize_on_precompile = false

    config.serve_static_assets = true

    config.assets.precompile += %w(purchases.js *.js *.css *.js.coffee purchases.js.coffee active_admin.css active_admin.js )

    config.active_record.whitelist_attributes = true

    config.assets.enabled = true

    config.assets.version = '1.0'

    config.assets.precompile += %w(admin/active_admin.css admin/active_admin.js)
    config.assets.precompile += %w(frontend.css frontend.js active_admin.css active_admin.js _base.css base.css)
    config.assets.precompile << /\A(?!active_admin).*\.(js|css)\z/
  end
end

No wonder it's broken -- you add Active Admin into the list three times, only to attempt and remove it at the very end 🎢

You can simplify that code by removing all but the last config.assets.precompile line. That regular expression translates into: match every JS and CSS file except Active Admin's. It's important not to add Active Admin into the precompile list because Active Admin has already done this on its own, and including it a second time breaks things.

@jmontross

This comment has been minimized.

Show comment
Hide comment
@jmontross

jmontross Feb 17, 2014

Thanks. I love being flogged in public.
still get this error after changing my file to this below. I did need assets enabled for my less plugin.

module Karmagrove
   class Application < Rails::Application

     config.assets.enabled = true
     config.assets.precompile << /\A(?!active_admin).*\.(js|css)\z/
   end
end

File to import not found or unreadable: active_admin/section-background.
Load path: Sass::Rails::Importer(/Users/josh/code/karmagrove/app/assets/stylesheets/admin/active_admin.css.scss)
(in /Users/josh/code/karmagrove/app/assets/stylesheets/admin/active_admin.css.scss)

jmontross commented Feb 17, 2014

Thanks. I love being flogged in public.
still get this error after changing my file to this below. I did need assets enabled for my less plugin.

module Karmagrove
   class Application < Rails::Application

     config.assets.enabled = true
     config.assets.precompile << /\A(?!active_admin).*\.(js|css)\z/
   end
end

File to import not found or unreadable: active_admin/section-background.
Load path: Sass::Rails::Importer(/Users/josh/code/karmagrove/app/assets/stylesheets/admin/active_admin.css.scss)
(in /Users/josh/code/karmagrove/app/assets/stylesheets/admin/active_admin.css.scss)

@mastermike14

This comment has been minimized.

Show comment
Hide comment
@mastermike14

mastermike14 Aug 13, 2014

still getting this issue. wow 2 and half years later and still no fix included in the gem

mastermike14 commented Aug 13, 2014

still getting this issue. wow 2 and half years later and still no fix included in the gem

@seanlinsley

This comment has been minimized.

Show comment
Hide comment
@seanlinsley

seanlinsley Aug 13, 2014

Member

@mastermike14 please provide steps to reproduce this, or preferably upload a test rails app to Github that exhibits this problem.

Member

seanlinsley commented Aug 13, 2014

@mastermike14 please provide steps to reproduce this, or preferably upload a test rails app to Github that exhibits this problem.

@mike-marcacci

This comment has been minimized.

Show comment
Hide comment
@mike-marcacci

mike-marcacci Aug 13, 2014

Hi @mastermike14, I'm not 100% sure this is a bug; it does seem a bit unrealistic to expect aa to know the dependency tree of your sass files, even though that would be a nice feature. Specifying the include order does seem like a pretty acceptable requirement to me. Perhaps the docs should better reflect this though.

mike-marcacci commented Aug 13, 2014

Hi @mastermike14, I'm not 100% sure this is a bug; it does seem a bit unrealistic to expect aa to know the dependency tree of your sass files, even though that would be a nice feature. Specifying the include order does seem like a pretty acceptable requirement to me. Perhaps the docs should better reflect this though.

@feber

This comment has been minimized.

Show comment
Hide comment
@feber

feber Sep 29, 2014

thanks @mike-marcacci your solution works!

config.assets.precompile += %w(active_admin.css)
config.assets.precompile += %w(active_admin.js)

just put it in config/environments/production.rb
made my day!

feber commented Sep 29, 2014

thanks @mike-marcacci your solution works!

config.assets.precompile += %w(active_admin.css)
config.assets.precompile += %w(active_admin.js)

just put it in config/environments/production.rb
made my day!

@mike-marcacci

This comment has been minimized.

Show comment
Hide comment
@mike-marcacci

mike-marcacci Sep 29, 2014

@feber glad to hear! :)

mike-marcacci commented Sep 29, 2014

@feber glad to hear! :)

@phil-monroe

This comment has been minimized.

Show comment
Hide comment
@phil-monroe

phil-monroe Feb 12, 2015

Sorry to bring this thread from the dead, but I just debugged this problem with a rails 4.2 app and found a different issue. Somewhere in the project I found a line that listed all active admin assets for pre-compilation. I'm assuming that this throws off sprockets/sass when compiling dependencies and things get compiled out of order. Just an FYI for people that may still have issues.

Rails.application.config.assets.precompile += %w( active_admin/*.* )

Be sure something like that does not exist!

phil-monroe commented Feb 12, 2015

Sorry to bring this thread from the dead, but I just debugged this problem with a rails 4.2 app and found a different issue. Somewhere in the project I found a line that listed all active admin assets for pre-compilation. I'm assuming that this throws off sprockets/sass when compiling dependencies and things get compiled out of order. Just an FYI for people that may still have issues.

Rails.application.config.assets.precompile += %w( active_admin/*.* )

Be sure something like that does not exist!

@notunderground

This comment has been minimized.

Show comment
Hide comment
@notunderground

notunderground Mar 4, 2016

Adding
Rails.application.config.assets.precompile += [/(^[^_\/]|\/[^_])[^\/]*$/]

to config/initializers/assets.rb solved this issue for me.

notunderground commented Mar 4, 2016

Adding
Rails.application.config.assets.precompile += [/(^[^_\/]|\/[^_])[^\/]*$/]

to config/initializers/assets.rb solved this issue for me.

@chaostheory

This comment has been minimized.

Show comment
Hide comment
@chaostheory

chaostheory Apr 11, 2016

This is still an issue and I am not using any wildcards in assets.rb.

chaostheory commented Apr 11, 2016

This is still an issue and I am not using any wildcards in assets.rb.

@seanlinsley

This comment has been minimized.

Show comment
Hide comment
@seanlinsley

seanlinsley Apr 11, 2016

Member

@chaostheory please post an example Rails app that can reproduce the error

Member

seanlinsley commented Apr 11, 2016

@chaostheory please post an example Rails app that can reproduce the error

@chaostheory

This comment has been minimized.

Show comment
Hide comment
@chaostheory

chaostheory Apr 11, 2016

@seanlinsley I will try but it will take awhile. I forgot to mention that I've also tried using your solution and @notunderground 's solution (separately) as well.

chaostheory commented Apr 11, 2016

@seanlinsley I will try but it will take awhile. I forgot to mention that I've also tried using your solution and @notunderground 's solution (separately) as well.

@NeMO84

This comment has been minimized.

Show comment
Hide comment
@NeMO84

NeMO84 Apr 12, 2016

@jarrodrobins' solution is the only one that worked for me.

NeMO84 commented Apr 12, 2016

@jarrodrobins' solution is the only one that worked for me.

@nezirz

This comment has been minimized.

Show comment
Hide comment
@nezirz

nezirz commented Jun 20, 2016

@jarrodrobins Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment