rake assets precompile failed - ruby-on-rails

When I run bundle exec rake assets:precompile --trace, my precompilation fails but I cannot see any specific reason for it.
See this pastebin for my output: http://pastebin.com/zggZyPyM

Precompiling assets takes a lot of memory. ~=400mb in my case. It might be possible that OS is killing of the process due to excessive memory usage. You can check the syslog to verify if that is the case.
You can increase the memory of your server to avoid the situation. If that is not possible, I would suggest that you precompile assets on your local system, commit them to the repo and deploy to the server. That way you wouldn't have to compile assets on your server. However you might want to look into ways to delete the previously generated assets somehow and also automate the process.

, but issue was resolvedI tried installing node.js first. And then, ran the following command bundle exec rake assets:precompile. Only then I didn't notice the error.
Initially, I thought it was because of low memory too. Cleaned almost all running applications, but couldn't find a solution. Plus, I opened Ruby as administrator. Not sure if that helped too, but issue was resolved.

This issue can also be resolved by using a node.js JS runtime to precompile assets as it apparently has a lower memory footprint. For Ubunutu 14.04 I needed to run apt-get install nodejs, then replace the default js runtime in the Gemfile with gem 'node', run bundleand finally rerun the precompile. I would caution against precompiling in another location as you may forget to do this after a css or js change, leading to errors.

Related

rails and metronic - assets precompile: SassC error, not enough space

I have developed a rails app, based on bootstrap. Now I'm using Metronic to improve the stylings but while I don't have any problem in development mode, trying to compile assets in production mode, I get this error:
rake aborted!
SassC::SyntaxError: Internal Error: Not enough space
/home/spanogi/.rbenv/versions/2.4.3/bin/bundle:23:in 'load'
/home/spanogi/.rbenv/versions/2.4.3/bin/bundle:23:in ''
Tasks: TOP => assets:precompile
the command I issue is
bundle exec rake assets:precompile RAILS_ENV=production
If I do not add Metronic assets to my application.scss and application.js precompilation regularly finishes.
The server resources seems to be abundant, I checked memory while compiling but it doesn't go over 30% of usage and in fact the error is generated internally by Sassc, not by the OS (it's not a memory crash). I looked for similar errors around but did not have any success.
Do you have ideas? Thank you so much for your help
I managed to get it work.
I discovered that in SassC package "Not enough space" means "No UTF-8 encoded file"... (at least in my case) so all I had to do has been to convert the file to UTF-8 coding. I used this command (LINUX):
iconv -f UTF-8 -t ascii//TRANSLIT filename -o output_file_name
then I had to clean the file from some "\0"s and everything worked.
Hope this could be useful to someone!
I just remove \0 from the css file and worked well

Webpacker binstubs not installing correctly

I have a perplexing issue here when trying to implement the Rails Webpacker gem into an existing application.
Unfortunately, I do not have much to offer in the way of debugging information, this is also an internal project, so I have limited options in terms of sharing the entire project source.
I am following the exact steps outlined here: https://github.com/rails/webpacker and have done it multiple times now, but during the bundle exec rails webpacker:install command (after running bundle), I see the message:
Skipped webpack and webpack-dev-server since they already exist.
If you want to overwrite skipped stubs, use --force.
This binstubs most-definitely do not exist in my bin/ directory. Either before or after the webpacker install.
I feel like I have tried everything at this point, and nothing seems to be working:
Reinstalling the gem (multiple versions, even via Git)
Manually creating the binstub from a different project (this "worked" until I tried to run the webpacker:install:react script).
Manually running Yarn, attempting to --force create the binstubs
Tried multiple different configuration tweaks in webpacker.yml
I am just out of ideas at this point. Anything else I should be checking, could try?
This is a fix that worked for me:
I copied these two files into the bin directory of my app and then bundle exec rails webpacker:check_binstubs stopped complaining.
As a side effect it made my app deployable on my Paas with the standard buildpack.

SASS: After every change have to reboot my server

Using: rails4 app
Command: For Connecting and Rebooting in order to see the change.
rake assets:precompile
and
control + c
rails s
Is it normal!! Because, sometime I have to do a lot of change and I don't want to reboot the rails server 2000 times per hour.
It's development machine.
Suggestions would be appreciated.
I'm not sure why you're precompiling while still making changes to your SASS.
During development, if making frequent changes to SASS, I'll have cleaned my assets out and the server will pick up and compile these changes as I make them.
rake assets:precompile
is only used when I push to production
There is some guidance here: http://guides.rubyonrails.org/asset_pipeline.html#local-precompilation on why you might want to precompile locally, but I can't speak for your own projects.
I had a lot of headaches when trying to edit js files and refresh them while my assets were precompiled and they all went away went I ditched it in dev.
I solve it with this command
rake assets:clobber
Thanks anyway.

Can I force Heroku to compile the assets?

I used to develop a project on my own and now I have got some others to help in the project. It's developed with Ruby on Rails and we have a staging server on Heroku. Beforehand the deployment workflow is to precompile the assets in local machine then push the code to heroku. It works well when I am on my own.
Now I am working with a Front-end engineer. The problem is we are working in different location so it is difficult to setup his computer the same as mine. As a result, he will not be able to precompile the code before pushing to heroku.
Of course I can do it for him but would be better if he can just submit the code to the staging server and let Heroku to precompile it. I think Heroku detect if the manifest file is available to determine if it needs to precompile. Is there a way to force Heroku to recompile the assets?
I have tried: heroku run rake assets:clean then heroku run rake assets:precompile but no luck...
Heroku's servers use a read-only file system. This is how they make it easy for you to spin up more dynos, among other things.
Compiling Rails assets means taking the source files and compiling a new file, i.e. writing a file to the file system. Since this can't happen on a read-only file system, you have to precompile first. Even if you did manage to compile assets on Heroku, by writing to the /tmp directory, at the end of the day when Heroku reboots dynos, your new files will be gone because they weren't checked into the repo as they would've been if you had precompiled them locally, committed them, and then pushed to Heroku.
Any workaround I can imagine would be more complicated than helping your front end dev setup Rails and bundle installing the gems needed to precompile before pushing.

Capistrano user-related problem

I'm deploying a rails application using Capistrano to a shared server (on WebFaction). This means there are several different Ruby version installed there.
Everything works fine until I want to run some rake tasks. These tasks fail by saying I don't have the right RubyGems version.
From this thread I understood that fixing it would be as easy as adding the full path to the correct rake folder to my rake commands. I tried that but failed again, now because the Ruby interpreter that is used is the wrong one.
I assumed that capistrano would use the username/password I gave it to run commands on the server but it seems not to be the case.
Am I missing something? How can I fix that?
Thanks!
This is indeed a path issue. I solved it by symlinking my ruby, rake, and rails executables to my path. For instance, if the executables that you want (but are failing to work) are located at /opt/ruby/bin/ruby, you'll symlink it to:
ln -s /opt/ruby/bin/ruby /usr/local/bin/ruby

Resources