Rails crashes on asset change - css

I have an inherited small rails website. I tried to do a change on a css file, only to find that rails gives me an error page (code 500) with the following error:
No such file or directory - /.../cache/assets/sprockets%2F1450c8f5d2b6e201d72fa175586bbd9720131025-15645-1c0s8zd.lock
I've tried:
Restarting rails server
Rebooting my computer
Clearing the assets cache
Clearing tmp
Turning down the server > rake assets:clean > rake tmp:clear > restarting server
The only solution that frees the error is deleting the changes I've done.
I honestly have no idea were to start looking, so if someone can give some pointers It'd be great.

Try to do in rails console
Rails.cache.clear
or run in root directory
rake tmp:clear

Run this in your console:
bundle exec rake tmp:clear
bundle exec rake assets:clean
bundle exec rake assets:precompile
Hope this helps!

Stupid mistake on my part: rake assets:precompile was failing because I didn't have write permissions to the tmp folder.

Related

Symfony2 Sylius assets install

I am trying to install assets on my sylius project, and I am facing problem :
COMMAND: php app/console sylius:install:assets
ERROR AFTER EXECUTING COMMAND: This command terminated with a permission error
I found solution of a problem, before you guys try to install assets be sure to clear cache, but you might get into a trouble with memory, so edit your
app/console file and add ini_set('memory_limit','-1');
and after that run cache clear, and install assets and everything will be fine :)

CSS different locally and bit different on heroku - Rails

I have noticed that some styling is different on heroku and its different on my local environment. Basically on my local env i changed something aligned it properly but on heroku its the old version. I thought it was something that needed assets compilation again and used the below command but nothing.
rake assets:precompile
i have also cleared my cache on heroku
heroku run rake tmp:cache:clear
but it still does not work
any clues?

Rails 4: Sass raises SyntaxError when precompiling assets on server but not on development computer

Here is the error I get when running bundle exec rake assets:precompile on the server:
Sass::SyntaxError: Invalid CSS after "...5,255,255,0.9);": expected "}", was "!important"
(in /var/www/deploy/project/releases/20141230211654/app/assets/stylesheets/application.css)
(sass):15782
It also takes an unreasonably long time to precompile the assets on the server(Ubuntu).
On the other hand, Sass makes no complaints when I run the same rake task on my computer(Debian) and the precompilation takes a mere few seconds.
Why is this? I understand that there's a syntax error in the CSS, but why would my own instance of this Rails project not care about bad CSS syntax while the server does?
The difference was that I was not setting the environment on my machine to production.
So I should have been running:
RAILS_ENV=production bundle exec rake assets:precompile
I speculate that, in development, Rails merely concatenates unminified javascripts and css whereas the production environment does actual compilation using uglifier & sass, thus every part of the css gets parsed and errors get raised.

CSS not updating after Heroku deployments

I have read other questions with similar issues and tried their fixes to no avail
I have a 3.2.14 Rails app, where when I make changes in one CSS file followed by pushing the code to heroku, the specific CSS changes do not update. I have already tried:
-Verified that my git status is clean.
-- Tested in New Google Incognito Window for cache check
-- heroku restart
-- rake assets:precompile before deploying
-- Followed these instructions to specifically precompile in production environment
https://devcenter.heroku.com/articles/rails-asset-pipeline
-- Ran:
bundle exec rake tmp:clear
bundle exec rake assets:clean RAILS_ENV=production
bundle exec rake assets:precompile RAILS_ENV=production
Thanks for reading. Any guidance would be much appreciated.
Probably you have solved your problem by now. However I believe trying these commands in the following order would work.
$bundle exec rake assets:precompile
$git add .
$git commit -m "msg"
$git push heroku master

Symfony2 Composer Install

I am trying to install Symfony 2.1.3 (latest). I am running composer and installs everything okay. The only error that I get is:
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache
handling the post-install-cmd event terminated with an exception
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command.
It's being installed under www folder. I am running nginx and followed the composer approach. I read on internet that apache should be run manually not as a service, however I am using nginx instead. Does apache still have any bearing on it? I'm using debian squeeze.
Edit: As per AdrienBrault's suggestion the error was because the timezone was not set in the php.ini. Only with --verbose I could see the warning. Thanks guys.
Apache is not related - PHP is called via command line.
Most likely is the permission in the cache folder: did you check if the user that runs the composer update can actually write the cache folder?
Try to manually run rm -Rf app/cache/dev (for production environment replace dev with prod) and see if you get any permission error.
Also you will get this error if the default.timezone setting is not configured in php when running in CLI. To verify just run
php --info | grep timezone
and check that the setting date.timezone is correctly configured.
On the security side, setting 777 to the folder is not the optimal solution - if you have ACL enabled you could use that to correctly set up the permission for the cache and logs folder. Read more at the Symfony2 official installation page
I had this same issue for a while and after hours of face to brick wall pounding I realized... I have a .gitmodule in my project, and on initial checkout these submodules are NOT initialized and as such are not there for your composer to update, which results in the above error.
Make sure you run the following
git submodule update --init src/Acme/Sadness/Bundle
of course replace src/Acme/Sadness/Bundle with YOUR project namespace.
Hope this helps someone not go through the same pain I just did.
If you have vendor folder already I would remove it and install symfony 2.1.3 again via "composer.phar install". Problem might be coming from outdated version of composer
I had the same problem and I resolve in this way.
execute this on the console
and you should see something like this
$ locate php.ini
/etc/php5/apache2/php.ini
/etc/php5/cli/php.ini
/etc/php5/fpm/php.ini
the first line is probably your php.ini that appear when you do a phpinfo();
the problem is that when you execute composer update this no check the same php.ini
in my case the second line
all my sites work fine but always I had problems not now
after edit the second file and put the same time zone that you set in the first one
run
$ sudo service apache2 reload
and now
$ composer update
I hope that this work for you like work for me
regards
Emiliano

Resources