在Ubuntu 18.04上安装Ruby 2.3.x会在安装过程结束时导致错误

flvlnr44  于 2023-02-08  发布在  Ruby
关注(0)|答案(9)|浏览(135)

我最近将我的系统更新到了Ubuntu 18.04 LTS,从那时起,Ruby版本似乎已经更新到了2.5。问题是,当尝试部署使用Capistrano的项目时,它现在会抱怨没有找到Ruby 2.3。
当运行rvm install 2.3时,它试图安装的版本是2. 3. 4,显示的第一个错误是“Error running '__rvm_make -j4'“。我试图删除RVM并重新安装,但没有解决这个问题。日志是一个巨大的文件,什么也没有告诉我。
然后,我尝试使用rbenv,这也会导致错误:

Installing ruby-2.3.4...

BUILD FAILED (Ubuntu 18.04 using ruby-build 20180424)

Inspect or clean up the working tree at /tmp/ruby-build.20180429172721.16258
Results logged to /tmp/ruby-build.20180429172721.16258.log

Last 10 log lines:
installing default nkf libraries
linking shared-object objspace.so
make[2]: Leaving directory '/tmp/ruby-build.20180429172721.16258/ruby-2.3.4/ext/objspace'
linking shared-object pathname.so
make[2]: Leaving directory '/tmp/ruby-build.20180429172721.16258/ruby-2.3.4/ext/pathname'
linking shared-object nkf.so
make[2]: Leaving directory '/tmp/ruby-build.20180429172721.16258/ruby-2.3.4/ext/nkf'
make[1]: Leaving directory '/tmp/ruby-build.20180429172721.16258/ruby-2.3.4'
uncommon.mk:203: recipe for target 'build-ext' failed
make: *** [build-ext] Error 2

日志文件也有一个愚蠢的巨型日志文件。
下一次尝试从源安装,在文件夹中运行make后,出现错误:

openssl_missing.h:78:35: error: macro "EVP_MD_CTX_create" passed 1 arguments, but takes just 0
 EVP_MD_CTX *EVP_MD_CTX_create(void);
                                   ^
In file included from /usr/include/openssl/x509.h:23:0,
                 from /usr/include/openssl/x509_vfy.h:17,
                 from openssl_missing.c:15:
