Reputation: 307
Hello I am working with ruby on rails on a windows 8 machine and I am having a hard time setting up ruby 2.1 on my machine. when I run rails s I get the following error:
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/execjs-2.2.0/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/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/execjs-2.2.0/l
ib/execjs.rb:5:in `<module:ExecJS>'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/execjs-2.2.0/l
ib/execjs.rb:4:in `<top (required)>'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/uglifier-2.5.1
/lib/uglifier.rb:3:in `require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/uglifier-2.5.1
/lib/uglifier.rb:3:in `<top (required)>'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.6.3/
lib/bundler/runtime.rb:76:in `require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.6.3/
lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.6.3/
lib/bundler/runtime.rb:72:in `each'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.6.3/
lib/bundler/runtime.rb:72:in `block in require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.6.3/
lib/bundler/runtime.rb:61:in `each'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.6.3/
lib/bundler/runtime.rb:61:in `require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.6.3/
lib/bundler.rb:132:in `require'
from C:/HandCo-op/HandCo-op/config/application.rb:7:in `<top (required)>
'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.2
.rc1/lib/rails/commands/commands_tasks.rb:79:in `require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.2
.rc1/lib/rails/commands/commands_tasks.rb:79:in `block in server'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.2
.rc1/lib/rails/commands/commands_tasks.rb:76:in `tap'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.2
.rc1/lib/rails/commands/commands_tasks.rb:76:in `server'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.2
.rc1/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.2
.rc1/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
I think this is because I need ruby 2.1 and the version installed is 2.0. Does anyone know what I should do to fix these errors? Thanks a lot anyone who has an idea on why I can not run rails s.
Upvotes: 0
Views: 157
Reputation: 38645
It's funny, I had just initialized a new rails 4 project with ruby 2.1 and when forgetting to update the Gemfile
I got the exact error message a few minutes ago.
Update your Gemfile
uncommenting the gem 'therubyracer'
line, so it looks like:
# Gemfile
gem 'therubyracer', platforms: :ruby
Run the bundle
command after updating the Gemfile
.
The error message is because you don't have a runtime installed.
Update: Options on Windows
I've had success installing and using closure-compiler
gem on Windows 7+ x64 arch. My development box switches from linux to windows from time to time so following is how I have my Gemfile
setup:
# Gemfile
gem 'therubyracer', :platforms => :ruby
gem 'execjs', :platforms => :ruby
gem 'closure-compiler'
And update your configuration for either of your environments in config/environments/
or app wide in config/application.rb
by updating the following line:
config.assets.js_compressor = :closure
Please see Customizing the Pipeline for further information at RailsGuide.
Upvotes: 2