I'm trying to run rails generate rspec:install but I get this error. I'm using ruby 2.0.0p353 and Rails 4.0.3.
The error is:
/home/adminuser/.rvm/gems/ruby-2.0.0-p353/gems/execjs-2.0.2/lib/execjs/runtimes.rb:51:in autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
from /home/adminuser/.rvm/gems/ruby-2.0.0-p353/gems/execjs-2.0.2/lib/execjs.rb:5:in'
from /home/adminuser/.rvm/gems/ruby-2.0.0-p353/gems/execjs-2.0.2/lib/execjs.rb:4:in <top (required)>'
from /home/adminuser/.rvm/gems/ruby-2.0.0-p353/gems/uglifier-2.4.0/lib/uglifier.rb:3:inrequire'
from /home/adminuser/.rvm/gems/ruby-2.0.0-p353/gems/uglifier-2.4.0/lib/uglifier.rb:3:in <top (required)>'
from /home/adminuser/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:inrequire'
from /home/adminuser/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in block (2 levels) in require'
from /home/adminuser/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:ineach'
from /home/adminuser/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in block in require'
from /home/adminuser/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:ineach'
from /home/adminuser/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in require'
from /home/adminuser/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.3.5/lib/bundler.rb:132:inrequire'
from /home/adminuser/Desktop/667-workspace/assignment_3/config/application.rb:12:in <top (required)>'
from /home/adminuser/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.3/lib/rails/commands.rb:43:inrequire'
from /home/adminuser/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.3/lib/rails/commands.rb:43:in <top (required)>'
from bin/rails:4:inrequire'
from bin/rails:4:in `'
Just as the error suggest, you need a runtime(interpreter) for JavaScript on your local machine (no, those in browser wont do).
You can achieve this by installing gems such as therubyracer or run command like 'sudo apt-get install nodejs' just for their dependency
You need to install either therubyracer or nodejs in order to run rails generators. I prefer nodejs, cause it can be used in other cases such as bower or npm
Just add the runtimes in your project
# Gemfile
gem 'therubyracer'
Related
/usr/local/lib/ruby/2.3.0/irb/completion.rb:10:in require': cannot load such file -- readline (LoadError)
from /usr/local/lib/ruby/2.3.0/irb/completion.rb:10:in'
from /usr/local/bundle/gems/railties-4.2.6/lib/rails/commands/console.rb:3:in require'
from /usr/local/bundle/gems/railties-4.2.6/lib/rails/commands/console.rb:3:in'
from /usr/local/bundle/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:123:in require'
from /usr/local/bundle/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:123:inrequire_command!'
from /usr/local/bundle/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:58:in console'
from /usr/local/bundle/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:39:inrun_command!'
from /usr/local/bundle/gems/railties-4.2.6/lib/rails/commands.rb:17:in <top (required)>'
from bin/rails:4:inrequire'
from bin/rails:4:in `'
Try adding gem 'rb-readline' to your project. It appears you don't have the capability to handle console interaction, and that gem should provide it for you.
Check your gem file.
install relevant rvm
use command - rvm use 'Your_version'
Why am i getting this error?
shibly#mybox:~/blog$ rails server
/home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler/runtime.rb:80:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'uglifier'. (Bundler::GemRequireError)
from /home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `each'
from /home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `block in require'
from /home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `each'
from /home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `require'
from /home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler.rb:99:in `require'
from /home/shibly/blog/config/application.rb:7:in `<top (required)>'
from /home/shibly/.gem/ruby/2.2.4/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:78:in `require'
from /home/shibly/.gem/ruby/2.2.4/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:78:in `block in server'
from /home/shibly/.gem/ruby/2.2.4/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in `tap'
from /home/shibly/.gem/ruby/2.2.4/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in `server'
from /home/shibly/.gem/ruby/2.2.4/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /home/shibly/.gem/ruby/2.2.4/gems/railties-4.2.5/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:9:in `require'
from bin/rails:9:in `<main>
You should run following command to install NodeJS in Ubuntu
sudo apt-get install nodejs
or run this for OSX
brew install nodejs
Uglifier is a JS wrapper and it needs a JS runtime running or JS interpreter. I would choose to install NodeJS.
In the default Rails Gemfile, the line for the gem 'therubyracer' is commented out. If you uncomment it, you'll get that gem and it should work.
From "Getting Started with Rails":
Compiling CoffeeScript and JavaScript asset compression requires you have a JavaScript runtime available on your system, in the absence of a runtime you will see an execjs error during asset compilation. Usually Mac OS X and Windows come with a JavaScript runtime installed. Rails adds the therubyracer gem to the generated Gemfile in a commented line for new apps and you can uncomment if you need it. therubyrhino is the recommended runtime for JRuby users and is added by default to the Gemfile in apps generated under JRuby. You can investigate all the supported runtimes at ExecJS.
There was an error with creating the db.
The problem is that the Node.js tried to install without sudo in the script:
sudo apt-get install nodejs
Why am i getting this error?
shibly#mybox:~/blog$ rails server
/home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler/runtime.rb:80:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'uglifier'. (Bundler::GemRequireError)
from /home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `each'
from /home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `block in require'
from /home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `each'
from /home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `require'
from /home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler.rb:99:in `require'
from /home/shibly/blog/config/application.rb:7:in `<top (required)>'
from /home/shibly/.gem/ruby/2.2.4/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:78:in `require'
from /home/shibly/.gem/ruby/2.2.4/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:78:in `block in server'
from /home/shibly/.gem/ruby/2.2.4/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in `tap'
from /home/shibly/.gem/ruby/2.2.4/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in `server'
from /home/shibly/.gem/ruby/2.2.4/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /home/shibly/.gem/ruby/2.2.4/gems/railties-4.2.5/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:9:in `require'
from bin/rails:9:in `<main>
You should run following command to install NodeJS in Ubuntu
sudo apt-get install nodejs
or run this for OSX
brew install nodejs
Uglifier is a JS wrapper and it needs a JS runtime running or JS interpreter. I would choose to install NodeJS.
In the default Rails Gemfile, the line for the gem 'therubyracer' is commented out. If you uncomment it, you'll get that gem and it should work.
From "Getting Started with Rails":
Compiling CoffeeScript and JavaScript asset compression requires you have a JavaScript runtime available on your system, in the absence of a runtime you will see an execjs error during asset compilation. Usually Mac OS X and Windows come with a JavaScript runtime installed. Rails adds the therubyracer gem to the generated Gemfile in a commented line for new apps and you can uncomment if you need it. therubyrhino is the recommended runtime for JRuby users and is added by default to the Gemfile in apps generated under JRuby. You can investigate all the supported runtimes at ExecJS.
There was an error with creating the db.
The problem is that the Node.js tried to install without sudo in the script:
sudo apt-get install nodejs
It's Rails 3.1.0
What I did:
rails new site
cd site
rails s
The message I got:
/home/user1/.rvm/gems/ruby-1.9.2-p180/gems/execjs-1.2.9/lib/execjs/runtimes.rb:47:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/execjs-1.2.9/lib/execjs.rb:5:in `<module:ExecJS>'
from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/execjs-1.2.9/lib/execjs.rb:4:in `<top (required)>'
from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `require'
from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `<top (required)>'
from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `require'
from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `<top (required)>'
from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/coffee-rails-3.1.1/lib/coffee-rails.rb:1:in `require'
from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/coffee-rails-3.1.1/lib/coffee-rails.rb:1:in `<top (required)>'
from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require'
from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `each'
from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `block in require'
from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `each'
from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `require'
from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.21/lib/bundler.rb:122:in `require'
from /home/user1/social/config/application.rb:7:in `<top (required)>'
from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0/lib/rails/commands.rb:52:in `require'
from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0/lib/rails/commands.rb:52:in `block in <top (required)>'
from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0/lib/rails/commands.rb:49:in `tap'
from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0/lib/rails/commands.rb:49:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Why did I get this error?
Can anyone give hint to fix it?
You may also need to install node.js (helped for me)
As the error mentions, you do not have a Javascript runtime installed. You should pick one yourself.
Add this to your Gemfile:
gem "therubyracer"
Then run bundle install and try again.
$sudo apt-get install nodejs
worked for me...
Just Open the file 'Gemfile' inside the root directory of your application folder, and then paste the below lines there.
gem 'execjs'
gem 'libv8'
gem 'therubyracer'
After pasting it, just save the file and execute 'bundle update' on the command prompt.
On finishing bundle update successfully, you try running 'rails s'. It works!!
Thank you.
By seeing your question, your system complains about the lack of JavaScript runtime.
you should visit https://github.com/sstephenson/execjs for a list of possibilities.
I would suggest you to download node.js from this http://nodejs.org/.
follow this way:
cd *your download dir*
tar xvf node-v0.4.11.tar.gz
cd node-v0.4.11
./configure
make
sudo make install
I am giving this answer because this works for me.
This answer will helpful to you.
I have tried various installation methods for deploying a WEBrick and mongrel from the terminal. When I enter the rails server command I get the following:
Toran1$ rails server
/Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/mysql2-0.3.2/lib/mysql2.rb:8:in `require': dlopen(/Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
Referenced from: /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle
Reason: image not found - /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle
from /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/mysql2-0.3.2/lib/mysql2.rb:8:in `<top (required)>'
from /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/bundler-1.0.13/lib/bundler/runtime.rb:68:in `require'
from /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/bundler-1.0.13/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/bundler-1.0.13/lib/bundler/runtime.rb:66:in `each'
from /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/bundler-1.0.13/lib/bundler/runtime.rb:66:in `block in require'
from /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/bundler-1.0.13/lib/bundler/runtime.rb:55:in `each'
from /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/bundler-1.0.13/lib/bundler/runtime.rb:55:in `require'
from /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/bundler-1.0.13/lib/bundler.rb:120:in `require'
from /Users/Toran1/Sites/simple_cms/config/application.rb:7:in `<top (required)>'
from /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/railties-3.0.7/lib/rails/commands.rb:28:in `require'
from /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/railties-3.0.7/lib/rails/commands.rb:28:in `block in <top (required)>'
from /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/railties-3.0.7/lib/rails/commands.rb:27:in `tap'
from /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/railties-3.0.7/lib/rails/commands.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I have installed the gem both locally and at the root level, and I also have navigated to the application folder before issuing the command. Any help would be appreciated!
Webrick will install automatically if you install rails in a correct manner.
Try this link
Here
And if you don't want to install rails again, try to install server using gem command
Dont forget to include the gems in Gemfile and to run "bundle install"
If you are using Rails < 3.1 you need to use version ~> 0.2.7 of the mysql2 gem
Checkout the documentation and search for active record: https://github.com/brianmario/mysql2
I'm not sure if that will help solve this problem directly, but it may solve others that you may encounter.
Just update your bundler, maybe of any-one of the older gem is conflicting with latest one, this type of issues arises.
gem install bundler
and then bundler install
If you find again error, then delete GEM.lock file, then run
bundler install
This may resolve the issue.