我已经在Linux(ubuntu 14.04)上成功安装了Ruby,rails和mysql2。
现在的问题是当我运行rails server时出现以下错误

/home/sharif/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/execjs-2.5.2/lib/execjs/runtimes.rb:48:in `autodetect': Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
    from /home/sharif/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/execjs-2.5.2/lib/execjs.rb:5:in `<module:ExecJS>'
    from /home/sharif/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/execjs-2.5.2/lib/execjs.rb:4:in `<top (required)>'
    from /home/sharif/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/uglifier-2.7.1/lib/uglifier.rb:3:in `require'
    from /home/sharif/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/uglifier-2.7.1/lib/uglifier.rb:3:in `<top (required)>'
    from /home/sharif/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.9.4/lib/bundler/runtime.rb:76:in `require'
    from /home/sharif/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.9.4/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    from /home/sharif/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.9.4/lib/bundler/runtime.rb:72:in `each'
    from /home/sharif/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.9.4/lib/bundler/runtime.rb:72:in `block in require'
    from /home/sharif/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.9.4/lib/bundler/runtime.rb:61:in `each'
    from /home/sharif/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.9.4/lib/bundler/runtime.rb:61:in `require'
    from /home/sharif/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.9.4/lib/bundler.rb:134:in `require'
    from /home/sharif/Sites/simple_cms/config/application.rb:7:in `<top (required)>'
    from /home/sharif/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:78:in `require'
    from /home/sharif/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:78:in `block in server'
    from /home/sharif/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:75:in `tap'
    from /home/sharif/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:75:in `server'
    from /home/sharif/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
    from /home/sharif/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands.rb:17:in `<top (required)>'
    from /home/sharif/Sites/simple_cms/bin/rails:8:in `require'
    from /home/sharif/Sites/simple_cms/bin/rails:8:in `<top (required)>'
    from /home/sharif/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/spring-1.3.4/lib/spring/client/rails.rb:28:in `load'
    from /home/sharif/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/spring-1.3.4/lib/spring/client/rails.rb:28:in `call'
    from /home/sharif/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/spring-1.3.4/lib/spring/client/command.rb:7:in `call'
    from /home/sharif/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/spring-1.3.4/lib/spring/client.rb:26:in `run'
    from /home/sharif/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/spring-1.3.4/bin/spring:48:in `<top (required)>'
    from /home/sharif/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/spring-1.3.4/lib/spring/binstub.rb:11:in `load'
    from /home/sharif/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/spring-1.3.4/lib/spring/binstub.rb:11:in `<top (required)>'
    from /home/sharif/.rbenv/versions/2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /home/sharif/.rbenv/versions/2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /home/sharif/Sites/simple_cms/bin/spring:13:in `<top (required)>'
    from bin/rails:3:in `load'
    from bin/rails:3:in `<main>'


不知道是什么问题,但runtimes.rb:48:in autodetect':找不到JavaScript运行时。`似乎是解决整个问题的问题,请帮助,我们将不胜感激。

安装nodejs后编辑

我收到以下错误

 Sorry, you can't use byebug without Readline. To solve this, you need to
    rebuild Ruby with Readline support. If using Ubuntu, try `sudo apt-get
    install libreadline-dev` and then reinstall your Ruby.
bin/rails:6: warning: already initialized constant APP_PATH
/home/sharif/Sites/simple_cms/bin/rails:6: warning: previous definition of APP_PATH was here
Usage: rails COMMAND [ARGS]

The most common rails commands are:
 generate    Generate new code (short-cut alias: "g")
 console     Start the Rails console (short-cut alias: "c")
 server      Start the Rails server (short-cut alias: "s")
 dbconsole   Start a console for the database specified in config/database.yml
             (short-cut alias: "db")
 new         Create a new Rails application. "rails new my_app" creates a
             new application called MyApp in "./my_app"

In addition to those, there are:
 destroy      Undo code generated with "generate" (short-cut alias: "d")
 plugin new   Generates skeleton for developing a Rails plugin
 runner       Run a piece of code in the application environment (short-cut alias: "r")

All commands can be run with -h (or --help) for more information.


我不是命令行专家,只是想学习Rails上的红宝石...请帮助

任何想法?

最佳答案

安装nodejs

sudo apt-get install nodejs

关于ruby-on-rails - linux webrick rails服务器无法启动-一些错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29817644/

10-16 20:30
查看更多