5

I'm getting an error while precompiling on production server; however, if I set the environment as production and run the precompilation on the development computer, it runs ok. How can it be possible?

RAILS_ENV="production" bundle exec rake assets:precompile RAILS_GROUPS=assets

error returned:

   ...
   rake aborted!
   ExecJS::RuntimeError:
   (execjs):1
   ...

I have no clue whatsoever on where's the error coming from.

Jorge
  • 1,730
  • 20
  • 27
  • 1
    I understand what you say about depending on people updating gems, but have you considered using [Rails Assets](https://rails-assets.org/)? The gems are generated automatically, so technically you don't depend on any specific maintainer, and you get updates using Bundler as for all other gems. – taglia Apr 26 '16 at 08:15
  • @taglia Yes. You're right. It's a good approach. Thanks for the note man! – Jorge Apr 26 '16 at 14:27
  • @taglia I did convert my assets to rails-assets; however, the error was on falling short of RAM memory on the production server. – Jorge Apr 30 '16 at 03:32

3 Answers3

8

Simply: My production server was running out of RAM memory. I boosted it a little bit to 1GB and now it works like a charm!

Jorge
  • 1,730
  • 20
  • 27
  • Ditto. I was using cap to deploy a rails app, and found i had to kill the app before running deploy. Just run htop on the server and see how close you get to the maxing out RAM. – mostlydev Jun 14 '17 at 01:52
  • Unfortunately 512mb won't do even for a staging server! – fatfrog Sep 13 '17 at 18:45
4

I had the same problem and restarting the server it solve it.

EDIT

Also you can add swap. Here is a great tutorial https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04

Panos Angel
  • 136
  • 1
  • 5
3

I had the same problem.My server was ngnix. After restart using command

service nginx restart

solved the problem.

Avijit Majhi
  • 508
  • 9
  • 15