Skip to content

Remove unnecessary ruby-libs package #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Remove unnecessary ruby-libs package #131

wants to merge 1 commit into from

Conversation

y3ti
Copy link

@y3ti y3ti commented Jun 5, 2017

Alpine version of ruby image installs unnecessary dependency ruby-libs.

$ docker container run --rm -ti ruby:2.3-alpine /bin/sh -c 'apk -vv info | grep ruby'
ruby-libs-2.3.1-r0 - Libraries necessary to run Ruby
.ruby-rundeps-0 - virtual meta package
$ docker container run --rm -ti ruby:2.3-alpine ruby -v
ruby 2.3.4p301 (2017-03-30 revision 58214) [x86_64-linux-musl]

Currently the image contains two versions of libruby.so: one created during
building process and one installed by apk:

$ docker container run --rm -ti ruby:2.3-alpine /bin/sh -c 'find . -name libruby.so*'
./usr/lib/libruby.so.2.3
./usr/lib/libruby.so.2.3.0
./usr/local/lib/libruby.so
./usr/local/lib/libruby.so.2.3
./usr/local/lib/libruby.so.2.3.0

Ruby uses correct libruby version:

$ docker container run --rm -ti ruby:2.3-alpine /bin/sh -c 'ldd /usr/local/bin/ruby'
/lib/ld-musl-x86_64.so.1 (0x5651cd9e5000)
libruby.so.2.3 => /usr/local/lib/libruby.so.2.3 (0x7ff147d4c000)
libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x5651cd9e5000)

I think we should not install ruby-libs from apk.
This commits removes ruby-libs from .ruby-rundeps.

Alpine version of ruby image installs unnecessary dependency `ruby-libs`.

```
$ docker container run --rm -ti ruby:2.3-alpine /bin/sh -c 'apk -vv info | grep ruby'
ruby-libs-2.3.1-r0 - Libraries necessary to run Ruby
.ruby-rundeps-0 - virtual meta package
```

```
$ docker container run --rm -ti ruby:2.3-alpine ruby -v
ruby 2.3.4p301 (2017-03-30 revision 58214) [x86_64-linux-musl]
```

Currently the image contains two version of `libruby.so`: one created during
building process and one installed by `apk`:

```
$ docker container run --rm -ti ruby:2.3-alpine /bin/sh -c 'find . -name libruby.so*'
./usr/lib/libruby.so.2.3
./usr/lib/libruby.so.2.3.0
./usr/local/lib/libruby.so
./usr/local/lib/libruby.so.2.3
./usr/local/lib/libruby.so.2.3.0
```

Ruby uses correct `libruby` version:

```
$ docker container run --rm -ti ruby:2.3-alpine /bin/sh -c 'ldd /usr/local/bin/ruby'
/lib/ld-musl-x86_64.so.1 (0x5651cd9e5000)
libruby.so.2.3 => /usr/local/lib/libruby.so.2.3 (0x7ff147d4c000)
libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x5651cd9e5000)
```

I think we should not install `ruby-libs` from apk.
This commits removes `ruby-libs` from `.ruby-rundeps`.
@tianon
Copy link
Member

tianon commented Jun 5, 2017

I'm a little confused -- the actual change in the commits here doesn't seem to match what you've described. 😕 (grep -v libruby vs removing ruby-libs)

If that runDeps block is matching libruby from the ruby-libs package, that likely means we've got a binary compiled against it, which is something we'd need to fix too. 😞

@@ -78,6 +78,7 @@ RUN set -ex \
scanelf --needed --nobanner --recursive /usr/local \
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, it's this bit that causes the trouble -- we only know that we're linked against libruby.so.2.3, not the full path to the proper .so file. 😞

$ docker run -it --rm ruby:2.3-alpine sh
/ # scanelf --needed --nobanner --recursive /usr/local | awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' | sort -u
so:libc.musl-x86_64.so.1
so:libcrypto.so.1.0.0
so:libffi.so.6
so:libgdbm.so.4
so:libgdbm_compat.so.4
so:libncursesw.so.6
so:libreadline.so.6
so:libruby.so.2.3
so:libssl.so.1.0.0
so:libyaml-0.so.2
so:libz.so.1
/ # 

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and we have two libruby.so installed.

grep -v libruby removes ruby-libs from dependencies list. My solution is only a workaround and I would like to point at the issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for finding the bug, but I would like to find a general solution to apply it to images other than ruby. Many official images that build from source on alpine use these same scanelf lines and might be have a similar problem.

🤔 😢

@ojab
Copy link
Contributor

ojab commented Sep 22, 2017

How about that?

@ojab
Copy link
Contributor

ojab commented Sep 22, 2017

whoops, copypaste error. See this commit, actually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants