![](/img/trans.png)
[英]Unable to install Phusion Passenger on Ubuntu Server 18.04
[英]Unable to install ruby from source in ubuntu 18.04 docker image
I am installing ruby 2.7.2 on a docker container that uses ubuntu:18.04.c I first tried to install rbenv but it did not offer the version I need so I resorted to installing from source. 但是,從源代碼安裝時, make install
不會通過。 這是我用來從源代碼https://coderwall.com/p/3u__pq/install-ruby-from-source-on-ubuntu安裝的方法,這就是我試圖解決我的問題無濟於事的方法 無法找到package openssl-dev 。 我也無法安裝 rvm,因為它沒有被 bash 拾取。
docker文件
#
# Ubuntu Dockerfile
#
# https://github.com/dockerfile/ubuntu
#
# Pull base image.
FROM ubuntu:18.04
ARG APP_NAME=<appname>
# Install.
RUN \
apt-get update && \
apt-get -y upgrade && \
apt-get install -y build-essential openssl libssl-dev zlib1g-dev&& \
apt-get install -y software-properties-common && \
apt-get install -y byobu curl git htop man unzip vim wget openssl libffi-dev &&\
rm -rf /var/lib/apt/lists/*
RUN \
wget https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.2.tar.bz2 &&\
tar -xf ruby-2.7.2.tar.bz2
RUN cd ruby-2.7.2
RUN pwd
RUN ./ruby-2.7.2/configure --prefix=/my/ruby/dir
RUN make
RUN make install
# Set environment variables.
EXPOSE 5000
ENV HOME /root
ENV PATH="${PATH}:/my/ruby/dir"
# Define working directory.
WORKDIR /root
COPY ${APP_NAME}/ ./${APP_NAME}/
# Define default command.
CMD ["bash"]
當我進行安裝時,它抱怨沒有安裝 openssl 但是我確實 apt install openssl
*** Following extensions are not compiled:
openssl:
Could not be configured. It will not be installed.
/ruby-2.7.2/ext/openssl/extconf.rb:97: OpenSSL library could not be found. You might want to use --with-openssl-dir=<dir> option to specify the prefix where OpenSSL is installed.
Check ext/openssl/mkmf.log for more details.
dbm:
Could not be configured. It will not be installed.
Check ext/dbm/mkmf.log for more details.
readline:
Could not be configured. It will not be installed.
/ruby-2.7.2/ext/readline/extconf.rb:62: Neither readline nor libedit was found
Check ext/readline/mkmf.log for more details.
gdbm:
Could not be configured. It will not be installed.
Check ext/gdbm/mkmf.log for more details.
zlib:
Could not be configured. It will not be installed.
Check ext/zlib/mkmf.log for more details.
*** Fix the problems, then remove these directories and try again if you want.
稍后這是錯誤消息
Traceback (most recent call last):
11: from ./tool/rbinstall.rb:947:in `<main>'
10: from ./tool/rbinstall.rb:947:in `each'
9: from ./tool/rbinstall.rb:950:in `block in <main>'
8: from ./tool/rbinstall.rb:799:in `block in <main>'
7: from ./tool/rbinstall.rb:835:in `install_default_gem'
6: from ./tool/rbinstall.rb:835:in `each'
5: from ./tool/rbinstall.rb:845:in `block in install_default_gem'
4: from ./tool/rbinstall.rb:279:in `open_for_install'
3: from ./tool/rbinstall.rb:846:in `block (2 levels) in install_default_gem'
2: from /ruby-2.7.2/lib/rubygems/specification.rb:2430:in `to_ruby'
1: from /ruby-2.7.2/lib/rubygems/core_ext/kernel_require.rb:92:in `require'
/ruby-2.7.2/lib/rubygems/core_ext/kernel_require.rb:92:in `require': cannot load such file -- openssl (LoadError)
我認為你的問題在這里
RUN cd ruby-2.7.2
RUN pwd
RUN ./ruby-2.7.2/configure --prefix=/my/ruby/dir
你 cd 進入ruby-2.7.2
-2.7.2 然后嘗試./ruby-2.7.2/configure...
但你已經在目錄ruby-2.7.2
-2.7.2 所以這一行
RUN./ruby-2.7.2/configure --prefix=/my/ruby/dir
應該失敗。
嘗試更換
RUN./ruby-2.7.2/configure --prefix=/my/ruby/dir
和
RUN./configure --prefix=/my/ruby/dir
您也可以通過刪除以下行來清理您的Docerfile
RUN pwd
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.