develar / 7zip-bin

7-Zip precompiled binaries
MIT License
118 stars 34 forks source link

7zip-bin not working on alpine (Docker) #8

Closed laysent closed 4 years ago

laysent commented 4 years ago

When running 7zip-bin inside alpine docker, it produces error of "file not found". I have created a gist that will reproduce the issue: https://gist.github.com/laysent/b12faceac4bcf10bee04aabfa505c244

I have tested in on MacOS 10.14.5

I have verified that the file exists in that location, just it cannot be executed.

mtgto commented 4 years ago

@laysent It's not 7zip-bin problem.

$ ldd /example/node_modules/7zip-bin/linux/x64/7za
    /lib64/ld-linux-x86-64.so.2 (0x7febe540e000)
    libpthread.so.0 => /lib64/ld-linux-x86-64.so.2 (0x7febe540e000)
    libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x7febe52b9000)
    libm.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7febe540e000)
    libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x7febe52a5000)
    libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7febe540e000)

First line shows alpine doesn't have /lib64/ld-linux-x86-64.so.2 . To resolve it, you need to install lacked shared library. I've test launching, but not test other operations work.

$ mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2
$ /example/node_modules/7zip-bin/linux/x64/7za

7-Zip (a) [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=C.UTF-8,Utf16=on,HugeFiles=on,64 bits,3 CPUs Intel(R) Core(TM) i5-7500 CPU @ 3.40GHz (906E9),ASM,AES-NI)

Usage: 7za <command> [<switches>...] <archive_name> [<file_names>...]
laysent commented 4 years ago

@mtgto It solves the issue. Thanks a lot! One more question if you don't mind, how did you know that linking /lib/libc.musl-x86_64.so.1 to /lib64/ld-linux-x86-64.so.2 would solve the issue? It would be very nice, if there is any doc/post that I can learn from.

mtgto commented 4 years ago

I'm native Japanese, first I read it a Japanese article https://qiita.com/hiroki-uchida/items/945478d518f5f76ce4b6 You may be able to google with "ld-linux-x86-64.so.2 alpine" as your language. Because Many people already came with this trouble :)

I'm not sure precompiled 7za work fine with libc.musl-x86_64.so. I suggest to use 7zip-bin in alpine linux, install p7zip and replace 7za file in your node_modules/7zip-bin/linux/x64/7za.

laysent commented 4 years ago

Thanks for the info. Using p7zip is actually my workaround here. I have read several posts regarding this issue, many suggest the similar solution. Just curious how one came up with this solution, seems really magic to me. :-P Also I find this post helpful: https://medium.com/devgorilla/node-gyp-support-in-alpine-linux-9374c6191140 running RUN apk add --no-cache libc6-compat to install the missing dependency should help as well.