PTY gem not found

不想你离开。 提交于 2019-12-04 04:04:39

问题


I have Ruby 1.9.3 installed on windows. When I try to require the gem the console outputs that the gem was not found:

require 'pty'

Which outputs:

'require': cannot load such file -- pty <LoadError>

Also I tried:

gem install pty

And got this output:

Could not find a valid gem 'pty' in any repository

How do I fix this?


回答1:


As far as I know, there is no PTY module implementation for Windows as they don't have pseudo-terminal capabilities.




回答2:


You can try

gem install rubysl-pty

if target ruby version is 1.9.x, run gem command with appropriate -v option

gem install rubysl-pty -v 1.0.0

if you would like to use PTY on Windows, my best recommendation is to use cygwin. I am able to install and use this rubysl-pty on my Windows with cygwin yet with few limitations:

$ gem install rubysl-pty -v 1.0.0
Building native extensions.  This could take a while...
Successfully installed rubysl-pty-1.0.0
1 gem installed
Installing ri documentation for rubysl-pty-1.0.0...
Installing RDoc documentation for rubysl-pty-1.0.0...

Sample code:

# test.rb
require 'pty'
PTY.getpty("ls") { |i,o,pid| p i; p pid }

Output:

$ ruby test.rb
#<File:/dev/pty0>
16376


来源:https://stackoverflow.com/questions/16467182/pty-gem-not-found

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!