1

I am following a video tutorial for installing rails and after installing rails, gems, and mysql, the video walks through rake db:create as a test to ensure mysql is working correctly.

c:\row\dev\Hello_World>rake db:create
DL is deprecated, please use Fiddle
rake aborted!
Bundler::GemRequireError: There was an error while trying to load the gem 'uglifier'.
c:/row/dev/Hello_World/config/application.rb:7:in `<top (required)>'
c:/row/dev/Hello_World/Rakefile:4:in `<top (required)>'
ExecJS::RuntimeUnavailable: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.
c:/row/dev/Hello_World/config/application.rb:7:in `<top (required)>'
c:/row/dev/Hello_World/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)

I'm a bit lost. Any help would be appreciated.

since it came up a couple of times in the comments, gem install therubyracer gave this:

ERROR:  Error installing therubyracer:
        ERROR: Failed to build gem native extension.

    c:/row/Ruby21/bin/ruby.exe extconf.rb
creating Makefile
which: no python in (.;c:\row\Ruby21\devkit\bin;c:\row\Ruby21\devkit\mingw\bin;c:\windows;C:\Program Files\MySQL\MySQL Server 5.7\bin;c:\row\Ruby21\bin)
The system cannot find the path specified.
which: no python in (.;c:\row\Ruby21\devkit\bin;c:\row\Ruby21\devkit\mingw\bin;c:\windows;C:\Program Files\MySQL\MySQL Server 5.7\bin;c:\row\Ruby21\bin)
c:/row/Ruby21/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.13/ext/libv8/builder.rb:81:in `setup_python!': libv8 requires python 2 to be installed in order to build, but it is currently not available (RuntimeError)
        from c:/row/Ruby21/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.13/ext/libv8/builder.rb:55:in `block in build_libv8!'
        from c:/row/Ruby21/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.13/ext/libv8/builder.rb:52:in `chdir'
        from c:/row/Ruby21/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.13/ext/libv8/builder.rb:52:in `build_libv8!'
        from c:/row/Ruby21/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.13/ext/libv8/location.rb:24:in `install!'
        from extconf.rb:7:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in c:/row/Ruby21/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.13 for inspection.
Results logged to c:/row/Ruby21/lib/ruby/gems/2.1.0/extensions/x86-mingw32/2.1.0/libv8-3.16.14.13/gem_make.out
Mike
  • 43
  • 2
  • 11

4 Answers4

1

Try to install therubyracer gem

Alexandr T
  • 1,471
  • 12
  • 24
  • gem install therubyracer gave me and error that it couldn't find the path specified and it could not find python. – Mike Dec 24 '15 at 13:29
  • add `gem 'therubyracer', :platforms => :ruby` in your Gemfile and run `bundle install` – Alexandr T Dec 24 '15 at 13:50
  • Ok, added that to the gemfile, saved, then ran bundle install. therubyracer does not show up on the list of gems used and it doesn't say it was installed. – Mike Dec 24 '15 at 13:59
  • I didn't pay attention that you use Windows. This answer may be useful http://stackoverflow.com/a/6359265/1998300 – Alexandr T Dec 24 '15 at 14:21
  • Looks like I don't need therubyracer gem, but its still not clear why I have an error loading uglifier on the rake db:create command. – Mike Dec 24 '15 at 14:27
  • `Uglifier` is required JS runtime. `Therubyracer` is a js interpreter into ruby, but "there is no way that I know of to currently install this gem on windows" (from the link above). And as says in the same link, on Windows you can try https://github.com/sstephenson/execjs gem instead therubyracer. – Alexandr T Dec 24 '15 at 14:50
  • I am with you. I removed therubyracer from my gemfile and uninstalled it. I added execjs and ran bundle install. But I still see the same "error while trying to load uglifier" message. – Mike Dec 24 '15 at 14:55
0

Try fix it:

/usr/local/lib/ruby/gems/ruby_ver/gems/execjs-ver/lib/execjs/runtimes.rb

Node = ExternalRuntime.new(
      :name        => "Node.js (V8)",
      :command     => ["nodejs", "/usr/local/bin/node"],
      :runner_path => ExecJS.root + "/support/node_runner.js",
      :encoding    => 'UTF-8'
    )
Artur Olenberg
  • 508
  • 1
  • 5
  • 16
0

As case, You could install node.js into system.

In my AmazonWS AMI EC2 this fix it.

0

Paste it into terminal

gem install therubyracer

INSERT INTO YOUR Gemfile

  gem 'uglifier', '~> 2.7', '>= 2.7.2'

run

bundle install
vipin
  • 2,374
  • 1
  • 19
  • 36