Reputation: 75
I'm a beginner in Ruby and I have had some trouble starting
I created a demo project:
C:\Sites>rails new demo
create
create README.rdoc
create Rakefile
create config.ru
create .gitignore
create Gemfile
create app
create app/assets/javascripts/application.js
...
create vendor/assets/stylesheets/.keep
run bundle install
Fetching gem metadata from https://rubygems.org/..........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Using mail (2.5.4)
Installing actionmailer (4.0.2)
...
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed
Next, selected the folder:
C:\Sites>cd demo
I maked rake... and plop!
C:\Sites\demo>rake about
rake aborted!
Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.
C:/Sites/demo/config/application.rb:7:in `<top (required)>'
C:/Sites/demo/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
I tried run the server... but not works
C:\Sites\gui>rails server
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/execjs-2.0.2/lib/execjs/run
times.rb:51:in `autodetect': Could not find a JavaScript runtime. See https://gi
thub.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUn
available)
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/execjs-2.0.2/l
ib/execjs.rb:5:in `<module:ExecJS>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/execjs-2.0.2/l
ib/execjs.rb:4:in `<top (required)>'
Help me, pls.
Upvotes: 3
Views: 6073
Reputation: 5412
You need a javascript runtime.
Install node.js from here http://nodejs.org/. Make sure that the executable added to PATH.
Upvotes: 0
Reputation: 10754
The reason is pretty self explanatory and says that a JS runtime was not available. You can explicitly add that dependency by adding rubyracer
gem to your rails application, and that should include the JS runtime, for you.
So, add gem 'therubyracer'
to your Gemfile
, and then, run bundle
command, again. Then, you can run your rake
or rails
commands, as desired :)
If that does not solve your problem, install node.js
on your system, and that should solve your problem, for sure. You can use:
sudo apt-get install nodejs # on ubuntu
brew install node # on mac-osx, if you have `homebrew` installed.
Upvotes: 17