使用Rvm在Ubuntu22.04系统中无法安装ruby2.7版本,因为Ubuntu22.04使用了OpenSSl3.0而非1.1.x系列版本所以必须使用ruby3.0以上版本。
报错如下:
cc1: note: unrecognized command-line option ‘-Wno-parentheses-equality’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-constant-logical-operand’ may have been intended to silence earlier diagnostics
compiling raddrinfo.c
cc1: note: unrecognized command-line option ‘-Wno-self-assign’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-parentheses-equality’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-constant-logical-operand’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-self-assign’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-parentheses-equality’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-constant-logical-operand’ may have been intended to silence earlier diagnostics
make[2]: 离开目录“/home/k/.rvm/src/ruby-2.7.2/ext/json/generator”
compiling ifaddr.c
In file included from option.c:1:
rubysocket.h:118:36: warning: argument 2 of type ‘char *’ declared as a pointer [-Warray-parameter=]
118 | char *if_indextoname(unsigned int, char *);
| ^~~~~~
In file included from rubysocket.h:97,
from option.c:1:
/usr/include/net/if.h:195:35: note: previously declared as an array ‘char[16]’
195 | char __ifname[IF_NAMESIZE]) __THROW
| ~~~~~^~~~~~~~~~~~~~~~~~~~~
installing default socket libraries
In file included from raddrinfo.c:11:
rubysocket.h:118:36: warning: argument 2 of type ‘char *’ declared as a pointer [-Warray-parameter=]
118 | char *if_indextoname(unsigned int, char *);
| ^~~~~~
In file included from rubysocket.h:97,
from raddrinfo.c:11:
/usr/include/net/if.h:195:35: note: previously declared as an array ‘char[16]’
195 | char __ifname[IF_NAMESIZE]) __THROW
| ~~~~~^~~~~~~~~~~~~~~~~~~~~
In file included from ancdata.c:1:
rubysocket.h:118:36: warning: argument 2 of type ‘char *’ declared as a pointer [-Warray-parameter=]
118 | char *if_indextoname(unsigned int, char *);
| ^~~~~~
In file included from rubysocket.h:97,
from ancdata.c:1:
/usr/include/net/if.h:195:35: note: previously declared as an array ‘char[16]’
195 | char __ifname[IF_NAMESIZE]) __THROW
| ~~~~~^~~~~~~~~~~~~~~~~~~~~
linking shared-object bigdecimal.so
In file included from ifaddr.c:1:
rubysocket.h:118:36: warning: argument 2 of type ‘char *’ declared as a pointer [-Warray-parameter=]
118 | char *if_indextoname(unsigned int, char *);
| ^~~~~~
In file included from rubysocket.h:97,
from ifaddr.c:1:
/usr/include/net/if.h:195:35: note: previously declared as an array ‘char[16]’
195 | char __ifname[IF_NAMESIZE]) __THROW
| ~~~~~^~~~~~~~~~~~~~~~~~~~~
make[2]: 离开目录“/home/k/.rvm/src/ruby-2.7.2/ext/bigdecimal”
cc1: note: unrecognized command-line option ‘-Wno-self-assign’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-parentheses-equality’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-constant-logical-operand’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-self-assign’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-parentheses-equality’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-constant-logical-operand’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-self-assign’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-parentheses-equality’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-constant-logical-operand’ may have been intended to silence earlier diagnostics
linking shared-object zlib.so
make[2]: 离开目录“/home/k/.rvm/src/ruby-2.7.2/ext/zlib”
cc1: note: unrecognized command-line option ‘-Wno-self-assign’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-parentheses-equality’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-constant-logical-operand’ may have been intended to silence earlier diagnostics
linking shared-object socket.so
make[2]: 离开目录“/home/k/.rvm/src/ruby-2.7.2/ext/socket”
make[1]: 离开目录“/home/k/.rvm/src/ruby-2.7.2”
make: *** [uncommon.mk:295:build-ext] 错误 2
++ return 2
如果必须安装旧版的情况加使用
rvm pkg install openssl
rvm reinstall 2.7.6 --with-openssl-dir=/home/$(whoami)/.rvm/usr