1

I am currently new to the Linux OS (Ubuntu). I was once learning to develop Rails application on Windows but I found out that it is better to develop Rails applications on Linux since there are some limitations on Windows. I dual booted my computer so I can have Linux and Windows at the same time.

So I installed Ruby and Rails using the RVM (I followed this setup: https://www.youtube.com/watch?v=hiPQynmnsiI) and I created a test project named web and placed it on my desktop. There were no errors prior to the creation of the project but when I ran the command rails s it returned the following:

    /home/arjay/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.6/lib/bundler    /runtime.rb:94:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'uglifier'. (Bundler::GemRequireError)
    Gem Load Error is: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.
    Backtrace for gem load error is:
    /home/arjay/.rvm/gems/ruby-2.3.0/gems/execjs-2.7.0/lib/execjs/runtimes.rb:58:in `autodetect'
    /home/arjay/.rvm/gems/ruby-2.3.0/gems/execjs-2.7.0/lib/execjs.rb:5:in `<module:ExecJS>'
    /home/arjay/.rvm/gems/ruby-2.3.0/gems/execjs-2.7.0/lib/execjs.rb:4:in `<top (required)>'
    /home/arjay/.rvm/gems/ruby-2.3.0/gems/uglifier-3.0.3/lib/uglifier.rb:5:in `require'
    /home/arjay/.rvm/gems/ruby-2.3.0/gems/uglifier-3.0.3/lib/uglifier.rb:5:in `<top (required)>'
    /home/arjay/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:91:in `require'
    /home/arjay/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:91:in `block (2 levels) in require'
    /home/arjay/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:86:in `each'
    /home/arjay/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:86:in `block in require'
    /home/arjay/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:75:in `each'
    /home/arjay/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:75:in `require'
    /home/arjay/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.6/lib/bundler.rb:106:in `require'
    /home/arjay/Desktop/web/config/application.rb:7:in `<top (required)>'
    /home/arjay/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:88:in `require'
    /home/arjay/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:88:in `block in server'
    /home/arjay/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:85:in `tap'
    /home/arjay/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:85:in `server'
    /home/arjay/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
    /home/arjay/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in `<top (required)>'
    /home/arjay/Desktop/web/bin/rails:9:in `require'
    /home/arjay/Desktop/web/bin/rails:9:in `<top (required)>'
    /home/arjay/.rvm/gems/ruby-2.3.0/gems/spring-2.0.0/lib/spring/client/rails.rb:28:in `load'
    /home/arjay/.rvm/gems/ruby-2.3.0/gems/spring-2.0.0/lib/spring/client/rails.rb:28:in `call'
    /home/arjay/.rvm/gems/ruby-2.3.0/gems/spring-2.0.0/lib/spring/client/command.rb:7:in `call'
    /home/arjay/.rvm/gems/ruby-2.3.0/gems/spring-2.0.0/lib/spring/client.rb:30:in `run'
    /home/arjay/.rvm/gems/ruby-2.3.0/gems/spring-2.0.0/bin/spring:49:in `<top (required)>'
    /home/arjay/.rvm/gems/ruby-2.3.0/gems/spring-2.0.0/lib/spring/binstub.rb:31:in `load'
    /home/arjay/.rvm/gems/ruby-2.3.0/gems/spring-2.0.0/lib/spring/binstub.rb:31:in `<top (required)>'
    /home/arjay/Desktop/web/bin/spring:14:in `require'
    /home/arjay/Desktop/web/bin/spring:14:in `<top (required)>'
    bin/rails:3:in `load'
    bin/rails:3:in `<main>'
    Bundler Error Backtrace:
      from /home/arjay/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:90:in `block (2 levels) in require'
      from /home/arjay/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:86:in `each'
      from /home/arjay/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:86:in `block in require'
      from /home/arjay/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:75:in `each'
      from /home/arjay/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:75:in `require'
      from /home/arjay/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.6/lib/bundler.rb:106:in `require'
      from /home/arjay/Desktop/web/config/application.rb:7:in `<top (required)>'
      from /home/arjay/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:88:in `require'
      from /home/arjay/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:88:in `block in server'
      from /home/arjay/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:85:in `tap'
      from /home/arjay/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:85:in `server'
      from /home/arjay/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
      from /home/arjay/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in `<top (required)>'
      from /home/arjay/Desktop/web/bin/rails:9:in `require'
      from /home/arjay/Desktop/web/bin/rails:9:in `<top (required)>'
      from /home/arjay/.rvm/gems/ruby-2.3.0/gems/spring-2.0.0/lib/spring/client/rails.rb:28:in `load'
      from /home/arjay/.rvm/gems/ruby-2.3.0/gems/spring-2.0.0/lib/spring/client/rails.rb:28:in `call'
      from /home/arjay/.rvm/gems/ruby-2.3.0/gems/spring-2.0.0/lib/spring/client/command.rb:7:in `call'
      from /home/arjay/.rvm/gems/ruby-2.3.0/gems/spring-2.0.0/lib/spring/client.rb:30:in `run'
      from /home/arjay/.rvm/gems/ruby-2.3.0/gems/spring-2.0.0/bin/spring:49:in `<top (required)>'
      from /home/arjay/.rvm/gems/ruby-2.3.0/gems/spring-2.0.0/lib/spring/binstub.rb:31:in `load'
      from /home/arjay/.rvm/gems/ruby-2.3.0/gems/spring-2.0.0/lib/spring/binstub.rb:31:in `<top (required)>'
      from /home/arjay/Desktop/web/bin/spring:14:in `require'
      from /home/arjay/Desktop/web/bin/spring:14:in `<top (required)>'
      from bin/rails:3:in `load'
      from bin/rails:3:in `<main>'

Thank you for anyone who can help me out!

Paradigm
  • 159
  • 1
  • 3
  • 11
  • 1
    Maybe this could help? http://stackoverflow.com/questions/34420554/there-was-an-error-while-trying-to-load-the-gem-uglifier-bundlergemrequire – Pierre Nov 01 '16 at 11:33
  • That got it working! Thanks man. Currently getting overwhelmed by Linux. – Paradigm Nov 01 '16 at 11:38

2 Answers2

3

Could not find a JavaScript runtime.

You need javascript runtime.

Solution 1: Run the following command install nodejs

sudo apt-get install nodejs

Solution 2: Add therubyracer gem in your Gemfile

gem 'therubyracer'

This will solve the issue

Deepak Mahakale
  • 22,834
  • 10
  • 68
  • 88
1

You should run

sudo apt-get install nodejs

For Reference follow url click here

Community
  • 1
  • 1
anil
  • 159
  • 3
  • 11