无法在ubuntu上运行rails服务器

时间:2014-09-01 08:03:06

标签: mysql ruby-on-rails ruby linux

我正在使用ruby on rails,

我使用

制作了一个项目

rails new proj -d mysql

然后输入

rails服务器

但是得到这个错误,问题是什么

/home/mani/.rvm/gems/ruby-2.1.2/gems/execjs-2.2.1/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/mani/.rvm/gems/ruby-2.1.2/gems/execjs-2.2.1/lib/execjs.rb:5:in `<module:ExecJS>'
        from /home/mani/.rvm/gems/ruby-2.1.2/gems/execjs-2.2.1/lib/execjs.rb:4:in `<top (required)>'
        from /home/mani/.rvm/gems/ruby-2.1.2/gems/uglifier-2.5.3/lib/uglifier.rb:3:in `require'
        from /home/mani/.rvm/gems/ruby-2.1.2/gems/uglifier-2.5.3/lib/uglifier.rb:3:in `<top (required)>'
        from /home/mani/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.7.2/lib/bundler/runtime.rb:76:in `require'
        from /home/mani/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.7.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
        from /home/mani/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.7.2/lib/bundler/runtime.rb:72:in `each'
        from /home/mani/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.7.2/lib/bundler/runtime.rb:72:in `block in require'
        from /home/mani/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.7.2/lib/bundler/runtime.rb:61:in `each'
        from /home/mani/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.7.2/lib/bundler/runtime.rb:61:in `require'
        from /home/mani/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.7.2/lib/bundler.rb:133:in `require'
        from /home/mani/Sites/proj/config/application.rb:7:in `<top (required)>'
        from /home/mani/.rvm/gems/ruby-2.1.2/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:79:in `require'
        from /home/mani/.rvm/gems/ruby-2.1.2/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:79:in `block in server'
        from /home/mani/.rvm/gems/ruby-2.1.2/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:76:in `tap'
        from /home/mani/.rvm/gems/ruby-2.1.2/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:76:in `server'
        from /home/mani/.rvm/gems/ruby-2.1.2/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
        from /home/mani/.rvm/gems/ruby-2.1.2/gems/railties-4.1.5/lib/rails/commands.rb:17:in `<top (required)>'
        from /home/mani/Sites/proj/bin/rails:8:in `require'
        from /home/mani/Sites/proj/bin/rails:8:in `<top (required)>'
        from /home/mani/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/client/rails.rb:27:in `load'
        from /home/mani/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/client/rails.rb:27:in `call'
        from /home/mani/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/client/command.rb:7:in `call'
        from /home/mani/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/client.rb:26:in `run'
        from /home/mani/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/bin/spring:48:in `<top (required)>'
        from /home/mani/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/binstub.rb:11:in `load'
        from /home/mani/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/binstub.rb:11:in `<top (required)>'
        from /home/mani/Sites/proj/bin/spring:16:in `require'
        from /home/mani/Sites/proj/bin/spring:16:in `<top (required)>'
        from bin/rails:3:in `load'
        from bin/rails:3:in `<main>'

3 个答案:

答案 0 :(得分:4)

Gemfile中添加以下宝石:

gem 'execjs'
gem 'therubyracer'

运行bundle install,现在尝试启动rails server rails s

答案 1 :(得分:0)

您可以在系统上执行此操作

  

sudo apt-get install nodejs

答案 2 :(得分:0)

sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison nodejs subversion

然后重新启动你的机器。