简体   繁体   English

`rails s` 在 Windows RailsInstaller 中显示“`require': 无法加载此类文件 -- pty (LoadError)”

[英]`rails s` says "`require': cannot load such file -- pty (LoadError)" in Windows RailsInstaller

I have just installed RailsInstaller on my Windows 10 PC.我刚刚在我的 Windows 10 PC 上安装了 RailsInstaller。 I am not able to run rails s or rails g controller StaticPages home help .我无法运行rails srails g controller StaticPages home help

I have also tried to fix this by installing the zeus gem as suggested by this related StackOverflow question but had no success.我也曾尝试通过安装宙斯宝石所建议来解决这个这个相关的StackOverflow的问题,但没有成功。

Gemfile:宝石档案:

source 'https://rubygems.org'

gem 'rails',        '4.2.2'
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
gem 'pry-nav', group: [:development, :test]

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'
end

Errors:错误:

rails s
c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.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.2.0/lib/ruby/gems/2.2.0/gems/web-console-2.0.0.beta3/lib/web_console/slave.rb:1:in `<top (required)>'
        from c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/web-console-2.0.0.beta3/lib/web_console.rb:13:in `require'
        from c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/web-console-2.0.0.beta3/lib/web_console.rb:13:in `<top (required)>'
        from c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/web-console-2.0.0.beta3/lib/web-console.rb:1:in `require'
        from c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/web-console-2.0.0.beta3/lib/web-console.rb:1:in `<top (required)>'
        from c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:77:in `require'
        from c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:77:in `block (2 levels) in require'
        from c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `each'
        from c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `block in require'
        from c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `each'
        from c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `require'
        from c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler.rb:99:in `require'
        from c:/Sites/sample_app/config/application.rb:7:in `<top (required)>'
        from c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:78:in `require'
        from c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:78:in `block in server'
        from c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:75:in `tap'
        from c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:75:in `server'
        from c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
        from c:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.2/lib/rails/commands.rb:17:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'

The backtrace tells us that the web-console gem wants Ruby's pty library.回溯告诉我们 web-console gem 需要 Ruby 的 pty 库。 Unfortunately PTYs (pseudo-terminals) are a Unix/Linux feature which does not exist on Windows, so that Ruby library doesn't either.不幸的是, PTY(伪终端)是 Windows 上不存在的 Unix/Linux 功能,因此 Ruby 库也不存在。

You can get moving in a couple of ways:您可以通过以下几种方式开始行动:

  • If you don't care about the web-console gem right now, just remove it from your Gemfile.如果您现在不关心网络控制台 gem,只需将它从您的 Gemfile 中删除。

  • If you really need the web-console gem, try replacing web-console with these gems:如果您确实需要 web-console gem,请尝试用这些 gem 替换 web-console:

     gem 'rubysl-pty', platforms: :ruby gem 'web-console-rails3', platforms: :ruby

    Source: a web-console Github issue .来源:网络控制台 Github 问题

I solve this issue by following below steps:我按照以下步骤解决了这个问题:

  1. First check your Gemfile.lock, if you have mentioned bcrypt version over there then you don't need to mention the bcrypt version in Gemfile.首先检查你的 Gemfile.lock,如果你在那里提到了 bcrypt 版本,那么你不需要在 Gemfile 中提到 bcrypt 版本。
  2. If bcrypt version is missing in the Gemfile.lock then in the perform following steps: a) gem install bcrypt b) Open your Gemfile and paste "gem 'bcrypt', '~> 3.1.7'" c) run command in console : bundle install如果 Gemfile.lock 中缺少 bcrypt 版本,则执行以下步骤: a) gem install bcrypt b) 打开 Gemfile 并粘贴“gem 'bcrypt', '~> 3.1.7'” c) 在控制台中运行命令:捆绑安装

I hope by following above given steps might solve your problem.我希望按照上面给出的步骤可以解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法加载此类文件-pty(LoadError) - cannot load such file — pty (LoadError) `require&#39;:无法加载此类文件-rails / all(LoadError) - `require': cannot load such file — rails/all (LoadError) Rails Rspec `require': 无法加载此类文件 -- rails_helper (LoadError) - Rails Rspec `require': cannot load such file -- rails_helper (LoadError) Ruby on Rails:错误“require”:无法加载此类文件——bundler/setup (LoadError) - Ruby on Rails: Error `require': cannot load such file -- bundler/setup (LoadError) rails服务器抛出`require&#39;:无法加载这样的文件 - bigdecimal / util(LoadError) - rails server throws `require': cannot load such file — bigdecimal/util (LoadError) require': 无法加载此类文件 -- mysql2/mysql2 (LoadError) rails 4 - require': cannot load such file -- mysql2/mysql2 (LoadError) rails 4 无法加载此类文件 -- pty (LoadError) 开发环境设置 - cannot load such file -- pty (LoadError) Dev Environment Setup Rails 控制台:在“require”中:无法加载此类文件 — readline (LoadError) - Rails console: in `require': cannot load such file — readline (LoadError) Rails错误-“需要”:没有要加载的此类文件-rubygems(LoadError) - Rails Error - `require': no such file to load — rubygems (LoadError) &#39;require&#39;:没有要加载的文件— rails / cli(LoadError) - 'require': no such file to load — rails/cli (LoadError)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM