jwt-cli icon indicating copy to clipboard operation
jwt-cli copied to clipboard

Not working on alpine linux

Open ukreddy-erwin opened this issue 1 year ago • 9 comments

I tried installing this on a docker container, alpine linux.

docker run -it alpine:3.6

And ran below set of commands.

wget https://github.com/mike-engel/jwt-cli/releases/download/5.0.3/jwt-linux.tar.gz;tar -xvzf jwt-linux.tar.gz;rm -rf jwt-linux.tar.gz;mv jwt /usr/local/bin/

But, when I ran jwt, getting error as not found. .usr/local/bin is already in system path.

Even from current working directory also same issue.

./jwt
/bin/sh: ./jwt: not found

ukreddy-erwin avatar Jun 24 '22 15:06 ukreddy-erwin

I'm not sure that this is an issue with jwt-cli specifically? This seems like an issue with the docker setup or alpine linux where it can't find the executable. jwt-cli has no concept, as far as I know, about its environment and definitely doesn't call itself during execution. Could this be a permissions issue? chmod +x /usr/local/bin/jwt?

mike-engel avatar Jun 28 '22 07:06 mike-engel

still same issue, i don't know why this question is closed without resolution. Could you please share that, if you missed to paste.

The environment I provided also easy to replicate as just single docker run command shared in my first comment

ukreddy-erwin avatar Jun 28 '22 18:06 ukreddy-erwin

Sorry, I assumed this wasn't a problem with the jwt binary.

Upon further inspection, alpine linux seems to require a static binary (not dynamically linked). This would require rust to be built with the musl target, but unfortunately ring, which is a transitive dependency of jsonwebtoken doesn't support static linking: https://github.com/briansmith/ring/issues/713

Until ring supports static linking via the musl target, jwt won't be able to run on alpine linux. Sorry! I'll leave this issue open for now though

mike-engel avatar Jun 28 '22 20:06 mike-engel

Hi, I think it is a good idea to document your findings. I now also spent a few hours facing the same issue on a busybox container with the most recent version.

Basically using the same method as OP. It is also not possible to pass it as argument to sh:

$ sh jwt
jwt: line 1: syntax error: unexpected "("

edit: a workaround seems to be to just use the rust container image.

tomwiggers avatar Nov 16 '22 09:11 tomwiggers

Added a note with 10cea20. Thanks all!

mike-engel avatar Jan 04 '23 20:01 mike-engel

Hi! Just let you know that I'm making an attempt to package jwt-cli for AlpineLinux at https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/46338.

It already works on my machine after the build. If the MR gets merged, you can install the package directly from Alpine's edge repo.

folliehiyuki avatar Apr 23 '23 06:04 folliehiyuki

Looks great, thanks @FollieHiyuki!

mike-engel avatar Apr 26 '23 07:04 mike-engel

FYI - currently static executable builds without issues with x86_64-unknown-linux-musl target and rustc 1.77.0-nightly (only had to update proc-macro2 dependency to avoid the unknown feature proc_macro_span_shrink error).

Rogach avatar Feb 06 '24 12:02 Rogach