Installing ncurses for ruby on Windows

杀马特。学长 韩版系。学妹 提交于 2019-12-01 07:06:40

Updated version:

  1. Get ncurses (MinGW Port): http://invisible-island.net/ncurses/
  2. Put it in C:\ncurses
  3. gem install curses --platform=ruby -- --with-ncurses-dir="C:\ncurses"
  4. Copy the contents of C:\ncurses\bin to somewhere in your path

C:\ncurses can be any directory

I've managed to do it for ruby 2.2, which doesn't come with curses by default, but it took me a while:

  • Download PDCurses from SourceForge;
  • Unzip it;
  • Copy it's contents to a folder where ruby can see it. I'm not sure which one I used, I think I copied it to multiple ones until it worked. ruby -e 'puts $:' might help;
  • Install curses, gem instal curses. If the previous step was wrong, this will fail;
  • Done :D

This method didn't work for other gems, like ffi-ncurses. Tip: most of curses functionality comes from the Window class, which comes with curses by default.

Update: It seems like SourceForge no longer hosts NCurses binaries for Windows. This answer is effectively obsolete now. Sorry! (As of August 2015, the GNU NCurses Page lists a "new" v6.0 release, which is newer than the 0.9.1 version in my answer.)

I finally got this to work (years after I needed it ...) without Cygwin, PDCurses, or manually building the NCurses source. The instructions are available on my blog. For reference:

  • Download the latest NCurses binaries (0.9.1) from SourceForge.
  • Unzip the files somewhere on your machine.
  • Find out where Ruby searches for libraries by running ruby -e 'puts $:'
  • Copy and paste ncurses.so and lib\ncurses.rb from the NCurses directory into the directory you picked. Place them both in the root directory.
  • Run your NCurses-enabled app.

It works. Without PDCurses!

I've successfully downloaded ncurses 0.9.1 binaries from sourceforge, so the library is still available.

I then tried with both native Ruby and IronRuby 1.1.3

  1. placing the two files (ncurses.so ncurses.rb) in

    C:\Ruby\Ruby193\lib\ruby\1.9.1

    gives an error with native Ruby

    The specified module could not be found. - C:/Ruby/Ruby193/lib/ruby/1.9.1/ncurses.so (LoadError)

  2. Placing them here (for IronRuby) C:\Program Files (x86)\IronRuby 1.1\Lib\ruby\1.9.1

    gives

    The module was expected to contain an assembly manifest. (Exception from HRESULT: 0x80131018)

When gem installed needs for curses lib; so at first you need to install NCurses with your msys2

https://sourceforge.net/p/mingw-w64/wiki2/NCurses/

Download NCurses (v5.9 at the time of writing): http://ftp.gnu.org/pub/gnu/ncurses/ in the source directory

Then untar and in the MSYS shell:

./configure --host=x86_64-w64-mingw32 --enable-term-driver --enable-sp-funcs --prefix=/some/prefix

make

make check

make install

then as mentioned in the link : https://github.com/ruby/curses/issues/13

use --platform=ruby ,--with-curses-include ,--with-curses-lib flags with gem install

The ruby ncurses gem requires that ncurses in installed on the machine. As far as I know ncurses has not been ported to windows. So I don't think you are going to get this to work.

There may be other ways to find out how wide the screen is on windows but I can't help you with that.

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