在Windows上安装适用于ruby的ncurses
我正在尝试为ruby on windows安装ncurses。我以前没有在我的计算机上安装ncurses。我原以为拥有它所要求的就足够了,但现在我被要求指定选项。。。我不知道要选择哪些选项,或者是否需要执行/安装其他操作才能安装gem:在Windows上安装适用于ruby的ncurses,ruby,windows,ncurses,Ruby,Windows,Ncurses,我正在尝试为ruby on windows安装ncurses。我以前没有在我的计算机上安装ncurses。我原以为拥有它所要求的就足够了,但现在我被要求指定选项。。。我不知道要选择哪些选项,或者是否需要执行/安装其他操作才能安装gem: C:\Ruby193\Devkit>gem install ncurses -- --ruby=C:/Ruby193/bin/ruby --without-make-prog --without-opt-dir Temporarily enhancing
C:\Ruby193\Devkit>gem install ncurses -- --ruby=C:/Ruby193/bin/ruby --without-make-prog --without-opt-dir
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing ncurses:
ERROR: Failed to build gem native extension.
C:/Ruby193/bin/ruby.exe extconf.rb --ruby=C:/Ruby193/bin/ruby --without-make-prog --without-opt-dir
C:/Ruby193/lib/ruby/1.9.1/shellwords.rb:35:in `shellsplit': undefined method `scan' for false:FalseClass (NoMethodError)
from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:2216:in `<top (required)>'
from C:/Ruby193/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from C:/Ruby193/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:22:in `<main>'
Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/ncurses-0.9.1 for inspection.
Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/gems/ncurses-0.9.1/./gem_make.out
C:\Ruby193\Devkit>gem安装ncurses--ruby=C:/Ruby193/bin/ruby--不带make prog--不带opt dir
暂时增强包含DevKit的路径。。。
构建本机扩展。这可能需要一段时间。。。
错误:安装ncurses时出错:
错误:无法生成gem本机扩展。
C:/Ruby193/bin/ruby.exe extconf.rb--ruby=C:/Ruby193/bin/ruby--不带make prog--不带opt dir
C:/Ruby193/lib/ruby/1.9.1/shellwords.rb:35:in'shellsplit':未定义的方法'scan'中的false:false类(NoMethodError)
来自C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:2216:in`'
from C:/Ruby193/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in'require'
from C:/Ruby193/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in'require'
来自extconf.rb:22:in`'
Gem文件仍将安装在C:/Ruby193/lib/ruby/gems/1.9.1/gems/ncurses-0.9.1中以供检查。
结果记录到C:/Ruby193/lib/ruby/gems/1.9.1/gems/ncurses-0.9.1//gem\u make.out
太痛苦了,我只想安装这个gem,这样我就可以运行这个:
require 'curses'
cols = Curses.stdscr.maxx
msg = "random_string"
str = msg.center(msg.length + cols - msg.length - 5 - 3)
puts "<!-- #{str}-->"
需要“诅咒”
cols=Curses.stdscr.maxx
msg=“随机字符串”
str=msg.center(msg.length+cols-msg.length-5-3)
放置“”
ruby ncurses gem要求在计算机上安装ncurses。据我所知,ncurses尚未移植到windows。所以我不认为你会让这件事起作用
可能还有其他方法可以确定windows上的屏幕有多宽,但我无法帮助您。更新:SourceForge似乎不再承载用于windows的NCurses二进制文件。这个答案现在实际上已经过时了。很抱歉(截至2015年8月,列表中列出了一个“新”的v6.0版本,它比我回答中的0.9.1版本更新。) 在没有Cygwin、PDCurses或手动构建NCurses源代码的情况下,我最终实现了这一点(在我需要它几年后…)。说明书已经准备好了。供参考:
- 从下载最新的NCurses二进制文件(0.9.1)
- 将文件解压缩到计算机上的某个位置
- 通过运行
Ruby-e'put$:'
- 将ncurses.so和lib\ncurses.rb从ncurses目录复制并粘贴到您选择的目录中。将它们都放在根目录中
- 运行已启用NCurses的应用程序
它起作用了。没有PDC课程 我已经为ruby 2.2做到了这一点,ruby 2.2默认不附带诅咒,但我花了一段时间:
- 从下载李>
- 解开它李>
- 将其内容复制到ruby可以看到的文件夹中。我不确定我用的是哪一个,我想我把它复制到了多个,直到它起作用
可能会有帮助李>ruby-e'put$:'
- 安装curses,
。如果前一步是错误的,这将失败李>gem instal curses
- 完成:D
gem安装诅咒--platform=ruby--with ncurses dir=“C:\ncurses”
C:\n课程可以是我从sourceforge成功下载的任何目录,因此该库仍然可用 然后我尝试了原生Ruby和IronRuby 1.1.3
安装gem时需要curses lib;因此,首先需要安装NCurses 用你的msys2 下载NCurses(撰写本文时为v5.9): 在源目录中 然后卸载并在MSYS外壳中: ./configure--host=x86_64-w64-mingw32--enable term driver--enable sp funcs--prefix=/some/prefix 制造 核对 安装 然后,如链接中所述: 使用--platform=ruby,--with curses include,--with curses lib flags with gem install从2020年2月起(可能更早),您可以使用
gem install curses
它可以毫无问题地工作,至少在Ruby 2.6.5上是如此。死链接:你博客的链接是dead@Nisanio这个答案中应该有足够的信息。我的博客确实早就死了。到SourceForge的死链接也死了。裂开answer@SlySherZ我相信你可以在谷歌上找到ncurses0.9.1二进制文件。仅供参考,GNU发布了NCurses 6.0。再见。@ashes999谢谢!我已经找到了,但这花费了我更多的时间:D
需要“io/console”;行,cols=STDIN.winsize
请修复此答案中的键入错误。zip文件中的库不是ncurses,而是pdcurses,有人已重命名该库以简化(他们的)工作。自2011年以来,mingw已经有了一个ncurses端口,但ruby的包装商还没有意识到这一点。这不是答案。