openssl_missing.h:82:6: error: expected declaration specifiers or ‘...’ before ‘(’ token
 void EVP_MD_CTX_init(EVP_MD_CTX *ctx);
      ^
openssl_missing.h:90:6: error: expected declaration specifiers or ‘...’ before ‘(’ token
 void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx);
      ^
openssl_missing.c:39:23: error: macro "EVP_MD_CTX_create" passed 1 arguments, but takes just 0
 EVP_MD_CTX_create(void)
                       ^
openssl_missing.c:40:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
 {
 ^
openssl_missing.c: In function ‘EVP_MD_CTX_cleanup’:
openssl_missing.c:55:27: error: invalid application of ‘sizeof’ to incomplete type ‘EVP_MD_CTX {aka struct evp_md_ctx_st}’
     memset(ctx, 0, sizeof(EVP_MD_CTX));
                           ^~~~~~~~~~
In file included from /usr/include/openssl/x509.h:23:0,
                 from /usr/include/openssl/x509_vfy.h:17,
                 from openssl_missing.c:15:
openssl_missing.c: At top level:
openssl_missing.c:63:1: error: expected declaration specifiers or ‘...’ before ‘(’ token
 EVP_MD_CTX_destroy(EVP_MD_CTX *ctx)
 ^
openssl_missing.c:72:1: error: expected declaration specifiers or ‘...’ before ‘(’ token
 EVP_MD_CTX_init(EVP_MD_CTX *ctx)
 ^
openssl_missing.c: In function ‘HMAC_CTX_init’:
openssl_missing.c:82:25: error: dereferencing pointer to incomplete type ‘HMAC_CTX {aka struct hmac_ctx_st}’
     EVP_MD_CTX_init(&ctx->i_ctx);
                         ^
openssl_missing.c: In function ‘HMAC_CTX_cleanup’:
openssl_missing.c:95:27: error: invalid application of ‘sizeof’ to incomplete type ‘HMAC_CTX {aka struct hmac_ctx_st}’
     memset(ctx, 0, sizeof(HMAC_CTX));
                           ^~~~~~~~
Makefile:301: recipe for target 'openssl_missing.o' failed
make[2]: *** [openssl_missing.o] Error 1
make[2]: Leaving directory '/home/gabriel/Downloads/ruby-2.3.7/ext/openssl'
exts.mk:212: recipe for target 'ext/openssl/all' failed
make[1]: *** [ext/openssl/all] Error 2
make[1]: Leaving directory '/home/gabriel/Downloads/ruby-2.3.7'
uncommon.mk:203: recipe for target 'build-ext' failed
make: *** [build-ext] Error 2

要安装它需要做些什么?或者不可能再安装这些旧版本了?

oprakyz7

oprakyz71#

我有一个同样的问题,虽然它似乎问题是在gcc,在我的情况下,问题是在libssl-dev,这是什么帮助我:

sudo apt purge libssl-dev && sudo apt install libssl1.0-dev

我使用rbenv。如果您使用rvm,在运行之前的命令后可能会遇到问题:

/usr/share/rvm/scripts/base: No such file or directory

我建议试试rbenv,安装libssl1.0-dev后,一切都完美无瑕。

guz6ccqo

guz6ccqo2#

cd ~/src
 wget https://www.openssl.org/source/openssl-1.0.2s.tar.gz
 tar xvzf openssl-1.0.2s.tar.gz
 cd openssl-1.0.2s
 mkdir ~/.rubies/openssl-1.0.2s
 ./config --prefix=$HOME/.rubies/openssl-1.0.2s --shared
 make
 make install
 RUBY_CONFIGURE_OPTS=--with-openssl-dir=$HOME/.rubies/openssl-1.0.2s rbenv install 2.3.1

为我工作

ibps3vxo

ibps3vxo3#

也可以与RVM一起使用:
1. sudo apt purge libssl-dev && sudo apt install libssl1.0-dev 2. rvm install 2.3.5 --autolibs=disable
您必须手动安装RVM依赖项,否则,在启用autolibs的情况下,RVM将尝试更新系统依赖项和libssl-dev(您在第一步中降级的)。如果您不想手动安装依赖项,您可以尝试在启用autolibs的情况下安装Ruby,安装将失败,此时您已经安装了依赖项,因此您可以从步骤1开始重复所有操作来降级libssl。

qlfbtfca

qlfbtfca4#

已通过更新rvm rvm get head解决该问题

iyzzxitl

iyzzxitl5#

要在Ubuntu 20.04上安装libssl-dev,请使用以下命令来执行此操作,它对我很有效:sudo apt install libssl-dev/focal

gab6jxml

gab6jxml6#

我也有类似的问题。显然ruby版本〈2.3与openssl 1.1是不兼容的,openssl 1.1是Ubuntu最新版本的。在这里我找到了一个ArchLinux的解决方案,我尝试了这个解决方案,ruby编译得很好,但是我在rails中有很多内存错误,那么我现在唯一的解决方案是使用ruby〉2.4,直到我找到其他解决方案。

vfh0ocws

vfh0ocws7#

OpenSSL 1.1与Ruby 2.3.x不兼容请检查此问题here
我使用以下命令解决了Mac上的问题。

rvm reinstall ruby-2.3.8 --with-openssl-dir=`brew --prefix openssl@1.0` --debug

对于ubuntu,您可以通过安装openssl@1.0以类似的方式解决此问题

xxe27gdn

xxe27gdn8#

在这篇文章发表之前,在Ubuntu 22.04上,我使用rbenv安装了一个旧版本的Ruby 2.7作为OSS贡献:

brew install openssl@1.1
RUBY_CONFIGURE_OPTS=--with-openssl-dir=`brew --prefix openssl@1.1` rbenv install 2.7.6
kmpatx3s

kmpatx3s9#

用rvm试试这个

rvm install ruby-2.3.4

或者尝试https://gorails.com/setup/ubuntu/18.04
您可能缺少所需的库,因此请尝试先运行这些库:

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev nodejs yarn

相关问题