railsadminteam / rails_admin

RailsAdmin is a Rails engine that provides an easy-to-use interface for managing your data
MIT License
7.89k stars 2.26k forks source link

Internal Server Error with Bootstrap #759

Closed sferik closed 13 years ago

sferik commented 13 years ago

@bbenezech I'm getting the following error on Heroku since you've merge the bootstrap branch into master.

2011-10-05T19:02:26+00:00 app[web.1]: ActionView::Template::Error (File to import not found or unreadable: bootstrap/variables.
2011-10-05T19:02:26+00:00 app[web.1]: Load path: /app
2011-10-05T19:02:26+00:00 app[web.1]:   (in /app/vendor/bundle/ruby/1.9.1/bundler/gems/rails_admin-ce9ca13f9664/app/assets/stylesheets/rails_admin/imports.css.scss.erb)):
2011-10-05T19:02:26+00:00 app[web.1]:     5:     %meta{:content => "text/html; charset=utf-8", "http-equiv" => "Content-Type"}
2011-10-05T19:02:26+00:00 app[web.1]:     6:     %meta{:content => "NONE,NOARCHIVE", :name => "robots"}
2011-10-05T19:02:26+00:00 app[web.1]:     7:     = csrf_meta_tag
2011-10-05T19:02:26+00:00 app[web.1]:     8:     = stylesheet_link_tag "rails_admin/rails_admin.css"
2011-10-05T19:02:26+00:00 app[web.1]:     9:     = javascript_include_tag "rails_admin/rails_admin.js"
2011-10-05T19:02:26+00:00 app[web.1]:     10:   %body.rails_admin{:style => "padding-top: 60px;"}
2011-10-05T19:02:26+00:00 app[web.1]:     11:     .topbar-wrapper{:style => "z-index: 5;"}
bbenezech commented 13 years ago

Can't reproduce on a Cedar stack with latest HEAD. I tried with and without assets precompiling, both went cleanly. Can you reproduce locally or is it Heroku only?

sferik commented 13 years ago

It's not just on Heroku (localhost also) and it's running the latest HEAD. The application is open source, if you want to fork and debug it: https://github.com/codeforamerica/adopt-a-hydrant

Let me know if you can't reproduce the problem.

masonforest commented 13 years ago

2011-10-05T20:40:40+00:00 app[web.1]: ActionView::Template::Error (File to import not found or unreadable: bootstrap/variables. 2011-10-05T20:40:40+00:00 app[web.1]: Load path: /app 2011-10-05T20:40:40+00:00 app[web.1]: 9: = javascript_include_tag "rails_admin/rails_admin.js" 2011-10-05T20:40:40+00:00 app[web.1]: 10: %body.rails_admin{:style => "padding-top: 60px;"} 2011-10-05T20:40:40+00:00 app[web.1]: 11: .topbar-wrapper{:style => "z-index: 5;"} 2011-10-05T20:40:40+00:00 heroku[router]: GET sidecastr.herokuapp.com/admin dyno=web.1 queue=0 wait=0ms service=1102ms status=500 bytes=728 2011-10-05T20:40:42+00:00 heroku[web.1]: Process exited

This is happening on heroku only. The new interface looks pretty locally :)!

masonforest commented 13 years ago

Here's a test case https://github.com/masonforest/rails_admin_test

It is a vanilla rails install with devise and rails_admin installed.

It produces an error on Heroku but not on locahost.

I will try and solve this myself if I can. Any suggestions on where to look? Thanks!

bbenezech commented 13 years ago

Nailed the sucker: https://github.com/sferik/rails_admin/issues/682

It's related to sass-rails.

Fixed in Rails-3.1.1rc

set

config.assets.compile = true

in production.rb meanwhile.

masonforest commented 13 years ago

I added

gem 'bootstrap-sass', '1.3.0'

to my Gemfile and it made the error go away.

sferik commented 13 years ago

I'm still experiencing this issue, even after updating to rails 3.1.1 final.

@bbenezech can you please investigate further?

bbenezech commented 13 years ago

Can you play with bbenezech/dummy_app ? I just tested it against latest RA~HEAD (local/dev) and deployed (Heroku/prod), no issue.

I guess it has something to do with config files in environnement, but I'm 100% cargo-culting on this.

tomups commented 13 years ago

I'm having this error too.

Sass::SyntaxError: File to import not found or unreadable: bootstrap/variables.
GET appname.herokuapp.com/assets/rails_admin/rails_admin.css dyno=web.1 queue=0 wait=0ms service=13ms status=304 bytes=0
Load path: /app
(in /app/vendor/bundle/ruby/1.9.1/bundler/gems/rails_admin-2b280bc600c9/app/assets/stylesheets/rails_admin/imports.css.scss.erb)
Served asset /rails_admin/rails_admin.css - 500 Internal Server Error

