rails服务器无法正常工作,Rails 4.2.0

时间:2015-04-18 02:10:53

标签: ruby-on-rails-4.2

我跟随Michael Hartl的Rails教程,在我捆绑安装所有必需的宝石后,rails服务器在运行时给我一个错误。我正在使用Windows

这是错误:

C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/web-console-2.0.0.beta3/lib/web_console/slave.rb:1:in `require': cannot load such file -- pty (LoadError)
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/web-console-2.0.0.beta3/lib/web_console/slave.rb:1:in `require': cannot load such file -- pty (LoadError)
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/web-console-2.0.0.beta3/lib/web_console.rb:13:in `require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/web-console-2.0.0.beta3/lib/web_console.rb:13:in `<top (required)>'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/web-console-2.0.0.beta3/lib/web-console.rb:1:in `require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/web-console-2.0.0.beta3/lib/web-console.rb:1:in `<top(required)>'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.7.7/lib/bundler/runtime.rb:76:in `require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.7.7/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.7.7/lib/bundler/runtime.rb:72:in `each'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.7.7/lib/bundler/runtime.rb:72:in `block in require'
 from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.7.7/lib/bundler/runtime.rb:61:in `each'
    from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.7.7/lib/bundler/runtime.rb:61:in `require'
    from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.7.7/lib/bundler.rb:133:in `require'
    from C:/sites/sample_app/config/application.rb:7:in `<top(required)>'
    from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:78:in `require'
    from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:78:in `block in server'

from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:75:in `tap'

from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:75:in `server'

 from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:39:in `run_command!'

from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.0/lib/rails/commands.rb:17:in `<top (required)>'

from bin/rails:4:in `require'
from bin/rails:4:in `<main>'

这是Gemfile:

  source 'https://rubygems.org'

gem 'rails',                   '4.2.0'
gem 'bcrypt',                  '3.1.7'
gem 'faker',                   '1.4.2'
gem 'carrierwave',             '0.10.0'
gem 'mini_magick',             '3.8.0'
gem 'fog',                     '1.23.0'
gem 'will_paginate',           '3.0.7'
gem 'bootstrap-will_paginate', '0.0.10'
gem 'bootstrap-sass',          '3.2.0.0'
gem 'sass-rails',              '5.0.2'
gem 'uglifier',                '2.5.3'
gem 'coffee-rails',            '4.1.0'
gem 'jquery-rails',            '4.0.3'
gem 'turbolinks',              '2.3.0'
gem 'jbuilder',                '2.2.3'
gem 'sdoc',                    '0.4.0', group: :doc

group :development, :test do
  gem 'sqlite3',     '1.3.9'
  gem 'byebug',      '3.4.0'
  gem 'web-console', '2.0.0.beta3'
  gem 'spring',      '1.1.3'
end

group :test do
  gem 'minitest-reporters', '1.0.5'
  gem 'mini_backtrace',     '0.1.3'
  gem 'guard-minitest',     '2.3.1'
end

group :production do
  gem 'pg',             '0.17.1'
  gem 'rails_12factor', '0.0.2'
  gem 'puma',           '2.11.1'
end

非常感谢所有帮助

2 个答案:

答案 0 :(得分:0)

查看错误,您的开发组中的web-console gem似乎会导致此问题。有些人看着online,看起来这个特殊的宝石在Windows环境中不能很好地工作(可以说,Rails作为一个整体在Windows机器上不合作)。

尝试发表评论web-console,然后bundle installrails c

如果仍然没有运气添加:

gem 'rubysl-pty', :platforms => :ruby

gem 'web-console', :platforms => :ruby

然后bundle installrails c并告诉我们是否能解决您的问题!

或者,我建议使用cloud9或者如果你想在rails应用程序本地工作,并且正在使用Windows机器,请尝试安装Linux / Unix ......

答案 1 :(得分:0)

更改

def algo():
    return range(5)

a5 = algo()                       # works
b1,b2,b3,b4,b5 = algo()           # works
c1,c2,c3 = algo()                 # doesn't work
d1,d2,d3,d4,d5,d6 = algo()        # doesn't work.

gem 'web-console', '2.0.0.beta3'

应该让它发挥作用