【问题标题】:Unable to run localhost:3000 (Ubuntu 12.10)无法运行 localhost:3000 (Ubuntu 12.10)
【发布时间】:2013-03-31 07:01:16
【问题描述】:

我找到了一些与我相关的帖子...但现有的答案都不起作用...所以这是来自 Newbee 的新帖子:

我刚刚安装了 Ubuntu 12.10 并尝试按照各种教程 (http://rubyonrails.org/download) 在 Rails 上安装 Ruby,我什至尝试了 RVM...所以最后当我尝试启动我的服务器时,我的 localhost:3000 无法正常工作。

这是我启动服务器时的终端:

laslo@ubuntu:~$ rails s
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': iconv will be deprecated in the future, use String#encode instead.
/usr/lib/ruby/vendor_ruby/railties/lib/rails_generator/generators/applications/app/app_generator.rb:7: Use RbConfig instead of obsolete and deprecated Config.
      exists  
      exists  app/controllers
      exists  app/helpers
      exists  app/models
      exists  app/views/layouts
      exists  config/environments
      exists  config/initializers
      exists  config/locales
      exists  db
      exists  doc
      exists  lib
      exists  lib/tasks
      exists  log
      exists  public/images
      exists  public/javascripts
      exists  public/stylesheets
      exists  script/performance
      exists  test/fixtures
      exists  test/functional
      exists  test/integration
      exists  test/performance
      exists  test/unit
      exists  vendor
      exists  vendor/plugins
      exists  tmp/sessions
      exists  tmp/sockets
      exists  tmp/cache
      exists  tmp/pids
   identical  Rakefile
   identical  README
   identical  app/controllers/application_controller.rb
   identical  app/helpers/application_helper.rb
   identical  config/database.yml
   identical  config/routes.rb
   identical  config/locales/en.yml
   identical  db/seeds.rb
   identical  config/initializers/backtrace_silencers.rb
   identical  config/initializers/inflections.rb
   identical  config/initializers/mime_types.rb
   identical  config/initializers/new_rails_defaults.rb
overwrite config/initializers/session_store.rb? (enter "h" for help) [Ynaqdh] y
       force  config/initializers/session_store.rb
overwrite config/initializers/cookie_verification_secret.rb? (enter "h" for help) [Ynaqdh] y
       force  config/initializers/cookie_verification_secret.rb
   identical  config/environment.rb
   identical  config/boot.rb
   identical  config/environments/production.rb
   identical  config/environments/development.rb
   identical  config/environments/test.rb
   identical  script/about
   identical  script/console
   identical  script/dbconsole
   identical  script/destroy
   identical  script/generate
   identical  script/runner
   identical  script/server
   identical  script/plugin
   identical  script/performance/benchmarker
   identical  script/performance/profiler
   identical  test/test_helper.rb
   identical  test/performance/browsing_test.rb
   identical  public/404.html
   identical  public/422.html
   identical  public/500.html
   identical  public/index.html
   identical  public/favicon.ico
   identical  public/robots.txt
   identical  public/images/rails.png
   identical  public/javascripts/prototype.js
   identical  public/javascripts/effects.js
   identical  public/javascripts/dragdrop.js
   identical  public/javascripts/controls.js
   identical  public/javascripts/application.js
   identical  doc/README_FOR_APP
   identical  log/server.log
   identical  log/production.log
   identical  log/development.log
   identical  log/test.log
      exists  vendor/rails

有什么想法吗?当然我错过了一些巨大的东西......但是什么?

【问题讨论】:

  • 它看起来像是在创建一个新的应用程序。你能试试bundle exec rails s吗?
  • 你在哪里?您在项目根目录中吗? pwd请
  • 您可能正在使用 Rails 2,它正在使用该命令创建新项目。
  • 非常好。在这种情况下做script/server
  • 你真的很快......谢谢。这是我的答案: laslo@ubuntu:~$ bundle exec rails s 找不到 Gemfile laslo@ubuntu:~$ ls Bureau Images new ruby​​gems-2.0.3 Téléchargements Documents Modèles Public s Ubuntu One examples.desktop Musique requirements server Vidéos laslo@ ubuntu:~$ script/server bash: script/server: Aucun fichier ou dossier de ce type laslo@ubuntu:~$ pwd /home/laslo laslo@ubuntu:~$

标签: ruby-on-rails ubuntu localhost


【解决方案1】:

我和你有同样的问题,这就是我解决这个问题的方法。 在您创建的项目的 cd 中键入 script/server。 我

【讨论】:

    【解决方案2】:

    导轨 3+

    从项目根目录尝试bundle exec script/rails server。

    例如

    durrantm.../linker$ bundle exec script/rails server
    => Booting WEBrick
    => Rails 3.1.8 application starting in development on http://0.0.0.0:3000
    => Call with -d to detach
    => Ctrl-C to shutdown server
    [2013-04-08 21:48:24] INFO  WEBrick 1.3.1
    [2013-04-08 21:48:24] INFO  ruby 1.9.3 (2012-11-10) [i686-linux]
    [2013-04-08 21:48:24] INFO  WEBrick::HTTPServer#start: pid=9187 port=3000
    

    导轨 2

    从项目根目录:

    $ script/server
    => Booting WEBrick
    => Rails 2.3.8 application starting on http://0.0.0.0:3000
    => Call with -d to detach
    => Ctrl-C to shutdown server
    [2013-04-08 21:58:11] INFO  WEBrick 1.3.1
    [2013-04-08 21:58:11] INFO  ruby 1.9.3 (2012-11-10) [i686-linux]
    [2013-04-08 21:58:11] INFO  WEBrick::HTTPServer#start: pid=10473 port=3000
    

    如果失败,也许可以重新开始:

    cd                  # Go to your home directory
    rails new abc       # Create the app
    cd abc              # cd into the project's directory.
                        # Change the config/database.yml if desired.
    script/rails server # for rails 3 or use the rails 2 command above.
    

    更多版本信息:

    Ruby,您应该使用 1.9.2+ 大多数人现在使用 1.9.3+。
    我建议您使用 RVM 来维护您的 ruby​​ 版本。其他人也使用 rbenv。

    rvm: https://rvm.io/ # 是的,这是一个真实的 URL!
    rbenv:https://github.com/sstephenson/rbenv/

    Rails 你应该在 Rails 3.1+ 上检查rails -v
    您可以使用gem install rails 安装更新版本,使用-v 3.1.2 指定该版本。

    【讨论】:

    • 感谢您的快速回答,但很遗憾得到相同的“找不到 Gemfile”。
    • 在我的回答中查看更多信息。
    • 仍有问题。 laslo@ubuntu:~/s$ sudo gem install rails -v 3.2.11 错误:安装 rails 时出错:错误:无法构建 gem 原生扩展。 /usr/bin/ruby1.9.1 extconf.rb /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in require': cannot load such file -- mkmf (LoadError) from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in require' 来自 extconf.rb:1:in `
      ' Gem文件将继续安装在 /var/lib/gems/1.9.1/gems/json-1.7.7 中以供检查。结果记录到 /var/lib/gems/1.9.1/gems/json-1.7.7/ext/json/ext/generator/gem_make.out Rails 版本:2.3.14
    • 我什至尝试从头开始(卸载 rvm、ruby 和 rails 并重新开始......但仍然是同样的问题)
    • 请注意,对于 1.8,需要 -dev 包,而不仅仅是 ruby​​1.8-dev。所以如果你有 ruby​​1.9.1 做sudo aptitude install ruby1.9.1-dev
    【解决方案3】:

    Rails 服务器适用于特定应用。你在根路径下启动了rails sever,当然不行。

    您首先需要创建一个新应用。

    $ rails new myapp
    $ cd myapp
    # Install the gems needed at first
    $ bundle install
    # Then start server
    $ rails s
    

    添加

    从您的代码中,我发现真正的原因是您使用的是 Ruby 1.9.1。您刚刚下载的最新 Rails 不支持此版本。

    尝试至少将 Ruby 升级到 1.9.3。

    【讨论】:

    • 对不起...不确定我是从我的 ~/.但感谢您的快速回答。当我执行您的第一个命令时,我收到与以前相同的消息,但没有创建文件夹
    【解决方案4】:

    你的 Ruby 版本是什么?Ruby-v 显示它?你应该首先执行这些命令。

    bundle update
    bundle install
    

    【讨论】:

    • 你的项目的 gemfile 是什么?它的包更新了吗?你捆绑安装成功了吗?
    • 我的 ruby​​ 版本是 1.9.3p194(2012-04-20 修订版 35410){x86_64-linux]。当我执行捆绑更新时,我得到“找不到 Gemfile”。
    • 您可以在您的 Gemfile 所在的其他目录中运行命令。
    • rails2没有Gemfile,都是在environments/development.rb等中完成的
    猜你喜欢
    • 2015-04-23
    • 1970-01-01
    • 2021-02-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多