Subject: [sup-talk] sup and OpenBSD

From: [email-masked] (Nick Guenther)
Date: Wed, 26 Nov 2008 12:48:36 -0500

I checked out the sup git repo and after fighting a bit to get all the
libs I needed installed (it's a bit wonky since I'm letting both
rubygems and BSD's pkg_add manage different ones).

$ ruby -I lib -w bin/sup
/usr/local/lib/ruby/1.8/dl/import.rb:29:in `initialize': File not
found (RuntimeError)
        from /usr/local/lib/ruby/1.8/dl/import.rb:29:in `dlopen'
        from /usr/local/lib/ruby/1.8/dl/import.rb:29:in `dlload'
        from /usr/local/lib/ruby/1.8/dl/import.rb:27:in `each'
        from /usr/local/lib/ruby/1.8/dl/import.rb:27:in `dlload'
        from ./lib/sup.rb:17
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require'
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require'
        from bin/sup:9

The problem here is that you are asking for libc.so.6 which OpenBSD
doesn't have (on my 4.3 system I see ["/usr/lib/libc.so.41.0",
"/usr/lib/libc.so.43.0"]). A patch:

diff --git a/lib/sup.rb b/lib/sup.rb
index 93369a5..dfdbda2 100644
--- a/lib/sup.rb
+++ b/lib/sup.rb
@@ -14,7 +14,7 @@ require 'curses'
 require 'dl/import'
 module LibC
   extend DL::Importable
-  dlload Config::CONFIG['arch'] =~ /darwin/ ? "libc.dylib" : "libc.so.6"
+  dlload Config::CONFIG['arch'] =~ /darwin/ ? "libc.dylib" : "libc.so"
   extern "void setlocale(int, const char *)"
 end
 LibC.setlocale(6, "")  # LC_ALL == 6

Now after doing that I still can't get sup to go. It doesn't seem to
like curses for some reason:

--- ArgumentError from thread: main
couldn't initialize curses color pair 4, 0 (key 1)
./lib/sup/colormap.rb:130:in `color_for'
./lib/sup/colormap.rb:206:in `send'
./lib/sup/colormap.rb:206:in `method_missing'
./lib/sup/buffer.rb:106:in `write'
./lib/sup/modes/scroll-mode.rb:51:in `draw'
./lib/sup/modes/scroll-mode.rb:49:in `each'
./lib/sup/modes/scroll-mode.rb:49:in `draw'
./lib/sup/modes/line-cursor-mode.rb:24:in `draw'
./lib/sup/buffer.rb:97:in `draw'
./lib/sup/buffer.rb:294:in `draw_screen'
bin/sup:154

I noticed when trying to install sup via gems (before giving up and
running the code directly) that it died on compiling curses support
for some reason:

I installed the OpenBSD ruby-ncurses package instead and hoped all was
well. I am just learning Ruby, but the fact that sup gets past
`require 'ncurses'` means that ncurses should be installed right?

$ sudo gem install ncurses
Password:
Bulk updating Gem source index for: http://gems.rubyforge.org
Building native extensions.  This could take a while...
ERROR:  Error installing ncurses:
        ERROR: Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb install ncurses
checking for unistd.h... yes
checking for ncurses.h... yes
checking for wmove() in -lncurses... yes
checking for newscr()... yes
checking for TABSIZE()... yes
checking for ESCDELAY()... yes
checking for keybound()... yes
checking for curses_version()... yes
checking for tigetstr()... yes
checking for getwin()... yes
checking for putwin()... yes
checking for ungetmouse()... yes
checking for mousemask()... yes
checking for wenclose()... yes
checking for mouseinterval()... yes
checking for wmouse_trafo()... yes
checking for mcprint()... yes
checking for has_key()... yes
checking for delscreen()... yes
checking for define_key()... yes
checking for keyok()... yes
checking for resizeterm()... yes
checking for use_default_colors()... yes
checking for use_extended_names()... yes
checking for wresize()... yes
checking for attr_on()... yes
checking for attr_off()... yes
checking for attr_set()... yes
checking for chgat()... yes
checking for color_set()... yes
checking for filter()... yes
checking for intrflush()... yes
checking for mvchgat()... yes
checking for mvhline()... yes
checking for mvvline()... yes
checking for mvwchgat()... yes
checking for mvwhline()... yes
checking for mvwvline()... yes
checking for noqiflush()... yes
checking for putp()... yes
checking for qiflush()... yes
checking for scr_dump()... yes
checking for scr_init()... yes
checking for scr_restore()... yes
checking for scr_set()... yes
checking for slk_attr_off()... no
checking for slk_attr_on()... no
checking for slk_attr()... yes
checking for slk_attr_set()... yes
checking for slk_color()... yes
checking for tigetflag()... yes
checking for tigetnum()... yes
checking for use_env()... yes
checking for vidattr()... yes
checking for vid_attr()... no
checking for wattr_on()... yes
checking for wattr_off()... yes
checking for wattr_set()... yes
checking for wchgat()... yes
checking for wcolor_set()... yes
checking for getattrs()... no
checking which debugging functions to wrap...
checking for _tracef()... no
checking for _tracedump()... no
checking for _nc_tracebits()... yes
checking for _traceattr()... no
checking for _traceattr2()... no
checking for _tracechar()... no
checking for _tracechtype()... no
checking for _tracechtype2()... no
checking for _tracemouse()... no
checking for other functions that appeared after ncurses version 5.0...
checking for assume_default_colors()... yes
checking for attr_get()... yes
checking for the panel library...
checking for panel.h... yes
checking for panel_hidden() in -lpanel... yes
checking for the form library...
checking for form.h... yes
checking for new_form() in -lform... yes
creating Makefile

make
cc -I. -I. -I/usr/local/lib/ruby/1.8/i386-openbsd4.3 -I.
-DHAVE_UNISTD_H -DHAVE_NCURSES_H -DHAVE_NEWSCR -DHAVE_TABSIZE
-DHAVE_ESCDELAY -DHAVE_KEYBOUND -DHAVE_CURSES_VERSION -DHAVE_TIGETSTR
-DHAVE_GETWIN -DHAVE_PUTWIN -DHAVE_UNGETMOUSE -DHAVE_MOUSEMASK
-DHAVE_WENCLOSE -DHAVE_MOUSEINTERVAL -DHAVE_WMOUSE_TRAFO
-DHAVE_MCPRINT -DHAVE_HAS_KEY -DHAVE_DELSCREEN -DHAVE_DEFINE_KEY
-DHAVE_KEYOK -DHAVE_RESIZETERM -DHAVE_USE_DEFAULT_COLORS
-DHAVE_USE_EXTENDED_NAMES -DHAVE_WRESIZE -DHAVE_ATTR_ON
-DHAVE_ATTR_OFF -DHAVE_ATTR_SET -DHAVE_CHGAT -DHAVE_COLOR_SET
-DHAVE_FILTER -DHAVE_INTRFLUSH -DHAVE_MVCHGAT -DHAVE_MVHLINE
-DHAVE_MVVLINE -DHAVE_MVWCHGAT -DHAVE_MVWHLINE -DHAVE_MVWVLINE
-DHAVE_NOQIFLUSH -DHAVE_PUTP -DHAVE_QIFLUSH -DHAVE_SCR_DUMP
-DHAVE_SCR_INIT -DHAVE_SCR_RESTORE -DHAVE_SCR_SET -DHAVE_SLK_ATTR
-DHAVE_SLK_ATTR_SET -DHAVE_SLK_COLOR -DHAVE_TIGETFLAG -DHAVE_TIGETNUM
-DHAVE_USE_ENV -DHAVE_VIDATTR -DHAVE_WATTR_ON -DHAVE_WATTR_OFF
-DHAVE_WATTR_SET -DHAVE_WCHGAT -DHAVE_WCOLOR_SET -DHAVE__NC_TRACEBITS
-DHAVE_ASSUME_DEFAULT_COLORS -DHAVE_ATTR_GET -DHAVE_PANEL_H
-DHAVE_FORM_H -I/usr/local/include -DOPENSSL_NO_STATIC_ENGINE -fPIC
-O2 -pipe  -fPIC -g -c form_wrap.c
form_wrap.c: In function `field_check':
form_wrap.c:1147: error: `true' undeclared (first use in this function)
form_wrap.c:1147: error: (Each undeclared identifier is reported only once
form_wrap.c:1147: error: for each function it appears in.)
form_wrap.c: In function `char_check':
form_wrap.c:1161: error: `true' undeclared (first use in this function)
form_wrap.c: In function `next_choice':
form_wrap.c:1192: error: `true' undeclared (first use in this function)
form_wrap.c: In function `prev_choice':
form_wrap.c:1201: error: `true' undeclared (first use in this function)
*** Error code 1

Stop in /usr/local/lib/ruby/gems/1.8/gems/ncurses-0.9.1 (line 92 of
/usr/share/mk/sys.mk).

Anyway, it shouldn't matter that the gem can't install because the
ncurses.rb I have installed in site_ruby is newer than the ncurses.rb
from the gem, judging from the version line. I don't know what to make
of this since at all. I'm not familiar with Ruby yet but if you could
point me at a right direction I will probably be able to figure this
out.

p.s. sorry for the null message just now. Sup doesn't work (yet) so I
was going to write this message in `mail` before I realized that was a
terrible idea but my finger slipped.

-Nick

---

From: [email-masked] (William Morgan)
Date: Wed, 26 Nov 2008 15:40:23 -0800

Reformatted excerpts from Nick Guenther's message of 2008-11-26:
> "/usr/lib/libc.so.43.0"]).

Someone else just reported this problem too. I wonder whether the best
solution is your patch (remove the .6) or the patch I was thinking of,
where we special-case BSD to look for libc.so.43. Does anyone have any
suggestions?

> `require 'ncurses'` means that ncurses should be installed right?

I... think so. What's your TERM environment variable set to? Do other
(color!) ncurses programs work?

> form_wrap.c:1147: error: `true' undeclared (first use in this function)

Do you have both ncurses and ruby development libraries installed? I
know what they are in Linux world but not in BSD land.

> point me at a right direction I will probably be able to figure this

Yeah, I would ignore the gem issue for now. I suspect that at this point
it's a matter of tricking the 1970's technology that is ncurses into
displaying color on your particular environment, by trying different
TERMs and terminal emulators.
-- 
William <wmorgan-sup at masanjin.net>