无法在Ubuntu 16.04中使用rbenv 2.3.1安装Ruby

时间:2022-08-03 23:40:17

While installing ruby with rbenv for Ubuntu 16.04 error regarding the ruby build is shown. I've tried completely removing the rbenv and again re-installing rbenv, but all i get the following error.

使用rbenv安装ruby以获取有关ruby构建的Ubuntu 16.04错误。我已经尝试完全删除rbenv并再次重新安装rbenv,但所有我得到以下错误。

I've followed DigitalOcean's procedure for installing the rbenv as in here, and followed steps listed here for ruby_build. I've also installed all dependencies required for the build.

我按照DigitalOcean的程序安装了rbenv,如下所示,并按照此处列出的ruby_build步骤进行操作。我还安装了构建所需的所有依赖项。

Still after times of uninstall and install of rbenv problem is the same.

在卸载和安装rbenv问题之后仍然是一样的。

   ~$ rbenv install 2.3.1
   Downloading ruby-2.3.1.tar.bz2...
   -> https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.1.tar.bz2
   Installing ruby-2.3.1...

   BUILD FAILED (Ubuntu 16.04 using ruby-build 20170726-2-g254728e)

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

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

Result of cat /tmp/ruby-build.20170818162042.1074.log

cat /tmp/ruby-build.20170818162042.1074.log的结果

In file included from ossl.h:57:0,
                 from ossl_bn.c:11:
/usr/include/openssl/asn1_mac.h:10:2: error: #error "This file is obsolete; please update your software."
 #error "This file is obsolete; please update your software."
  ^
In file included from ossl.h:221:0,
                 from ossl_bn.c:11:
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/x509v3.h:14,
                 from ossl.h:58,
                 from ossl_bn.c:11:
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);
      ^
ossl_bn.c: In function ‘ossl_bn_size’:
ossl_bn.c:43:19: error: invalid application of ‘sizeof’ to incomplete type ‘BIGNUM {aka struct bignum_st}’
     return sizeof(BIGNUM);
                   ^
