ruby / curses

Ruby binding for curses, ncurses, and PDCurses. Formerly part of the ruby standard library.
Other
294 stars 34 forks source link

Easy install for Windows #13

Closed kevin-stuart closed 7 years ago

kevin-stuart commented 9 years ago

I used Ruby 1.9 x86 with Windows. Now I installed 2.1 x64. I discovered that curses is not bundle anymore with Ruby and this gem is supposed to be the replacement. A quick gem install curses failed, because some native libraries needed to be built. I installed the dev-kit. It does not seem to include the required headers. I might be able to get the headers from cygwin by installing `libncurses-devel, but that is already quite a lot of effort already after installing the devkit.

Is there some way to have the gem include a prebuilt dll for Windows? For Python, it seems to be possible to offer packages with binaries for platforms to not require compiling the native libraries. As it currently stands, it is quite difficult to just get up and running if the devkit is not sufficient for compiling the gem.

It used to be really easy for a Windows user to use ncurses with Ruby since it was bundled with the Ruby install. The gem is not a sufficient replacement on Windows as a platform, if there are not easy instructions and an easy way to build to gem. On Linux it would be quite simple to obtain the missing headers and build the gem, but this is not the case for Windows.

carleshf commented 8 years ago

After close to one year of the post still no answer and I found myself in the same situation. Will got answer for this issue?

kevin-stuart commented 8 years ago

I did not receive any answer, it seems pretty abandoned, which I think is a shame.

Since this did not inspire my confidence in Ruby, I have since then started to migrate to Python. I am under the impression that the ecosystem is better maintained, since this was not issue there.

drbrain commented 8 years ago

I guess there are only you two who want to use ruby-curses on Windows (I believe there are very few non-Windows users).

Creating compiled gems for Windows is both a financial and time commitment. Windows costs money to purchase. Maintaining a second operating system and keeping it up-to-date takes time. Maintaining a Windows build environment and keeping it up to date takes time.

We the maintainers are not obligated to work for free to maintain this software for you.

I will leave this issue open in case someone steps forward with a patch for adding pre-built Windows gems for ruby-curses and is willing to create releases.

preetpalS commented 8 years ago

I encountered this issue when I wanted to contribute to a project that depended on curses (Turbolinks relies on blade (this gem has a dependency on curses) for running its test suite). I was able to install the curses gem on Windows using msys2 (I believe that the official Git distribution on Windows is built with this toolchain so you should have some confidence in using it). The following bash commands from my bash history (mingw64 shell (make sure to use the 64-bit shell as this will not work on the msys shell or the 32-bit one)) show exactly how I was able to install the gem on Windows and run the test suite for Turbolinks on Windows 10 (64-bit):

pacman -S mingw-w64-x86_64-ruby
pacman -S mingw-w64-x86_64-toolchain
pacman -S base-devel gmp-devel libcrypt-devel ncurses-devel
gem install curses
cd ~/Projects/Github/turbolinks/
gem install bundler
bundle
pacman -S mingw-w64-x86_64-nodejs
export TERMINFO=/mingw64/share/terminfo
bin/blade build
bin/blade runner

Links I used in figuring out how to install the curses gem on Windows:

https://github.com/junegunn/fzf/wiki/Installing-curses-gem https://sourceforge.net/p/msys2/discussion/general/thread/f81f0b97/#e1ad

On a side note, beware that pre-built gems typically don't work on the Ruby from MSYS2 (the prebuilt versions typically only work with the Ruby from http://rubyinstaller.org/ (and then, only if they were built with the Ruby version that you are using (for example some prebuilt gems do not with Ruby 2.3 yet))) so you will have to build them on your own, by using the --platform=ruby flag, finding the appropriate libraries using the package manager, and sometimes overriding other build flags (gem install x --platform=ruby -- --x-header-location=/c/x). Also, I find that bundler (for commands other than bundle exec) reinstalls the pre-built gems when you run it which forces you to uninstall the prebuilt gems (without uninstalling the gems you built on the MSYS2 Ruby) to get your project to work.

kevin-stuart commented 8 years ago

Thank you for the detailed information. This is very interesting and helpful. I have not looked at mys2 before, only Cygwin.

I also found that Cygwin has a ruby-curses package that seems to do the trick. As an another alternative to a full VM, there is also the new beta Windows Subsystem for Linux (WSL LXSS), which is Ubuntu based.

However, my original inquiry was targeted at the simple installers from http://rubyinstaller.org/ to get up and running without any other subsystems and/or manual building. I figured that those are the most obvious installers for Windows installations. Maybe it would be best if a compatible curses gem would be build together with the installers (like it used to), since the builds are done anyway for Windows. But I am not sure how the management of this is organized.

preetpalS commented 8 years ago

@kevin-stuart I am glad that you found my response helpful.

I believe http://rubyinstaller.org is actually a third-party (in that it's not supported officially by the developers of the Ruby programming language; please correct me if I'm wrong). http://rubyinstaller.org actually has a GitHub page (https://github.com/oneclick/rubyinstaller) and they have an FAQ on their Wiki that answers your question directly (https://github.com/oneclick/rubyinstaller/wiki/FAQ#bundled_short).

PeterCamilleri commented 8 years ago

It is true that http://rubyinstaller.org is third party and not officially supported. It is also true that it is now completely unsupported as the public has been told to switch to something called chocolatey and install using psychic powers to bridge the gap.

Looks to me that Ruby as a multi-platform programming tool is already dead.

preetpalS commented 8 years ago

@PeterCamilleri I am using Ruby 2.3.1 (released less than two months ago) from http://rubyinstaller.org on Windows without any issues (there are a couple of gems that you'll probably have to compile yourself but that's only a minor inconvenience), it's a bit of a stretch to say that it's completely unsupported IMO.

You can basically target any platform you want with Ruby. You can use Opal (Ruby to JavaScript compiler) to target anywhere JavaScript can run and you can use mruby for embedded systems. There's also JRuby that can fully interop with Java and its ecosystem. Then there's RubyMotion that can run natively in iOS and Android. Plus there's the official Ruby that runs natively on Windows and all *nixes. On the contrary, Ruby is probably a more viable multi-platform programming tool today than it's ever been.

PeterCamilleri commented 8 years ago

@preetpalS That's really good to hear actually. In a case like this, I really like to be wrong. Umm, just one thing... Is there a curses library for JRuby? I know I should probably do the legwork myself, but if you already know...

preetpalS commented 8 years ago

@PeterCamilleri I don't think so since Curses is a gem with a native dependency.

shugo commented 7 years ago

FYI, I could successfully build curses with a forked version of PDCurses by the following steps:

> set PATH=\DevKit\bin;%PATH%
> git clone https://github.com/Bill-Gray/PDCurses.git # or download zip from https://github.com/Bill-Gray/PDCurses and extract
> cd PDCurses\win32
> make -f gccwin32.mak WIDE=Y DLL=Y
> copy pdcurses.dll \Ruby23-x64\bin
> copy ..\curses.h \Ruby23-x64\include
> gem install --platform=ruby -- --with-curses-include=\Ruby23-x64\include --with-curses-lib=\Ruby23-x64\bin
shugo commented 7 years ago

curses 1.1.0 has been released with binary gems for x86-mingw32 and x64-mingw32. Supported versions of Ruby are 2.2, 2.3, and 2.4.