Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uninitialized constant Curses::Menu (NameError) #83

Closed
AlexB52 opened this issue Nov 22, 2023 · 3 comments · Fixed by #84
Closed

uninitialized constant Curses::Menu (NameError) #83

AlexB52 opened this issue Nov 22, 2023 · 3 comments · Fixed by #84

Comments

@AlexB52
Copy link
Contributor

AlexB52 commented Nov 22, 2023

Hi,

I've been trying the different sample code for curses. All of them work except for the sample/menu.rb
Running ruby sample/menu.rb gives me this error.

sample/menu.rb:13:in `<main>': uninitialized constant Curses::Menu (NameError)

menu = Curses::Menu.new([

I'm on mac OS ventura 13.4.1 and homebrew seems to have ncurses 6.4 already installed.

I can see that there are some issues getting menu from ncurses from MacOS

Is this why there is no documentation on the README for MacOS?

The menu sample works fine when inside the official docker image ruby:3.0

What would it take to get ncurses menu to work?

Thanks for your help

@AlexB52
Copy link
Contributor Author

AlexB52 commented Nov 22, 2023

I'm not really familiar with C bindings library.
I tried to run ruby extconf.rb and these are the logs.

ruby extconf.rb
checking for tgetent() in -ltinfow... no
checking for tgetent() in -ltinfo... no
checking for tgetent() in -ltermcap... yes
checking for ncursesw/curses.h... no
checking for ncurses.h... yes
checking for initscr() in -lncursesw... no
checking for initscr() in -lncurses... yes
header: ncurses.h
library: ncurses
checking for beep()... yes
checking for bkgd()... yes
checking for bkgdset()... yes
checking for curs_set()... yes
checking for deleteln()... yes
checking for doupdate()... yes
checking for flash()... yes
checking for getbkgd()... yes
checking for getnstr()... yes
checking for init()... no
checking for init in ncurses.h... no
checking for isendwin()... yes
checking for keyname()... yes
checking for keypad()... yes
checking for resizeterm()... yes
checking for scrl()... yes
checking for set()... no
checking for set in ncurses.h... no
checking for setscrreg()... yes
checking for ungetch()... yes
checking for addnwstr()... yes
checking for wattroff()... yes
checking for wattron()... yes
checking for wattrset()... yes
checking for wbkgd()... yes
checking for wbkgdset()... yes
checking for wdeleteln()... yes
checking for wgetnstr()... yes
checking for wresize()... yes
checking for wscrl()... yes
checking for wsetscrreg()... yes
checking for werase()... yes
checking for redrawwin()... yes
checking for waddnwstr()... yes
checking for mvderwin()... yes
checking for derwin()... yes
checking for touchwin()... yes
checking for untouchwin()... yes
checking for wtouchln()... yes
checking for is_linetouched()... yes
checking for is_wintouched()... yes
checking for def_prog_mode()... yes
checking for reset_prog_mode()... yes
checking for timeout()... yes
checking for wtimeout()... yes
checking for nodelay()... yes
checking for init_color()... yes
checking for wcolor_set()... yes
checking for use_default_colors()... yes
checking for assume_default_colors()... yes
checking for newpad()... yes
checking for unget_wch()... yes
checking for get_wch()... yes
checking for wget_wch()... yes
checking for PDC_get_key_modifiers()... no
checking for PDC_get_key_modifiers in ncurses.h... no
checking for convertible type of chtype... unsigned int
checking for _XOPEN_SOURCE_EXTENDED... yes
checking for ESCDELAY in ncurses.h... yes
checking for TABSIZE in ncurses.h... yes
checking for COLORS in ncurses.h... yes
checking for COLOR_PAIRS in ncurses.h... yes
checking for function curses_version in ncurses.h... yes
checking for variable curses_version in ncurses.h... no
checking for ncursesw/menu.h... no
checking for ncurses/menu.h... no
checking for curses/menu.h... no
checking for menu.h... yes
checking for new_menu() in -lmenuw... no
checking for new_menu() in -lmenu... no
checking for ncursesw/form.h... no
checking for ncurses/form.h... no
checking for curses/form.h... no
checking for form.h... yes
checking for new_form() in -lformw... no
checking for new_form() in -lform... yes
checking for form_driver_w()... no
checking for sizeof(WINDOW) is available... no
checking for sizeof(MEVENT) is available... yes
checking for sizeof(ITEM) is available... yes
checking for sizeof(MENU) is available... yes
checking for sizeof(FIELD) is available... yes
checking for sizeof(FORM) is available... yes
creating extconf.h
creating Makefile

@shugo
Copy link
Member

shugo commented Nov 23, 2023

It seems that ncurses of macOS does not support menu:

https://stackoverflow.com/questions/56622042/clang-on-macos-fails-linking-lmenu-from-ncurses

Could you try installing ncurses by Homebrew?

@AlexB52
Copy link
Contributor Author

AlexB52 commented Nov 23, 2023

Thanks @shugo

It took me a while to understand what I had to do but after running the command below sample/menu.rb now works 👍

gem install curses -- --use-system-libraries --with-ncurses-dir=/usr/local/opt/ncurses

with /usr/local/opt/ncurses the path where homebrew installed ncurses on my machine.

I've created a small PR to update the README.md #84

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants