What do I need to do to get this working?
I'm on Ubuntu 11.04 and had similar issues. Installing Node.js fixed it.
As of Ubuntu 13.04 x64 you only need to run:
sudo apt-get install nodejs
This will solve the problem.
sudo yum install nodejs
gem 'execjs' gem 'therubyracer'
Everything should be fine after.
In your Gem file, write
gem 'execjs' gem 'therubyracer'
and then run
Everything works fine for me :)
I had a similar problem: my Rails 3.1 app worked fine on Windows but got the same error as the OP when running on Linux. The fix that worked for me on both platforms was to add the following to my
gem 'therubyracer', :platforms => :ruby
The trick is knowing that
:platforms => :ruby actually means only use this gem with "C Ruby (MRI) or Rubinius, but NOT Windows."
Other possible values for
:platforms are described in the
bundler man page.
execjs can locate. On Linux there is not a builtin although there are several available that one can install.
therubyracer is one of them. Others are listed in the
Adding the following gem to my Gemfile solved the issue:
Then bundle your new dependencies:
$ bundle install
An alternative way is to just bundle without the gem group that contains the things you don't have.
bundle install --without assets
you don't have to modify the Gemfile at all, providing of course you are not doing asset chain stuff - which usually applies in non-development environments. Bundle will remember your '--without' setting in the .bundle/config file.
For amazon linux(AMI):
sudo yum install nodejs npm --enablerepo=epel
I had this same error but only on my staging server not my production environment. nodejs was already installed on both environments.
I found out that the node command was located in: /usr/bin/node on production but: /usr/local/bin/node in staging.
After creating a symlink on staging i.e. :
sudo ln -s /usr/local/bin/node /usr/bin/node
the application then worked in staging.
No muss no fuss.
Don't Use RubyRacer as it is bad on memory. Installing Node.js as suggested by some people here is a better idea.
This list of available runtimes that can be used by ExecJs Library also documents the use of Node.js
So, Node.js is not an overkill, and much better solution than using the RubyRacer.
FYI, this fixed the problem for me... it's a pathing problem: http://forums.freebsd.org/showthread.php?t=35539
I started getting this problem when I started using rbenv with Ruby 1.9.3 where as my system ruby is 1.8.7. The gem is installed in both places but for some reason the rails script didn't pick it up. But adding the "execjs" and "therubyracer" to the Gemfile did the trick.
In your gem file Uncomment this line.
19 # gem 'therubyracer', platforms: :ruby
And run bundle install
You are ready to work. :)
Attempting to debug in RubyMine using Ubuntu 18.04, Ruby 2.6.*, Rails 5, & RubyMine 2019.1.1, I ran into the same issue.
To resolve the issue, I uncommented the
mini_racer line from my
Gemfile and then ran
# See https://github.com/rails/execjs#readme for more supported runtimes # gem 'mini_racer', platforms: :ruby
# See https://github.com/rails/execjs#readme for more supported runtimes gem 'mini_racer', platforms: :ruby
Add following gems in your gem file
gem 'therubyracer' gem 'execjs'
you are done :)
node via nvm and encountered this issue when deploying with Capistrano. Capistrano didn't load nvm automatically because it runs non-interactively.
To fix, simply move the lines that nvm adds to your
~/.bashrc up to the top. The file will then look something like this:
export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion # If not running interactively, don't do anything case $- in *i*) ;; *) return;; esac
©2020 All rights reserved.