bootsnap: Bootsnap causes kamal setup to hang in Ruby 3.3.5
I have a new Rails app, There are some env
ruby 3.3.5
rails 8.0.0
kamal 2.3.0
Dockerfile
# Install application gems
RUN bundle install
RUN rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git
RUN rm -rf tmp/cache/bootsnap*
RUN bundle exec bootsnap precompile --gemfile
# Copy application code
COPY . .
# Precompile bootsnap code for faster boot times
RUN bundle exec bootsnap precompile app/ lib/
# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile
When I run kamal setup
DEBUG [c688ef86] #15 /bin/sh -c bundle install
DEBUG [c688ef86] #15 CACHED
DEBUG [c688ef86]
DEBUG [c688ef86] #16 /bin/sh -c rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git
DEBUG [c688ef86] #16 CACHED
DEBUG [c688ef86]
DEBUG [c688ef86] #17 /bin/sh -c rm -rf tmp/cache/bootsnap*
DEBUG [c688ef86] #17 CACHED
DEBUG [c688ef86]
DEBUG [c688ef86] #18 /bin/sh -c bundle exec bootsnap precompile --gemfile
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 5
- Comments: 31 (16 by maintainers)
Commits related to this issue
- Fix bootsnap hanging in CI — committed to maybe-finance/maybe by zachgoll 2 years ago
- Temporary disable Bootsnap to fix QEMU issue https://github.com/Shopify/bootsnap/issues/495 — committed to ledermann/docker-rails-base by ledermann 2 years ago
- Fix handing of docker image build According to this issue: https://github.com/Shopify/bootsnap/issues/495 — committed to blackcandy-org/blackcandy by aidewoode 2 years ago
- Attempt to detect QEMU hangs When building cross platform images with Docker, QEMU is often used under the hood and can have a bug that cause forked processes to deadlock. Before spawning workers we... — committed to Shopify/bootsnap by byroot 2 years ago
- Attempt to detect QEMU hangs When building cross platform images with Docker, QEMU is often used under the hood and can have a bug that cause forked processes to deadlock. Before spawning workers we... — committed to Shopify/bootsnap by byroot 2 years ago
- Attempt to detect QEMU hangs When building cross platform images with Docker, QEMU is often used under the hood and can have a bug that cause forked processes to deadlock. Before spawning workers we... — committed to Shopify/bootsnap by byroot 2 years ago
Probably because bootsnap terminated too early; it hasn’t frozen yet. There is something wrong with
Process.fork, it seems the first fork is fine but the subsequent forks seem to hang.POC code:
-j 0and-j 1won’t trigger the issue, we can use them in the meantime.Switching to Ruby 3.2.6 fixes it for me too
I’ve published a
1.18.5that tries to automatically detect this QEMU bug and when it does it disable parallel compilation.It’s of course gonna be slower, but at least it will complete.
Thanks @midnight-wonderer for the initial version of the detection code.
I have been able to get my builds to run past bootsnap precompile with the following setting:
Use Rosetta for x86_64/amd64 emulation on Apple Siliconspecifically.Good job @midnight-wonderer , confirming it works with ruby 3.3.7
no hanging at
for simple
docker buildx build --push --platform linux/arm64,linux/amd64 -t your-repo/project-name .edit: works even with ruby 3.4.2
Here is my second shot but this time just the detection logic. https://github.com/Shopify/bootsnap/pull/497
Try with:
So that confirms my suspicion that Ruby is running into some QEMU limitation.
I just thought of something. For people who manage to make it hang in local, if you can try to enter the container from another shell, and kill the ruby process with
kill -S ABRT -p <PID>.That should hopefully cause Ruby to crash and print a crash report with a backtrace. Short of having a proper repro, that may give clues as to where it’s stuck.
Also stuck on ruby 3.3.7. and latest bootsnap release.
With the --verbose flag it shows paths being processed, then at some point it just stops outputting. The order of the file paths is not deterministic, so it is hard to pinpoint anything specific.
While it says here https://github.com/rails/rails/issues/54039, that the issue is with arm64, I am using amd64 and still getting stuck:
I changed ruby version to 3.2.5. bootsnap precompile is ok!