Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

compile Ruby 2.0 errors without rvm or rbenv , `readline.c:1886:26: error: 'Function' undeclared (first use in this function)`

I want to install gitlab, which don't recommend to use any ruby version manager. But

This is my OS Linux dqa-dev 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:08:14 UTC 2014 i686 i686 i686 GNU/Linux

linking shared-object psych.so
installing default psych libraries
make[2]: Leaving directory `/home/poc/ruby-2.0.0-p451/ext/psych'
make[2]: Entering directory `/home/poc/ruby-2.0.0-p451/ext/pty'
compiling pty.c
pty.c: In function 'chfunc':
pty.c:143:12: warning: ignoring return value of 'seteuid', declared with attribute warn_unused_result [-Wunused-result]
     seteuid(getuid());
            ^
linking shared-object pty.so
installing default pty libraries
make[2]: Leaving directory `/home/poc/ruby-2.0.0-p451/ext/pty'
make[2]: Entering directory `/home/poc/ruby-2.0.0-p451/ext/racc/cparse'
compiling cparse.c
linking shared-object racc/cparse.so
installing default cparse libraries
make[2]: Leaving directory `/home/poc/ruby-2.0.0-p451/ext/racc/cparse'
make[2]: Entering directory `/home/poc/ruby-2.0.0-p451/ext/readline'
compiling readline.c
readline.c: In function 'Init_readline':
readline.c:1886:26: error: 'Function' undeclared (first use in this function)
     rl_pre_input_hook = (Function *)readline_pre_input_hook;
                          ^
readline.c:1886:26: note: each undeclared identifier is reported only once for each function it appears in
readline.c:1886:36: error: expected expression before ')' token
     rl_pre_input_hook = (Function *)readline_pre_input_hook;
                                    ^
readline.c: At top level:
readline.c:530:1: warning: 'readline_pre_input_hook' defined but not used [-Wunused-function]
 readline_pre_input_hook(void)
 ^
make[2]: *** [readline.o] Error 1
make[2]: Leaving directory `/home/poc/ruby-2.0.0-p451/ext/readline'
make[1]: *** [ext/readline/all] Error 2
make[1]: Leaving directory `/home/poc/ruby-2.0.0-p451'
make: *** [build-ext] Error 2
like image 746
newBike Avatar asked May 06 '14 07:05

newBike


3 Answers

I also have Ubuntu 14.04 and I got to make it work. Sharing what I did just in case it works for you.

I patched the file ext/readline/readline.c replacing line 1886:

rl_pre_input_hook = (Function *)readline_pre_input_hook;

With

rl_pre_input_hook = (rl_hook_func_t *)readline_pre_input_hook;

Then I tried to make it again and it worked.

Source: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=741825

like image 123
Pablo López Torres Avatar answered Oct 21 '22 09:10

Pablo López Torres


I also ran into this issue trying to install ruby-2.0.0-p247 with rbenv. Save some time by using this patch.

You can run it like this:

curl -fsSL https://gist.github.com/ference/d3d4cbbe18309a91ad9b/raw/267ea89fa145c536967831e1af4dea030297b53e/ruby-2.0.0-p247.patch | rbenv install --patch 2.0.0-p247
like image 35
pymkin Avatar answered Oct 21 '22 09:10

pymkin


This is my solution on Ubuntu 14.04 Server edition.

I need to install underline

sudo apt-get install libreadline6 libreadline6-dev

Then, the problem was fixed.

like image 33
newBike Avatar answered Oct 21 '22 09:10

newBike