No ARM binaries; cannot run in Docker container on Apple M1
When I install the wkhtmltopdf_binary_gem in a Docker container built on ruby:2.7.4-slim-buster on an Apple M1 machine, it fails with a RuntimeError:
RuntimeError:
Failed to execute:
["/usr/local/bundle/bin/wkhtmltopdf", "file:////tmp/wicked_pdf20220825-4460-1twretl.html", "/tmp/wicked_pdf_generated_file20220825-4460-nwpbjz.pdf"]
Error: PDF could not be generated!
Command Error: qemu-i386: Could not open '/lib/ld-linux.so.2': No such file or directory
# /usr/local/bundle/gems/wicked_pdf-2.6.3/lib/wicked_pdf.rb:80:in `rescue in pdf_from_url'
# /usr/local/bundle/gems/wicked_pdf-2.6.3/lib/wicked_pdf.rb:79:in `pdf_from_url'
# /usr/local/bundle/gems/wicked_pdf-2.6.3/lib/wicked_pdf.rb:36:in `pdf_from_html_file'
# /usr/local/bundle/gems/wicked_pdf-2.6.3/lib/wicked_pdf.rb:44:in `pdf_from_string'
# ./app/models/nomination_instruction.rb:66:in `generate_report'
# ./app/models/nomination_instruction.rb:50:in `generate_pdf'
# ./spec/lib/redacted_spec.rb.rb:467:in `block (4 levels) in <top (required)>'
# ------------------
# --- Caused by: ---
# RuntimeError:
# PDF could not be generated!
# Command Error: qemu-i386: Could not open '/lib/ld-linux.so.2': No such file or directory
# /usr/local/bundle/gems/wicked_pdf-2.6.3/lib/wicked_pdf.rb:76:in `pdf_from_url'
docker-compose exec rails arch returns aarch64, so it should be trying to run the aarch64 version, and not touching qemu-i386.
However, looking in the bin folder, there only appear to be builds for i386 and amd64; there are no aarch64 builds.
Please could they be added?
I had this exact error myself. There are multiple PRs waiting merging. For example this fixed things for me:
gem 'wkhtmltopdf-binary', github: 'willnet/wkhtmltopdf_binary_gem', branch: 'arm'
Many arm binaries were added with the above PR and a few others in version 0.12.6.7 of this gem, but there still isn't a build of wkhtmltopdf for M-class Apple machines, and I'm not sure there ever will be.
However, it should work with Rosetta.
Please reopen this issue & let me know if I'm missing something.