2012-03-09 15 views
10

Ho problemi a impostare ruby ​​su rail sulla mia macchina. Ho seguito il libro "Agile Web Development with Rails" e fino ad ora tutto andava bene.ho bisogno di aiuto per impostare ruby ​​on rails ambiente di runtime javascript

Il problema che sto avendo è che quando si digita

rails server 

ottengo il seguente errore:

/home/myname/.gem/ruby/1.9.1/gems/execjs-1.3.0/lib/execjs/runtimes.rb:50:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable) 
from /home/myname/.gem/ruby/1.9.1/gems/execjs-1.3.0/lib/execjs.rb:5:in `<module:ExecJS>' 
from /home/myname/.gem/ruby/1.9.1/gems/execjs-1.3.0/lib/execjs.rb:4:in `<top (required)>' 
from /usr/lib/ruby/gems/1.9.1/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `require' 
from /usr/lib/ruby/gems/1.9.1/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `<top (required)>' 
from /usr/lib/ruby/gems/1.9.1/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `require' 
from /usr/lib/ruby/gems/1.9.1/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `<top (required)>' 
from /usr/lib/ruby/gems/1.9.1/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1:in `require' 
from /usr/lib/ruby/gems/1.9.1/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1:in `<top (required)>' 
from /home/myname/.gem/ruby/1.9.1/gems/bundler-1.1.0/lib/bundler/runtime.rb:68:in `require' 
from /home/myname/.gem/ruby/1.9.1/gems/bundler-1.1.0/lib/bundler/runtime.rb:68:in `block (2 levels) in require' 
from /home/myname/.gem/ruby/1.9.1/gems/bundler-1.1.0/lib/bundler/runtime.rb:66:in `each' 
from /home/myname/.gem/ruby/1.9.1/gems/bundler-1.1.0/lib/bundler/runtime.rb:66:in `block in require' 
from /home/myname/.gem/ruby/1.9.1/gems/bundler-1.1.0/lib/bundler/runtime.rb:55:in `each' 
from /home/myname/.gem/ruby/1.9.1/gems/bundler-1.1.0/lib/bundler/runtime.rb:55:in `require' 
from /home/myname/.gem/ruby/1.9.1/gems/bundler-1.1.0/lib/bundler.rb:118:in `require' 
from /home/myname/Programming/Learning/Learning_Rails/demo/config/application.rb:7:in `<top (required)>' 
from /home/myname/.gem/ruby/1.9.1/gems/railties-3.2.2/lib/rails/commands.rb:53:in `require' 
from /home/myname/.gem/ruby/1.9.1/gems/railties-3.2.2/lib/rails/commands.rb:53:in `block in <top (required)>' 
from /home/myname/.gem/ruby/1.9.1/gems/railties-3.2.2/lib/rails/commands.rb:50:in `tap' 
from /home/myname/.gem/ruby/1.9.1/gems/railties-3.2.2/lib/rails/commands.rb:50:in `<top (required)>' 
from script/rails:6:in `require' 
from script/rails:6:in `<main>' 

Sta dicendo che non riesce a trovare un ambiente di runtime JavaScript. Sono andato al sito Web che il messaggio di errore consigliato e ho fatto un po 'googling e ho letto che execjs sarebbe una buona scelta per l'installazione. Ho installato execjs con i seguenti comandi:

sudo gem install execjs 
sudo gem update 

Quando eseguo 'elenco gioiello' ottengo il seguente output:

*** LOCAL GEMS *** 

actionmailer (3.2.2) 
actionpack (3.2.2) 
activemodel (3.2.2) 
activerecord (3.2.2) 
activeresource (3.2.2) 
activesupport (3.2.2) 
arel (3.0.2) 
bigdecimal (1.1.0) 
builder (3.0.0) 
bundler (1.1.0) 
coffee-rails (3.2.2) 
coffee-script (2.2.0) 
coffee-script-source (1.2.0) 
erubis (2.7.0) 
execjs (1.3.0 ruby) 
hike (1.2.1) 
i18n (0.6.0) 
io-console (0.3) 
journey (1.0.3) 
jquery-rails (2.0.1) 
json (1.6.5, 1.5.4) 
mail (2.4.3) 
mime-types (1.17.2) 
minitest (2.11.3, 2.5.1) 
multi_json (1.1.0) 
polyglot (0.3.3) 
rack (1.4.1) 
rack-cache (1.2) 
rack-ssl (1.3.2) 
rack-test (0.6.1) 
rails (3.2.2) 
railties (3.2.2) 
rake (0.9.2.2) 
rdoc (3.12, 3.9.4) 
sass (3.1.15) 
sass-rails (3.2.4) 
sprockets (2.3.1, 2.1.2) 
sqlite3 (1.3.5) 
thor (0.14.6) 
tilt (1.3.3) 
treetop (1.4.10) 
tzinfo (0.3.32) 
uglifier (1.2.3) 

Dall'output sopra sembra a me come è installato execjs. Cosa sta succedendo qui e perché sto ricevendo questo errore?

Se è utile a tutti,

Il mio sistema operativo è Arch Linux.

ruby ​​-v: ruby ​​1.9.3p125 (2012-02-16 revisione 34643) [x86_64-linux]

rotaie -v: Rails 3.2.2

Qualsiasi aiuto sarebbe apprezzato.

risposta

11

tuo Gemfile deve contenere entrambe le seguenti linee:

gem 'execjs' 
gem 'therubyracer' 

Poi gestita bundle install e riprovare.

+0

Grazie, questo era il problema.Tutto funziona ora. – martega

1

Penso che avete bisogno di un tempo di esecuzione come rubyracer. Prova

sudo gem install therubyracer 
+0

ho provato e questo è stato il risultato: '$ bundle install execjs "install" è stato chiamato in modo non corretto. Chiama come "pacchetto installazione" .' – martega

+0

Modificato per specificare un runtime js. – Sebi

+0

Purtroppo, l'ho già provato. Stesso problema :( – martega

5

Se si aggiungerà therubyracer gemma, potrebbe essere il vostro problema woould essere risolto

Codice

gem 'therubyracer' 
gem 'execjs' 

poi basta fare un bundle install

+0

Ho provato a correre il comando gemma 'therubyracer' ma ho ricevuto un errore dicendo che therubyracer è un comando sconosciuto. La stessa cosa succede se eseguo gem 'execjs'. Ti ho frainteso? – martega

+0

Grazie! Sembra che funzioni adesso. – martega

3

Prova questa:

$ sudo apt-get install nodejs 
1

Se stai usando Pacman Packet Manager che dovresti usare:

# pacman -S nodejs 

o

$ sudo pacman -S nodejs 
0

che avevo installato Node.js prima di Rails. Ora sta usando Node.js come runtime javascript da solo.

JavaScript Runtime Node.js (V8) 
Problemi correlati