参照サイト
Installing Nokogiri - Nokogiri
The Official Tutorial Archive™ of Nokogiri®
Error loading shared library ld-linux-aarch64.so.1: No such file or directory が出た場合
解決策:libc6-compat をインストールする
Sinatra を利用した簡単なアプリを MacBook(M1)で開発していて、いざ Linux 環境へデプロイするためには Docker build したときに発生。
/usr/local/bundle/gems/nokogiri-1.13.8-aarch64-linux/lib/nokogiri/extension.rb:7:in `require_relative': Error loading shared library ld-linux-aarch64.so.1: No such file or directory (needed by /usr/local/bundle/gems/nokogiri-1.13.8-aarch64-linux/lib/nokogiri/3.0/nokogiri.so) - /usr/local/bundle/gems/nokogiri-1.13.8-aarch64-linux/lib/nokogiri/3.0/nokogiri.so (LoadError)
from /usr/local/bundle/gems/nokogiri-1.13.8-aarch64-linux/lib/nokogiri/extension.rb:7:in `<top (required)>'
from /usr/local/bundle/gems/nokogiri-1.13.8-aarch64-linux/lib/nokogiri.rb:10:in `require_relative'
from /usr/local/bundle/gems/nokogiri-1.13.8-aarch64-linux/lib/nokogiri.rb:10:in `<top (required)>'
=> ERROR [6/6] RUN bundle exec rails assets:precompile 0.5s
------
> [6/6] RUN bundle exec rails assets:precompile:
#10 0.462 bundler: failed to load command: rails (/usr/local/bundle/bin/rails)
#10 0.462 /usr/local/bundle/gems/bundler-2.2.22/lib/bundler/spec_set.rb:41:in `block in for': Unable to find a spec satisfying sqlite3 (~> 1.4) in the set. Perhaps the lockfile is corrupted? Found sqlite3 (1.5.3-arm64-darwin) that did not match the current platform. (Bundler::GemNotFound)
#10 0.462 from /usr/local/bundle/gems/bundler-2.2.22/lib/bundler/spec_set.rb:20:in `loop'
#10 0.462 from /usr/local/bundle/gems/bundler-2.2.22/lib/bundler/spec_set.rb:20:in `for'
...
Platformを追加
bundle lock --add-platform aarch64-linux
+ sqlite3 (1.5.3-aarch64-linux)
sqlite3 (1.5.3-arm64-darwin)
PLATFORMS
+ aarch64-linux
arm64-darwin-21
関連
The Official Tutorial Archive™ of Nokogiri®
Bundler 2.2 and later has great multiplatform support and allows you to cache gems for multiple platforms. You can run commands like these to cause Bundler to fetch and cache gems for all the named platforms:
```text
bundle lock --add-platform x86_64-darwin
bundle lock --add-platform x86_64-linux
bundle package --all-platforms
```