IAPark / tiktoken_ruby

Unofficial ruby binding for tiktoken by way of rust
MIT License
109 stars 26 forks source link

Error loading shared library ld-linux-x86-64.so.2 in Alpine Docker image #38

Closed fguillen closed 1 week ago

fguillen commented 1 week ago

I am running a Rails App in a Docker image:

FROM ruby:3.2.4-alpine3.19

I was seeing this error when loading:

/usr/local/bundle/gems/tiktoken_ruby-0.0.9-x86_64-linux/lib/tiktoken_ruby.rb:10:in `require_relative': cannot load such file -- /usr/local/bundle/gems/tiktoken_ruby-0.0.9-x86_64-linux/lib/tiktoken_ruby/tiktoken_ruby (LoadError)
    from /usr/local/bundle/gems/tiktoken_ruby-0.0.9-x86_64-linux/lib/tiktoken_ruby.rb:10

I added this line to the script to see the original error:

begin
  RUBY_VERSION =~ /(\d+\.\d+)/
  require_relative "tiktoken_ruby/#{$1}/tiktoken_ruby"
rescue LoadError => e
  puts ">>>> e: #{e.inspect}" # This line
  require_relative "tiktoken_ruby/tiktoken_ruby"
end

And the original error is:

Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /usr/local/bundle/gems/tiktoken_ruby-0.0.9-x86_64-linux/lib/tiktoken_ruby/3.2/tiktoken_ruby.so)

I don't know how to solve the issue :/

fguillen commented 1 week ago

I installed all this:

apk update --no-cache \
    && apk add build-base git curl --no-cache \
    && apk add bash libstdc++ zlib pkgconfig autoconf automake libtool nasm --no-cache \
    && apk add tzdata nodejs npm openjdk8 libxml2 libxslt gcompat imagemagick --no-cache \
    && apk add gifsicle jpegoptim libpng libjpeg-turbo libjpeg-turbo-utils optipng pngcrush pngquant --no-cache \
    && apk add advancecomp --no-cache \
        --repository http://dl-cdn.alpinelinux.org/alpine/edge/community \
    && apk add jhead --no-cache \
        --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing \
    && npm install -g --force --unsafe-perm=true --allow-root svgo advpng-bin

Following instructions here: https://blog.siposdani87.com/posts/create-alpine-docker-image-for-rails-7

And it works. I don't know what package did the trick