ossl_bn.c: In function ‘ossl_bn_s_generate_prime’:
ossl_bn.c:769:5: warning: ‘BN_generate_prime’ is deprecated [-Wdeprecated-declarations]
     if (!BN_generate_prime(result, num, safe, add, rem, NULL, NULL)) {
     ^
In file included from /usr/include/openssl/bn.h:31:0,
                 from /usr/include/openssl/asn1.h:24,
                 from /usr/include/openssl/objects.h:916,
                 from /usr/include/openssl/evp.h:27,
                 from /usr/include/openssl/x509.h:23,
                 from /usr/include/openssl/x509v3.h:14,
                 from ossl.h:58,
                 from ossl_bn.c:11:
/usr/include/openssl/bn.h:285:1: note: declared here
 DEPRECATEDIN_0_9_8(BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe,
 ^
ossl_bn.c: In function ‘ossl_bn_is_prime’:
ossl_bn.c:877:5: warning: ‘BN_is_prime’ is deprecated [-Wdeprecated-declarations]
     switch (BN_is_prime(bn, checks, NULL, ossl_bn_ctx, NULL)) {
     ^
In file included from /usr/include/openssl/bn.h:31:0,
                 from /usr/include/openssl/asn1.h:24,
                 from /usr/include/openssl/objects.h:916,
                 from /usr/include/openssl/evp.h:27,
                 from /usr/include/openssl/x509.h:23,
                 from /usr/include/openssl/x509v3.h:14,
                 from ossl.h:58,
                 from ossl_bn.c:11:
/usr/include/openssl/bn.h:291:1: note: declared here
 DEPRECATEDIN_0_9_8(int
 ^
ossl_bn.c: In function ‘ossl_bn_is_prime_fasttest’:
ossl_bn.c:916:5: warning: ‘BN_is_prime_fasttest’ is deprecated [-Wdeprecated-declarations]
     switch (BN_is_prime_fasttest(bn, checks, NULL, ossl_bn_ctx, NULL, do_trial_division)) {
     ^
In file included from /usr/include/openssl/bn.h:31:0,
                 from /usr/include/openssl/asn1.h:24,
                 from /usr/include/openssl/objects.h:916,
                 from /usr/include/openssl/evp.h:27,
                 from /usr/include/openssl/x509.h:23,
                 from /usr/include/openssl/x509v3.h:14,
                 from ossl.h:58,
                 from ossl_bn.c:11:
/usr/include/openssl/bn.h:295:1: note: declared here
 DEPRECATEDIN_0_9_8(int
 ^
ossl_bn.c: In function ‘ossl_bn_size’:
ossl_bn.c:44:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
Makefile:301: recipe for target 'ossl_bn.o' failed

2 个解决方案

#1


1  

I was able to successfully build docker image with the following Dockerfile

我能够使用以下Dockerfile成功构建docker镜像

FROM ubuntu:16.04

ENV RBENV_ROOT=/usr/local/rbenv
ENV PATH=$RBENV_ROOT/bin:$RBENV_ROOT/shims:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential \
    cmake curl git zlib1g-dev \
    libssl-dev libreadline-dev \
    libyaml-dev libxml2-dev \
    libxslt-dev libsqlite3-dev \
    python-dev libxml2-dev \
    libxslt-dev groff zip \
    pkg-config ca-certificates \
    && apt-get clean

# Install rbenv
RUN git clone https://github.com/sstephenson/rbenv.git /usr/local/rbenv \
    && echo '# rbenv setup' > /etc/profile.d/rbenv.sh \
    && echo 'export RBENV_ROOT=/usr/local/rbenv' >> /etc/profile.d/rbenv.sh \
    && echo 'export PATH="$RBENV_ROOT/bin:$PATH"' >> /etc/profile.d/rbenv.sh \
    && echo 'eval "$(rbenv init -)"' >> /etc/profile.d/rbenv.sh \
    && chmod +x /etc/profile.d/rbenv.sh

ENV RUBY_VERSION=2.3.1

# install ruby-build
RUN mkdir /usr/local/rbenv/plugins \
    && git clone https://github.com/sstephenson/ruby-build.git /usr/local/rbenv/plugins/ruby-build \
    && /usr/local/rbenv/plugins/ruby-build/install.sh \
    && rbenv install ${RUBY_VERSION} \
    && rbenv global ${RUBY_VERSION} \
    && gem install bundler \
    && rbenv rehash

Some tests

一些测试

$ docker run -it --rm test rbenv version
2.3.1 (set by /usr/local/rbenv/version)

$ docker run -it --rm test ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]

#2


0  

This is a known compatibility issue with openssl and ruby 2.3.x.

这是openssl和ruby 2.3.x的已知兼容性问题。

The openssl extension of Ruby version before 2.4 is not compatible with OpenSSL 1.1.x. At the moment, most Linux distributions that come with OpenSSL 1.1.0 have a separate package for OpenSSL 1.0.x.

2.4之前的Ruby版本的openssl扩展与OpenSSL 1.1.x不兼容。目前,OpenSSL 1.1.0附带的大多数Linux发行版都有一个单独的OpenSSL 1.0.x包。

You need to install the earlier version of OpenSSL or use ruby 2.4.x.

您需要安装早期版本的OpenSSL或使用ruby 2.4.x.

full description and solution here

完整的描述和解决方案

#1


1  

I was able to successfully build docker image with the following Dockerfile

我能够使用以下Dockerfile成功构建docker镜像

FROM ubuntu:16.04

ENV RBENV_ROOT=/usr/local/rbenv
ENV PATH=$RBENV_ROOT/bin:$RBENV_ROOT/shims:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential \
    cmake curl git zlib1g-dev \
    libssl-dev libreadline-dev \
    libyaml-dev libxml2-dev \
    libxslt-dev libsqlite3-dev \
    python-dev libxml2-dev \
    libxslt-dev groff zip \
    pkg-config ca-certificates \
    && apt-get clean

# Install rbenv
RUN git clone https://github.com/sstephenson/rbenv.git /usr/local/rbenv \
    && echo '# rbenv setup' > /etc/profile.d/rbenv.sh \
    && echo 'export RBENV_ROOT=/usr/local/rbenv' >> /etc/profile.d/rbenv.sh \
    && echo 'export PATH="$RBENV_ROOT/bin:$PATH"' >> /etc/profile.d/rbenv.sh \
    && echo 'eval "$(rbenv init -)"' >> /etc/profile.d/rbenv.sh \
    && chmod +x /etc/profile.d/rbenv.sh

ENV RUBY_VERSION=2.3.1

# install ruby-build
RUN mkdir /usr/local/rbenv/plugins \
    && git clone https://github.com/sstephenson/ruby-build.git /usr/local/rbenv/plugins/ruby-build \
    && /usr/local/rbenv/plugins/ruby-build/install.sh \
    && rbenv install ${RUBY_VERSION} \
    && rbenv global ${RUBY_VERSION} \
    && gem install bundler \
    && rbenv rehash

Some tests

一些测试

$ docker run -it --rm test rbenv version
2.3.1 (set by /usr/local/rbenv/version)

$ docker run -it --rm test ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]

#2


0  

This is a known compatibility issue with openssl and ruby 2.3.x.

这是openssl和ruby 2.3.x的已知兼容性问题。

The openssl extension of Ruby version before 2.4 is not compatible with OpenSSL 1.1.x. At the moment, most Linux distributions that come with OpenSSL 1.1.0 have a separate package for OpenSSL 1.0.x.

2.4之前的Ruby版本的openssl扩展与OpenSSL 1.1.x不兼容。目前,OpenSSL 1.1.0附带的大多数Linux发行版都有一个单独的OpenSSL 1.0.x包。

You need to install the earlier version of OpenSSL or use ruby 2.4.x.

您需要安装早期版本的OpenSSL或使用ruby 2.4.x.

full description and solution here

完整的描述和解决方案