The Accidental Rubyist

invalid byte sequence in UTF-8

ncurses working with ruby 1.9.2 (Snow Leopard)

with 14 comments

Thanks to the comment on the previous post, and the folks on ruby-forum, I’ve managed to get the ncurses gem working on ruby 1.9.2. Some changes are required w.r.t. STR2CSTR. I’ve uploaded a gem here. I’ve named the gem ncurses-0.9.2.gem to avoid confusion with the existing 0.9.1. I hope it’s not illegal.

btw, not all examples of ncurses are working. Some are breaking due to changes in ruby 1.9.x, and some I don’t know. example.rb, rain.rb and hello_world are working.

Edit: Thanks to Ralf Papenkordt, ncurses 1.2.4 is now working on Snow Leopard. The gem and tarbz2 are available on github.

Update: You may also try:

gem install snowleopard-ncurses

Advertisements

Written by totalrecall

August 22, 2010 at 2:11 pm

Posted in ncurses, ruby

14 Responses

Subscribe to comments with RSS.

  1. Hi,

    is it possible that you publish the gemspec (or whatever you use) for the generation of ncurses-0.9.2.gem? I have compiled ncurses-ruby-1.2.4 on Snow Leopard and want to test it under ruby 1.9.2, but don’t know exactly which files are to be installed under the gem tree. Thanks in advance.

    Btw. is it planned to use rbcurse with ncurses-ruby-1.2.4?

    Ralf Papenkordt

    August 24, 2010 at 8:36 am

  2. 1. I have uploaded the gemspec as http://gist.github.com/546961

    2. I cannot use ncurses 1.2.4 since I am unable to compile it under SL. Can you tell me the changes, or better yet host the source somewhere so i can copy. Why not github ?

    If i can compile it then rbcurse can use it.

    totalrecall

    August 24, 2010 at 10:09 am

  3. Up to now I have never used github. Maybe later.

    The compilation of ncurses 1.2.4 is quiet easy: In extconf.rb change the line

    $CFLAGS += ” -g”

    to

    $CFLAGS += ” -g -DNCURSES_OPAQUE=0″

    then the changes as in 0.9.1 (STR2CSTR), and the normal build routine:

    ruby ./extconf.rb
    make
    make install

    Ralf Papenkordt

    August 24, 2010 at 10:23 am

  4. Very strange. I installed 1.2.4 and ran it successfully, but i do _not_ need to change STR2CSTR.

    I only made the change (as you suggested):
    $CFLAGS += ” -g -DNCURSES_OPAQUE=0″

    I would like to know how 1.2.4 differs from 0.9.1. Is there a lot of functionality change?

    Is there a reason you were asking if rbcurse would use 1.2.4 ?

    thanks a lot

    p.s. i have uploaded the gemspec at http://gist.github.com/547220

    totalrecall

    August 24, 2010 at 2:16 pm

  5. You now have a mixed installation of ncurses-ruby 0.9.1 and 1.2.4.

    ruby -e ‘puts $:’ gives you all directories where ruby is looking for libraries.

    A install of 1.2.4 (make install) installs only two files:

    .rvm/rubies/ruby-1.9.2-p0/lib/ruby/site_ruby/1.9.1/ncurses.rb
    .rvm/rubies/ruby-1.9.2-p0/lib/ruby/site_ruby/1.9.1/x86_64-darwin10.4.0/ncurses_bin.bundle

    I guess your ncurses.rb is the 0.9.1 version. You can distinguish them by looking at the require line:

    0.9.1: require “ncurses.so”
    1.2.4: require “ncurses_bin.so”

    Before you call ‘make install’ make sure that the above 2 files don’t exist (you better delete them). Don’t know why it wasn’t overwritten.

    So to summarize: You installed 1.2.4, but called the 0.9.1 library.

    Ralf Papenkordt

    August 25, 2010 at 9:59 am

  6. Actually, I uninstalled 0.9.1 and then installed 1.2.4
    However, I have both the files: bundle and bin.bundle. I will delete the files, rerun the procedure and see.
    Thanks,

    totalrecall

    August 25, 2010 at 10:06 am

  7. Yes, you are right. i deleted ncurses.bundle, and changed ncurses.rb to point to ncurses_bin.so and it gives a STR2CSTR error.

    totalrecall

    August 25, 2010 at 10:09 am

  8. I have done the changes to STRCSTR. The examples in ncurses work fine.
    However, when i run my examples in rbcurse, i get junk printed on the screen. Most characters are printed as “^E”.

    Also, i notice that installing the gem does not create ncurses.rb and ncurses_bin.bundle in the site directory. I have to “make install” for that to happen.

    totalrecall

    August 25, 2010 at 10:38 am

  9. What exactly have you done? What do you mean by “and changed ncurses.rb to point to ncurses_bin.so”?

    You can’t change ncurses.rb to point to ncurses_bin.so. They belong to different versions. You have to do a “make install” to get the right nbcurses.rb. I have testet rbcurse 1.1.3 with ncurses 1.2.4 and the rbcurse examples,

    cd ~/.rvm/gems/ruby-1.9.2-p0/gems/rbcurse-1.1.3/examples
    ruby test1.rb
    ruby -I. test2.rb

    work correctly (as far as I can estimate it).

    Which example gives “^E”?

    Ralf Papenkordt

    August 25, 2010 at 12:00 pm

  10. I deleted both those files as you recommended (ncurses,rb and bundle). And I then uninstalled ncurses.
    Then i did the full: ruby extconf.rb && make && make install.

    So there is no mixup now.
    If i run test1.rb or test2.rb or testtable.rb all characters printed are junk. I get “^E”.

    totalrecall

    August 25, 2010 at 6:55 pm

  11. Strange. I have uninstalled ncurses. and deleted ncurses.rb and all ncurses.bundle and ncurses_bin.bundle and yet ncurses is working ! Where is it picking it up from.

    Both the examples in ncurses folder are working, and the rbcurse examples. However, the rbcurse examples are printing funny characters.

    totalrecall

    August 25, 2010 at 7:09 pm

  12. > Where is it picking it up from.

    Ignore previous comment. THere was still a ncurses_bin.bundle in rvm which was not coming up in “mdfind -name”

    I’ve deleted those files and will start over.

    totalrecall

    August 25, 2010 at 7:41 pm

  13. Ralf,

    Thanks for your help and the tar.bz2 file you provided. Have uploaded it on http://github.com/rkumar/rbcurse/downloads as well as the gem created.

    Now ncurses-1.2.4 is working fine on Snow Leopard.

    totalrecall

    August 26, 2010 at 12:33 am

  14. Just wanted to say thanks a bunch for the gem. I wasn’t able to find an easier solution getting ncurses on OS X. I’m on Lion, and it’s working great.

    Zack Hovatter

    December 6, 2011 at 9:24 pm


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: