不能在 Alpine Linux 上要求 ruby gsl
Can't require ruby gsl on Alpine Linux
在 docker 图片和 运行 ruby 代码中我是 运行 高山。这成功安装了所有软件包,但是当我尝试 require gsl 时失败。
这是 Dockerfile:
FROM alpine:3.4
RUN apk upgrade --update \
&& apk add libatomic readline readline-dev libxml2 libxml2-dev \
libxslt libxslt-dev zlib-dev zlib ruby yaml \
yaml-dev libffi-dev build-base git nodejs \
ruby-io-console ruby-irb ruby-json ruby-rake \
make gsl gsl-dev \
gcc g++ libffi-dev ruby-dev tzdata
RUN gsl-config --cflags
RUN gem install --no-document nmatrix gsl
ADD scripts/gsl-test.rb test.rb
RUN ruby test.rb
测试文件为:
require 'gsl'
运行 docker 构建。产生以下输出:
Sending build context to Docker daemon 20 MB
Step 0 : FROM alpine:3.4
---> ad84c222f6a3
Step 1 : RUN apk upgrade --update && apk add libatomic readline readline-dev libxml2 libxml2-dev libxslt libxslt-dev zlib-dev zlib ruby yaml yaml-dev libffi-dev build-base git nodejs ruby-io-console ruby-irb ruby-json ruby-rake make gsl gsl-dev gcc g++ libffi-dev ruby-dev tzdata
---> Using cache
---> b7f66d6f2bd7
Step 2 : RUN gsl-config --cflags
---> Using cache
---> b5acc8868a74
Step 3 : RUN gem install --no-document nmatrix gsl
---> Using cache
---> 2623683a706e
Step 4 : ADD scripts/gsl-test.rb test.rb
---> e4388f952198
Removing intermediate container 743340a3be60
Step 5 : RUN ruby test.rb
---> Running in c53a34ece153
/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': Error relocating /usr/lib/ruby/gems/2.3.0/gems/gsl-2.1.0.1/lib/gsl_native.so: gsl_multifit_fdfsolver_jac: symbol not found - /usr/lib/ruby/gems/2.3.0/gems/gsl-2.1.0.1/lib/gsl_native.so (LoadError)
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/lib/ruby/gems/2.3.0/gems/backports-3.6.8/lib/backports/std_lib.rb:9:in `require_with_backports'
from /usr/lib/ruby/gems/2.3.0/gems/gsl-2.1.0.1/lib/gsl.rb:11:in `<top (required)>'
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `require'
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `rescue in require'
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:40:in `require'
from test.rb:1:in `<main>'
The command '/bin/sh -c ruby test.rb' returned a non-zero code: 1
如有任何帮助,我们将不胜感激。
我认为问题是您 运行 gsl 版本 1.16 然后 运行 最新的 gsl gem (2.1.0.1)。如果您强制 gem 安装以匹配 gsl 版本:
gem install --no-document gsl -v 1.16.0.6
它应该能很好地工作。
在 docker 图片和 运行 ruby 代码中我是 运行 高山。这成功安装了所有软件包,但是当我尝试 require gsl 时失败。
这是 Dockerfile:
FROM alpine:3.4
RUN apk upgrade --update \
&& apk add libatomic readline readline-dev libxml2 libxml2-dev \
libxslt libxslt-dev zlib-dev zlib ruby yaml \
yaml-dev libffi-dev build-base git nodejs \
ruby-io-console ruby-irb ruby-json ruby-rake \
make gsl gsl-dev \
gcc g++ libffi-dev ruby-dev tzdata
RUN gsl-config --cflags
RUN gem install --no-document nmatrix gsl
ADD scripts/gsl-test.rb test.rb
RUN ruby test.rb
测试文件为:
require 'gsl'
运行 docker 构建。产生以下输出:
Sending build context to Docker daemon 20 MB
Step 0 : FROM alpine:3.4
---> ad84c222f6a3
Step 1 : RUN apk upgrade --update && apk add libatomic readline readline-dev libxml2 libxml2-dev libxslt libxslt-dev zlib-dev zlib ruby yaml yaml-dev libffi-dev build-base git nodejs ruby-io-console ruby-irb ruby-json ruby-rake make gsl gsl-dev gcc g++ libffi-dev ruby-dev tzdata
---> Using cache
---> b7f66d6f2bd7
Step 2 : RUN gsl-config --cflags
---> Using cache
---> b5acc8868a74
Step 3 : RUN gem install --no-document nmatrix gsl
---> Using cache
---> 2623683a706e
Step 4 : ADD scripts/gsl-test.rb test.rb
---> e4388f952198
Removing intermediate container 743340a3be60
Step 5 : RUN ruby test.rb
---> Running in c53a34ece153
/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': Error relocating /usr/lib/ruby/gems/2.3.0/gems/gsl-2.1.0.1/lib/gsl_native.so: gsl_multifit_fdfsolver_jac: symbol not found - /usr/lib/ruby/gems/2.3.0/gems/gsl-2.1.0.1/lib/gsl_native.so (LoadError)
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/lib/ruby/gems/2.3.0/gems/backports-3.6.8/lib/backports/std_lib.rb:9:in `require_with_backports'
from /usr/lib/ruby/gems/2.3.0/gems/gsl-2.1.0.1/lib/gsl.rb:11:in `<top (required)>'
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `require'
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `rescue in require'
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:40:in `require'
from test.rb:1:in `<main>'
The command '/bin/sh -c ruby test.rb' returned a non-zero code: 1
如有任何帮助,我们将不胜感激。
我认为问题是您 运行 gsl 版本 1.16 然后 运行 最新的 gsl gem (2.1.0.1)。如果您强制 gem 安装以匹配 gsl 版本:
gem install --no-document gsl -v 1.16.0.6
它应该能很好地工作。