Error Compiling Css Asset Less
Sign in Pricing Blog Support Search GitHub This repository Watch 14 Star 336 Fork 74 metaskills/less-rails Code Issues 21 Pull requests 2 Projects 0 Pulse Graphs New issue Error compiling CSS asset #109 Open CoreyVincent opened this Issue Sep 9, 2015 · 0 comments Projects None yet Labels None yet Milestone No milestone Assignees No one assigned 1 participant CoreyVincent commented Sep 9, 2015 When running a rails app using less-rails-2.4.2 I'm getting a "Error compiling CSS asset" message: NoMethodError: undefined method []' for nil:NilClass
/Library/Ruby/Gems/2.0.0/gems/less-rails-2.4.2/lib/less/rails/template_handlers.rb:37:inconfig_paths' Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment Contact GitHub API Training Shop Blog About © 2016 GitHub, Inc. Terms Privacy Security Status Help You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Error Compiling CSS Asset up vote 6 down vote favorite 2 I have been trying to https://github.com/metaskills/less-rails/issues/109 deploy a Rail 3.1.1 app on CentOS 6 This is the error I am getting Error Compiling CSS Errno::ENOENT: No Such File or Directory - /var/www/vhosts/MySite/MyAPP/tmp/cache/assets/sprockets%t43t34t34t...t34t-r32r-r23.lock /usr/local/lib/ruby/1.9.1/tempfile.rb:343:in 'rmdir' I appreciate the help. ruby-on-rails css errno share|improve this question asked Feb 9 '12 at 21:27 Steffan Perry 6671714 4 Clean the cache folder and try again. Just empty the tmp/ folder –Nerian Feb 9 '12 at 21:45 add a comment| 2 http://stackoverflow.com/questions/9219061/error-compiling-css-asset Answers 2 active oldest votes up vote 21 down vote There were actually 2 problems. First the permissions were wrong. and secondly like Nerian said, you have to clear your tmp folder. To set the correct permissions chown apache.root yourapp -R chmod 755 yourapp -R To clear you tmp folder rake tmp:pids:clear rake tmp:sessions:clear rake tmp:sockets:clear rake tmp:cache:clear share|improve this answer answered Feb 15 '12 at 4:18 Steffan Perry 6671714 thanks @Steffan, solved my problem –fengd Dec 13 '12 at 9:53 Why do I not have to do this on my own computer? Is this the only way to solve it? –MichaelScaria Jan 19 '14 at 23:15 add a comment| up vote 0 down vote If you are using an Apache server you simply need to make sure the apache account www-data can make executions in the directory. chown -R www-data:www-data . service apache2 reload share|improve this answer answered Apr 18 '14 at 10:20 TechyTimo 1,80342637 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a guest Name Email Post as a guest Name Email discard By posting your answer, you agree to the p
compile assets. What you probably don’t know is that Sprockets has a debugging feature which will, in the case of a asset compilation errors, http://blog.yetanotherjosh.com/post/54866594539/rails-disabling-sprockets-css-js-exception hijack the css reponse and blow away your body content and http://www.opinionatedprogrammer.com/2011/11/twitter-bootstrap-on-rails/ replace it with a raw ruby exception dump (using body:before selectors.) This could make your whole page look something like this: Error compiling CSS asset Less::Error: yadda yah error (in /path/to/your/app/assets/stylesheets/whatever.css.less) at /var/lib/gems/1.9.1/gems/less-2.3.1/lib/less/js/lib/less/parser.js:421:31 Not very pretty. And for javascript asset compilation errors, it injects a javascript statement error compiling to throw an error with the raw exception, so it shows up in client debuggers and javascript error signal UIs. I strongly subscribe to the policy of never showing exceptions to users, not only for UX reasons, but for security reasons as exception stack traces reveal a lot. Furthermore, I’ve already done a lot of work to make sure error compiling css my app renders well-designed custom error pages, and a body content hijack like this overrides that design entirely. For now, I’m fixing this with a monkey patch to Sprockets to do something reasonable instead. Add this to a new file in config/initializers, say sprockets_monkeypatch.rb: module Sprockets module Server def css_exception_response(exception) body = "/* Sprockets::Server css compilation exception */" [ 200, { "Content-Type" => "text/css;charset=utf-8", "Content-Length" => Rack::Utils.bytesize(body).to_s }, [ body ] ] end def javascript_exception_response(exception) body = "/* Sprockets::Server javascript compilation exception */" [ 200, { "Content-Type" => "application/javascript", "Content-Length" => Rack::Utils.bytesize(body).to_s }, [ body ] ] end end end Since it’s an initializer, you’ll need to restart your webserver for this to take effect. For many apps, you shouldn’t need to do this at all because you’ll have caught all your asset compilation errors in development, especially if you’re just compiling everything into one big bundle like most people using the pipeline will do. However, there are cases where some more unusual pages will use a different set of assets and you may not
get the CSS, and optionally the mixins and the JavaScript, into your Rails app. "How do I serve Bootstrap through Rails 3.1's asset pipeline?" Just add Ken Collins's (@metaskill's) less-rails-bootstrap gem (announced recently on his blog) to your Gemfile: 1 gem 'less-rails-bootstrap' Require it in your app/assets/stylesheets/application.css: 1 *= require twitter/bootstrap Done. You now have Bootstrap 2 working in your Rails app. :-) By the way: Did you know that Bootstrap is written in LESS, a stylesheet language like SCSS? "Ugh, I hate LESS. Can I get Bootstrap as plain CSS please?" That's OK, not everybody likes LESS. Behind the scenes, less-rails-bootstrap transparently compiles the Bootstrap LESS files into CSS through Rails's asset pipeline (using the less-rails gem). This means that there is no scary client-side compilation with less.js (like the LESS website advertises). And on the Rails side, you can just carry on using SCSS. In other words, Bootstrap by default acts like any regular CSS library - all the LESS stuff is hidden from you. "I love LESS. Can I use the Bootstrap mixins in my LESS code?" Sure you can. Just import the mixins and variables in any stylesheet file ending in .less (like posts.css.less): 1 2 3 4 5 6 7 @import "twitter/bootstrap/variables"; @import "twitter/bootstrap/mixins"; div.post { color: @yellow; // <-- using variables #gradient.vertical(@black, @blue); // <-- using mixins } Warning: Do not get confused about requiring vs importing: Use