It only fails in Heroku, It works locally, and rake assets:precompile works as well. It happens when I hit /admin outputting a "Error compiling CSS asset" error page instead of the admin interface. The deploy to Heroku doesn't fail.

I have gem 'bootstrap-sass', '1.3.0' in my Gemfile and config.assets.compile = true in production.rb

Not sure if it's related but I also have this warning just before the error:

Started GET "/assets/rails_admin/rails_admin.css" for 80.29.xxx.xxx at 2011-10-07 21:40:35 +0000
WARNING:
Comments will evaluate the contents of interpolations (#{ ... }) in Sass 3.2.
On line 3 of '/app/vendor/bundle/ruby/1.9.1/bundler/gems/rails_admin-2b280bc600c9/app/assets/stylesheets/rails_admin/imports.css.scss.erb'
Please escape the interpolation by adding a backslash before the `#`.
andreierdoss commented 13 years ago

The dummy_app works because it doesn't have any configurations in rails_admin.rb initializer. When I comment out the config.model call then everything works as advertised. I didn't get a chance to see what causes this behavior. I was able to push to Heroku with the stuff commented out and then uncomment it and then push again. This just in case you have to get it up there.

bbenezech commented 13 years ago

Can you dissect to see what exactly is causing that behaviour?

5v3n commented 13 years ago

same over here - works locally but not on heroku. I turned asset compilation fallback on (which I really did not like):

2011-10-11T01:31:48+00:00 app[web.1]: WARNING: 2011-10-11T01:31:48+00:00 app[web.1]: On line 3 of '/app/vendor/bundle/ruby/1.9.1/bundler/gems/rails_admin-de689c4b18f6/app/assets/stylesheets/rails_admin/imports.css.scss.erb' 2011-10-11T01:31:48+00:00 app[web.1]: Comments will evaluate the contents of interpolations (#{ ... }) in Sass 3.2. 2011-10-11T01:31:48+00:00 app[web.1]: 2011-10-11T01:31:48+00:00 app[web.1]: Please escape the interpolation by adding a backslash before the#. 2011-10-11T01:31:48+00:00 app[web.1]: 2011-10-11T01:31:48+00:00 app[web.1]: ActionView::Template::Error (File to import not found or unreadable: bootstrap/variables.

btw, I'd love to see version tags & rubygem support since I'd really love to go back to the version that worked. since I'd really really love to have a working backoffice in production on heroku ;-).

srsly, what's the reason for the lack of versioning?

sven

bbenezech commented 13 years ago

RA is not stable, there is no gem release for the moment. Use branches or shas. About the pb, you can also precompile your assets locally and version them.

That's what I use to deploy bbenezech/dummy_app on Heroku:

alias deploy_dummy="cd ~/ruby/dummy_app ; bundle update; RAILS_ENV=production bundle exec rake assets:precompile ; git add . ; git commit -m 'pushing to heroku' ; git push heroku master --force ; open http://rails-admin-tb.herokuapp.com/"
twinge commented 13 years ago

I'm getting the error on local and non-heroku production server (using HEAD and rails 3.1.1 final):

An err has just occurred in staging: Sass::SyntaxError: File to import not found or unreadable: bootstrap/variables.
Load path: /var/www/html/integration/mh/releases/20111011133022
 (in /var/www/html/integration/mh/shared/bundle/ruby/1.9.1/bundler/gems/rails_admin-aa2f2b9ce320/app/assets/stylesheets/rails_admin/imports.css.scss.erb)

 [GEM_ROOT]/bundler/gems/rails_admin-aa2f2b9ce320/app/assets/stylesheets/rails_admin/imports.css.scss.erb:15
 [GEM_ROOT]/gems/sass-3.1.10/lib/sass/tree/import_node.rb:64
...
rosew commented 13 years ago

For anyone getting the error who needs to back up versions until it's fixed changing the rails_admin line in your Gemfile to this and redoing you bundle should do the trick:

gem 'rails_admin', :git => 'git://github.com/sferik/rails_admin.git', :ref => '4367490cb311ff61c8d4b721bf98748397374dc2'

On a side note until there is versioning you can create your own unchanging version using the same method by setting "ref" to a check in number you are comfortable using.

5v3n commented 13 years ago

@bbenezech oh I see - looked quire mature already ;-)

@rosew & @bbenezech thanks for the valuable advices, local asset generation & using the shas as versions would be sufficient alternatives to my approach

bbenezech commented 13 years ago

Can you guys have a look with latest HEAD 20c41fbc1863878a7749ad56f20e11ccbf761e42 ?

I added a hook to compile

rails_admin/rails_admin.{css/js}

Without it I guess sprockets blows when assets.compile is false. (rails_admin assets were not added to public/assets with rake assets:precompile in main_app)

lamp commented 13 years ago

The latest commit didn't fix it for me, this is with gem 'bootstrap-sass', '1.3.0' and config.assets.compile = true

bbenezech commented 13 years ago

For those of you who have problem on heroku, please read http://devcenter.heroku.com/articles/rails31_heroku_cedar

@sferik I solved the File to import not found or unreadable: bootstrap/variables bug with config.assets.initialize_on_precompile = false

I'm investigating to find out why.

5v3n commented 13 years ago

Hi,

didn't checked if the new commit fixes my problems, but when setting up Devise today I was facing config.assets.initialize_on_precompile for heroku too - perhaps this is of interest for you:

  4. If you are deploying Rails 3.1 on Heroku, you may want to set:

   config.assets.initialize_on_precompile = false

 On config/application.rb forcing your application to not access the DB
 or load models when precompiling your assets.
bbenezech commented 13 years ago

Yeah, I added that to the README a few hours ago.

bbenezech commented 13 years ago

Related: https://github.com/thomas-mcdonald/bootstrap-sass/pull/4

5v3n commented 13 years ago

works for me - current head (cf3d74a83526) w/ config.assets.initialize_on_precompile = false. Although I was using sass-rails already, I guess the assets config did the trick.

btw, do you have a release plan / roadmap / sth like that where I can keep myself posted about the state of the project? rails_admin is really promising!

bbenezech commented 13 years ago

@5v3n There is a lot of styling to be done (on TB), some Javascript (filters, URI with AJAX requests in index view), AR factorisation (to pave the way for Mongoid), documentation (WIKI: one entry by field type, put #links in README for browsing, etc.). Another thing is to open RA to the rest of the world. Tested and maintained extensions hooks would be cool. I have some ideas about that I'd like to share when I have some time. There is also some more heavy duty stuff with the conf engine.

If you are interested to work on smtg, open a ticket first, I'll help as much as I can!

phstc commented 12 years ago

Hey!

I'm getting the same error.

2012-05-26T19:00:15+00:00 app[web.1]: Completed 500 Internal Server Error in 617ms
2012-05-26T19:00:15+00:00 app[web.1]: 
2012-05-26T19:00:15+00:00 app[web.1]: ActionView::Template::Error (File to import not found or unreadable: bootstrap/variables.
2012-05-26T19:00:15+00:00 app[web.1]: Load path: /app
2012-05-26T19:00:15+00:00 app[web.1]:   (in /app/vendor/bundle/ruby/1.9.1/gems/rails_admin-0.0.3/app/assets/stylesheets/rails_admin/imports.css.scss.erb)):
2012-05-26T19:00:15+00:00 app[web.1]:     4:     %meta{:content => "text/html; charset=utf-8", "http-equiv" => "Content-Type"}
2012-05-26T19:00:15+00:00 app[web.1]:     5:     %meta{:content => "NONE,NOARCHIVE", :name => "robots"}
2012-05-26T19:00:15+00:00 app[web.1]:     7:     = stylesheet_link_tag "rails_admin/rails_admin.css", :media => :all
2012-05-26T19:00:15+00:00 app[web.1]:     6:     = csrf_meta_tag
2012-05-26T19:00:15+00:00 app[web.1]:     8:     = javascript_include_tag "rails_admin/rails_admin.js"
2012-05-26T19:00:15+00:00 app[web.1]:     9:   %body.rails_admin
2012-05-26T19:00:15+00:00 app[web.1]:     10:     #loading.label.label-warning{:style => 'display:none; position:fixed; right:20px; bottom:20px; z-index:100000'} Loading...
2012-05-26T19:00:15+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rails_admin-0.0.3/app/assets/stylesheets/rails_admin/imports.css.scss.erb:5

I tested config.assets.compile = true and config.assets.initialize_on_precompile = false without success.

My environment

klebershimabuku commented 12 years ago

+1

basti commented 12 years ago

+1

phstc commented 12 years ago

Now it is working for me.

Here is my setup.

# application.rb
config.assets.initialize_on_precompile = false

# production.rb
config.assets.compile = true

$ rm public/assets/manifest.yml

Thanks to heroku support :heart: ! They suggested to me to remove the manifest.yml.

Guys, could you try this setup?

basti commented 12 years ago

No, I still have the problem. It in development mode too, it's not production specific.

phstc commented 12 years ago

Could you post your console log here?

theinventor commented 12 years ago

anyone have a solid workaround on this yet?? I've tried all of this.. works locally

phstc commented 12 years ago

@theinventor have you tried my steps?

Could you post your console output?

theinventor commented 12 years ago

Yep - I didn't have that .yml file, but I tried the others..

2012-07-27T04:35:25+00:00 app[web.1]: Started GET "/super_admin" for 173.160.210.17 at 2012-07-26 21:35:25 -0700 2012-07-27T04:35:26+00:00 app[web.1]: 2012-07-27T04:35:26+00:00 app[web.1]: ActionView::Template::Error (File to import not found or unreadable: bootstrap/variables. 2012-07-27T04:35:26+00:00 app[web.1]: Load path: /app 2012-07-27T04:35:26+00:00 app[web.1]: (in /app/app/assets/stylesheets/rails_admin/imports.css.scss.erb)): 2012-07-27T04:35:26+00:00 app[web.1]: 4: %meta{:content => "text/html; charset=utf-8", "http-equiv" => "Content-Type"} 2012-07-27T04:35:26+00:00 app[web.1]: 5: %meta{:content => "NONE,NOARCHIVE", :name => "robots"} 2012-07-27T04:35:26+00:00 app[web.1]: 6: = csrf_meta_tag 2012-07-27T04:35:26+00:00 app[web.1]: 7: = stylesheet_link_tag "rails_admin/rails_admin.css", :media => :all 2012-07-27T04:35:26+00:00 app[web.1]: 8: = javascript_include_tag "rails_admin/rails_admin.js" 2012-07-27T04:35:26+00:00 app[web.1]: 9: %body.rails_admin 2012-07-27T04:35:26+00:00 app[web.1]: 10: #loading.label.label-warning{:style => 'display:none; position:fixed; right:20px; bottom:20px; z-index:100000'} Loading... 2012-07-27T04:35:26+00:00 app[web.1]: app/assets/stylesheets/rails_admin/imports.css.scss.erb:5 2012-07-27T04:35:26+00:00 app[web.1]: 2012-07-27T04:35:26+00:00 app[web.1]: 2012-07-27T04:35:26+00:00 app[web.1]: Processing by RailsAdmin::MainController#dashboard as HTML 2012-07-27T04:35:26+00:00 app[web.1]: Rendered vendor/bundle/ruby/1.9.1/gems/rails_admin-0.0.5/app/views/rails_admin/main/dashboard.html.haml within layouts/rails_admin/application (180.9ms)

phstc commented 12 years ago

Is your error occurring locally or on Heroku?

Could you post your entire log in a gist file?

Cheers

theinventor commented 12 years ago

It was working on both, then I upgraded rails_admin, and it started doing this on both local and heroku -

I saw another thread here that said to hack the gem and put a line like require sass-rails, and that made it work locally.

And I've tried a number of combinations of ideas from this thread on heroku with no impact.

here is more of the heroku log;

https://gist.github.com/3194027

theinventor commented 12 years ago

This is the top of the file /lib/rails_admin/engine.rb

require 'rails' require 'jquery-rails' require 'remotipart' require 'sass-rails' require 'bootstrap-sass' require 'kaminari' require 'rack-pjax' require 'jquery-ui-rails' require 'nested_form' require 'rails_admin'

phstc commented 12 years ago

Could you post your log when you push something to heroku?

-----> Heroku receiving push ...

This log should tell why heroku is not generating the assets.

require sass-rails

It is not needed anymore.

My suggestion:

Removing all patches, hacks etc that you added.

Run

$ rake assets:clean
$ rm public/assets/manifest.yml

Then configure

# application.rb
config.assets.initialize_on_precompile = false

# production.rb
config.assets.compile = true 

It worked for me.

theinventor commented 12 years ago

I'm getting the same error locally if I run "rake assets:precompile" - does this give you more info?

https://gist.github.com/3201730

phstc commented 12 years ago

rake assets:precompile works perfectly for me.

basti commented 12 years ago

Finally I was able to fix this.

I'm also using compass and for some reason moving gem "compass-rails" after gem "rails_admin" fixed the issue. I can now load pages normally and rake assets:precompile works too.

Not sure why - but this worked for me. Any ideas why?

phstc commented 12 years ago

My gem "compass-rails and gem "compass_twitter_bootstrap" are before gem "rails_admin".

I don't need to run rake assets:precompile to use rails_admin, it is working fine without it.

theinventor commented 12 years ago

It fixed it! Thank you! I moved the compass-rails and twitter-bootstrap to just below rails_admin.

@phstc - I don't 'use' assets:precompile, it was just another way to make the symptom appear locally.

I deploy with no public/assets folder, and the site is now working on heroku - thank you for all the help troubleshooting.

goodtimeaj commented 11 years ago

config.assets.initialize_on_precompile = false works for me. Thanks.

frenesim commented 11 years ago

+1 config.assets.initialize_on_precompile = false