postmodern / ruby-install

Installs Ruby, JRuby, TruffleRuby, or mruby
MIT License
1.91k stars 255 forks source link

not able to install older ruby versions #394

Closed SilentGlasses closed 3 years ago

SilentGlasses commented 3 years ago

Fresh install of both chruby and ruby-install on MacOS 10.15.7 using the homebrew method:

brew install ruby-install brew install chruby

Attempt to install new ruby:

I tried with 2.2.4 and 2.5.0 they fail with their own errors but this is the latest one that I tried to install.

ruby-install ruby 2.5.1

Warnings

compiling sprintf.c
In file included from sprintf.c:1254:
./vsnprintf.c:832:8: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
                            IS_PRI_EXTRA_MARK(fmt)) {
                            ^~~~~~~~~~~~~~~~~~~~~~
./vsnprintf.c:825:34: note: expanded from macro 'IS_PRI_EXTRA_MARK'
           strncmp((s)+1, PRI_EXTRA_MARK+1, \
                          ~~~~~~~~~~~~~~^~
./vsnprintf.c:832:8: note: use array indexing to silence this warning
./vsnprintf.c:825:34: note: expanded from macro 'IS_PRI_EXTRA_MARK'
           strncmp((s)+1, PRI_EXTRA_MARK+1, \
                                        ^
1 warning generated.
compiling vm.c
vm.c:2365:34: warning: expression does not compute the number of elements in this array; element type is 'const int', not 'VALUE' (aka 'unsigned long') [-Wsizeof-array-div]
                             sizeof(ec->machine.regs) / sizeof(VALUE));
                                    ~~~~~~~~~~~~~~~~  ^
vm.c:2365:34: note: place parentheses around the 'sizeof(VALUE)' expression to silence this warning
1 warning generated.
compiling closure.c
closure.c:264:14: warning: 'ffi_prep_closure' is deprecated [-Wdeprecated-declarations]
    result = ffi_prep_closure(pcl, cif, callback, (void *)self);
             ^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/ffi/ffi.h:348:18: note: 'ffi_prep_closure' has been explicitly marked deprecated here
  __attribute__((deprecated))
                 ^
1 warning generated.

Fail

compiling ossl_x509store.c
linking shared-object openssl.bundle
installing default openssl libraries
extracting ripper.y from ../.././parse.y
compiling compiler ripper.y
ripper.y:997.1-12: warning: deprecated directive: ‘%pure-parser’, use ‘%define api.pure’ [-Wdeprecated]
  997 | %pure-parser
      | ^~~~~~~~~~~~
      | %define api.pure
ripper.y: warning: fix-its can be applied.  Rerun with option '--update'. [-Wother]
generating eventids1.c from ../.././parse.y
generating eventids2table.c from ../.././ext/ripper/eventids2.c
compiling ripper.c
ripper.c:5340:14: warning: incompatible pointer types passing 'FILE *' (aka 'struct __sFILE *') to parameter of type 'struct parser_params *' [-Wincompatible-pointer-types]
  YYFPRINTF (yyo, "%s %s (",
             ^~~
../../node.h:529:45: note: passing argument to parameter 'parser' here
void rb_parser_printf(struct parser_params *parser, const char *fmt, ...);
                                            ^
ripper.c:5344:14: warning: incompatible pointer types passing 'FILE *' (aka 'struct __sFILE *') to parameter of type 'struct parser_params *' [-Wincompatible-pointer-types]
  YYFPRINTF (yyo, ": ");
             ^~~
../../node.h:529:45: note: passing argument to parameter 'parser' here
void rb_parser_printf(struct parser_params *parser, const char *fmt, ...);
                                            ^
ripper.c:5346:14: warning: incompatible pointer types passing 'FILE *' (aka 'struct __sFILE *') to parameter of type 'struct parser_params *' [-Wincompatible-pointer-types]
  YYFPRINTF (yyo, ")");
             ^~~
../../node.h:529:45: note: passing argument to parameter 'parser' here
void rb_parser_printf(struct parser_params *parser, const char *fmt, ...);
                                            ^
ripper.c:5539:12: error: use of undeclared identifier 'YYEMPTY'
  yychar = YYEMPTY; /* Cause a token to be read.  */
           ^
ripper.c:5630:23: error: redefinition of 'parser'
struct parser_params *parser;
                      ^
ripper.c:5468:32: note: previous definition is here
yyparse (struct parser_params *parser)
                               ^
ripper.c:5655:17: error: use of undeclared identifier 'YYEMPTY'
  if (yychar == YYEMPTY)
                ^
ripper.c:5667:22: error: use of undeclared identifier 'YYerror'
  else if (yychar == YYerror)
                     ^
ripper.c:5673:16: error: use of undeclared identifier 'YYUNDEF'
      yychar = YYUNDEF;
               ^
ripper.c:5712:12: error: use of undeclared identifier 'YYEMPTY'
  yychar = YYEMPTY;
           ^
ripper.c:11352:23: error: use of undeclared identifier 'YYEMPTY'
  yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
                      ^
ripper.c:11375:41: error: too many arguments provided to function-like macro invocation
                      yytoken, &yylval, &yylloc, parser);
                                        ^
ripper.c:5632:9: note: macro 'yydestruct' defined here
#define yydestruct(m, t, v) ruby_parser_yydestruct(m, t, v, parser)
        ^
ripper.c:11374:11: error: use of undeclared identifier 'yydestruct'
          yydestruct ("Error: discarding",
          ^
ripper.c:11376:20: error: use of undeclared identifier 'YYEMPTY'
          yychar = YYEMPTY;
                   ^
ripper.c:11430:57: error: too many arguments provided to function-like macro invocation
                  YY_ACCESSING_SYMBOL (yystate), yyvsp, yylsp, parser);
                                                        ^
ripper.c:5632:9: note: macro 'yydestruct' defined here
#define yydestruct(m, t, v) ruby_parser_yydestruct(m, t, v, parser)
        ^
ripper.c:11429:7: error: use of undeclared identifier 'yydestruct'
      yydestruct ("Error: popping",
      ^
ripper.c:11482:17: error: use of undeclared identifier 'YYEMPTY'
  if (yychar != YYEMPTY)
                ^
ripper.c:11488:37: error: too many arguments provided to function-like macro invocation
                  yytoken, &yylval, &yylloc, parser);
                                    ^
ripper.c:5632:9: note: macro 'yydestruct' defined here
#define yydestruct(m, t, v) ruby_parser_yydestruct(m, t, v, parser)
        ^
ripper.c:11487:7: error: use of undeclared identifier 'yydestruct'
      yydestruct ("Cleanup: discarding lookahead",
      ^
ripper.c:11497:57: error: too many arguments provided to function-like macro invocation
                  YY_ACCESSING_SYMBOL (+*yyssp), yyvsp, yylsp, parser);
                                                        ^
ripper.c:5632:9: note: macro 'yydestruct' defined here
#define yydestruct(m, t, v) ruby_parser_yydestruct(m, t, v, parser)
        ^
ripper.c:11496:7: error: use of undeclared identifier 'yydestruct'
      yydestruct ("Cleanup: popping",
      ^
ripper.y:12089:5: warning: division by zero is undefined [-Wdivision-by-zero]
    rb_scan_args(argc, argv, "12", &src, &fname, &lineno);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:2182:9: note: expanded from macro 'rb_scan_args'
        rb_scan_args0(argc,argvp,fmt,\
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:2355:9: note: expanded from macro 'rb_scan_args0'
                     (rb_scan_args_verify(fmt, varc), vars))
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:2240:11: note: expanded from macro 'rb_scan_args_verify'
        verify = rb_scan_args_verify_count(fmt, varc); \
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: (skipping 4 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
../.././include/ruby/ruby.h:2206:6: note: expanded from macro 'rb_scan_args_count_hash'
     rb_scan_args_count_block(fmt, ofs, varc, vari) : \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:2201:6: note: expanded from macro 'rb_scan_args_count_block'
     rb_scan_args_count_end(fmt, ofs, varc, vari) : \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:2197:12: note: expanded from macro 'rb_scan_args_count_end'
    ((vari)/(!fmt[ofs] || rb_scan_args_bad_format(fmt)))
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ripper.y:12089:5: warning: division by zero is undefined [-Wdivision-by-zero]
    rb_scan_args(argc, argv, "12", &src, &fname, &lineno);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:2182:9: note: expanded from macro 'rb_scan_args'
        rb_scan_args0(argc,argvp,fmt,\
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:2355:9: note: expanded from macro 'rb_scan_args0'
                     (rb_scan_args_verify(fmt, varc), vars))
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:2240:11: note: expanded from macro 'rb_scan_args_verify'
        verify = rb_scan_args_verify_count(fmt, varc); \
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: (skipping 4 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
../.././include/ruby/ruby.h:2206:6: note: expanded from macro 'rb_scan_args_count_hash'
     rb_scan_args_count_block(fmt, ofs, varc, vari) : \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:2202:6: note: expanded from macro 'rb_scan_args_count_block'
     rb_scan_args_count_end(fmt, ofs+1, varc, vari+1))
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:2197:12: note: expanded from macro 'rb_scan_args_count_end'
    ((vari)/(!fmt[ofs] || rb_scan_args_bad_format(fmt)))
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ripper.y:12089:5: warning: division by zero is undefined [-Wdivision-by-zero]
    rb_scan_args(argc, argv, "12", &src, &fname, &lineno);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:2182:9: note: expanded from macro 'rb_scan_args'
        rb_scan_args0(argc,argvp,fmt,\
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:2355:9: note: expanded from macro 'rb_scan_args0'
                     (rb_scan_args_verify(fmt, varc), vars))
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:2240:11: note: expanded from macro 'rb_scan_args_verify'
        verify = rb_scan_args_verify_count(fmt, varc); \
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: (skipping 4 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
../.././include/ruby/ruby.h:2207:6: note: expanded from macro 'rb_scan_args_count_hash'
     rb_scan_args_count_block(fmt, ofs+1, varc, vari+1))
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:2201:6: note: expanded from macro 'rb_scan_args_count_block'
     rb_scan_args_count_end(fmt, ofs, varc, vari) : \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:2197:12: note: expanded from macro 'rb_scan_args_count_end'
    ((vari)/(!fmt[ofs] || rb_scan_args_bad_format(fmt)))
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ripper.y:12089:5: warning: division by zero is undefined [-Wdivision-by-zero]
    rb_scan_args(argc, argv, "12", &src, &fname, &lineno);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:2182:9: note: expanded from macro 'rb_scan_args'
        rb_scan_args0(argc,argvp,fmt,\
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:2355:9: note: expanded from macro 'rb_scan_args0'
                     (rb_scan_args_verify(fmt, varc), vars))
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:2240:11: note: expanded from macro 'rb_scan_args_verify'
        verify = rb_scan_args_verify_count(fmt, varc); \
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: (skipping 4 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
../.././include/ruby/ruby.h:2206:6: note: expanded from macro 'rb_scan_args_count_hash'
     rb_scan_args_count_block(fmt, ofs, varc, vari) : \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:2201:6: note: expanded from macro 'rb_scan_args_count_block'
     rb_scan_args_count_end(fmt, ofs, varc, vari) : \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:2197:12: note: expanded from macro 'rb_scan_args_count_end'
    ((vari)/(!fmt[ofs] || rb_scan_args_bad_format(fmt)))
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ripper.y:12089:5: warning: division by zero is undefined [-Wdivision-by-zero]
    rb_scan_args(argc, argv, "12", &src, &fname, &lineno);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:2182:9: note: expanded from macro 'rb_scan_args'
        rb_scan_args0(argc,argvp,fmt,\
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:2355:9: note: expanded from macro 'rb_scan_args0'
                     (rb_scan_args_verify(fmt, varc), vars))
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:2240:11: note: expanded from macro 'rb_scan_args_verify'
        verify = rb_scan_args_verify_count(fmt, varc); \
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: (skipping 4 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
../.././include/ruby/ruby.h:2206:6: note: expanded from macro 'rb_scan_args_count_hash'
     rb_scan_args_count_block(fmt, ofs, varc, vari) : \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:2201:6: note: expanded from macro 'rb_scan_args_count_block'
     rb_scan_args_count_end(fmt, ofs, varc, vari) : \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:2197:12: note: expanded from macro 'rb_scan_args_count_end'
    ((vari)/(!fmt[ofs] || rb_scan_args_bad_format(fmt)))
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ripper.y:12089:5: warning: division by zero is undefined [-Wdivision-by-zero]
    rb_scan_args(argc, argv, "12", &src, &fname, &lineno);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:2182:9: note: expanded from macro 'rb_scan_args'
        rb_scan_args0(argc,argvp,fmt,\
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:2355:9: note: expanded from macro 'rb_scan_args0'
                     (rb_scan_args_verify(fmt, varc), vars))
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:2240:11: note: expanded from macro 'rb_scan_args_verify'
        verify = rb_scan_args_verify_count(fmt, varc); \
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: (skipping 5 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
../.././include/ruby/ruby.h:2206:6: note: expanded from macro 'rb_scan_args_count_hash'
     rb_scan_args_count_block(fmt, ofs, varc, vari) : \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:2201:6: note: expanded from macro 'rb_scan_args_count_block'
     rb_scan_args_count_end(fmt, ofs, varc, vari) : \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:2197:12: note: expanded from macro 'rb_scan_args_count_end'
    ((vari)/(!fmt[ofs] || rb_scan_args_bad_format(fmt)))
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9 warnings and 17 errors generated.
make[2]: *** [ripper.o] Error 1
make[1]: *** [ext/ripper/all] Error 2
make: *** [build-ext] Error 2
!!! Compiling ruby 2.5.1 failed!
postmodern commented 3 years ago

ruby-install only installs the rubies as-is. If older rubies are no longer maintained and not compatible with the current versions of gcc, openssl, etc, then they will fail to compile. Same thing would happen if you attempted to compile the ruby version manually. You would have to pass configuration options in to compile them against older versions of openssl, gcc, etc. It's much easier to simply upgrade to a newer Ruby version that's currently maintained by upstream.

mprokopov commented 3 years ago

same for ruby 2.6.8 on macos Big Sur 11.6 ruby-install v0.8.3

To1ne commented 2 years ago

Consider using a patch to make it work.

In my case I've used the following patch:

diff --git a/parse.h b/parse.h
index b65ad8f..174e702 100644
--- a/parse.h
+++ b/parse.h
@@ -49,7 +49,10 @@ extern int yydebug;
 # define YYTOKENTYPE
   enum yytokentype
   {
+    YYEMPTY = -2,
     END_OF_INPUT = 0,
+    YYerror = 256,                 /* error  */
+    YYUNDEF = 257,                 /* "invalid token"  */
     keyword_class = 258,
     keyword_module = 259,
     keyword_def = 260,

I saved it to disk and passed it to ruby-install -p /path/to/patch.patch ruby x.y.z.

lacostenycoder commented 1 year ago

ripper

Can you help point us to where to look for patch.patch ?

To1ne commented 1 year ago

@lacostenycoder If you are talking to me, I just created a gist you can use directly:

ruby-install -p https://gist.githubusercontent.com/To1ne/a21b5f38edeada462e6e2eba4582beec/raw/72322afd86f855ce8c2a2bb7888ecb6db4b5fcc0/ruby-install.patch ruby 2.5.1

I cannot guarantee though it will work for the version you're trying to install.

lacostenycoder commented 1 year ago

@To1ne thanks but it still doesn't work.

To1ne commented 1 year ago

@lacostenycoder What's the exact error?

AhlamHani commented 1 year ago

same issue here, not resolved yet!!

lacostenycoder commented 1 year ago

The issue seemed related to the version of Ubuntu 22.04, reverted to Ubuntu 20.04.5 LTS and issue was resolved.

AdrienGiboire commented 1 year ago

@lacostenycoder If you are talking to me, I just created a gist you can use directly:

ruby-install -p https://gist.githubusercontent.com/To1ne/a21b5f38edeada462e6e2eba4582beec/raw/72322afd86f855ce8c2a2bb7888ecb6db4b5fcc0/ruby-install.patch ruby 2.5.1

I cannot guarantee though it will work for the version you're trying to install.

Thank you! That saved me!