Skip to content

Elastic Beanstalk deployment of Rails app stalls during assets:precompile

1

Hello,

I'm running a Ruby on Rails application on Elastic Beanstalk. Deployments work with platform version Ruby 3.2 running on 64bit Amazon Linux 2023/4.1.0. But after updating to Ruby 3.2 running on 64bit Amazon Linux 2023/4.2.0 the deployment stops after

Running command: /bin/su webapp -c bundle exec rake assets:precompile

I don't see any errors in /var/log/eb-engine.log and the CPU usage is near 0. The instance status in the AWS console is

Degraded
    Performing application deployment (running for 19 minutes).
    Incorrect application version "app-12345" (deployment 2). Expected version "app-12345" (deployment 2).

Any suggestions?

asked 2 years ago427 views

3 Answers
0

Hi there,

I had the exact same problem with version 4.2.0 and Ruby 3.2 . Everything works fine with the version 4.0.12 but when I upgrade to 4.2.0, the process get stuck at the assets compilation step. Logs show those two line and then nothing happens until deployment timeouts :

2024/12/11 22:28:52.065236 [INFO] Found assets:precompile task in Rakefile
2024/12/11 22:28:52.066338 [INFO] Running command: /bin/su webapp -c bundle exec rake assets:precompile

@AWS , Is there already a known issue about this ?

answered 2 years ago

  • Hi there, here's what I found out so far: For debugging it is helpful to set RAILS_SKIP_ASSET_COMPILATION to true and trigger the asset compilation manually:

    $ sudo su -l webapp
    # cd /var/app/current
    # bundle exec rake assets:precompile
    

    Doing this, I noticed:

    • I had in fact one gem in my Gemfile that caused an error message.
    • After removing this gem, the process stalled during yarn install, specifically during linking. I was using yarn 1, an upgrade to yarn 3 helped.
    • Now the process stalls while running webpack.

    So I couldn't solve my problem yet, but maybe this is helpful for you.

  • Glad to finally see some action on this post - I've been experiencing the same thing jumping from 4.0.12 to 4.2.0. I'll give RAILS_SKIP_ASSET_COMPILATION a try tonight and see if I can get through yarn install. @rePost-User-9095603 - which gem was causing your hang up?

  • in case you don't get notifications when someone posts an answer here (I'm not sure when rePost sends notifications): I posted our solution below.

0

I work with the guy who posted this. In case anyone is still stuck on the issue, in our case it proved to be https://github.com/amazonlinux/amazon-linux-2023/issues/840#issuecomment-2485615625 . (The people there are talking about pnpm, but all node processes were affected, including yarn install with all yarn versions.) Since the underlying kernel bug is fixed in the last Ruby platform version, we updated to that, and the issue is gone. If you need to be on Amazon Linux 4.2.0 for some reason, there's a workaround behind the link, which I'll repeat here to save you a click: set the environment variable UV_USE_IO_URING to the value 0 when running node, and if your problem is what our problem was, it should disappear.

answered 2 years ago

-3

This issue you're experiencing with your Ruby on Rails application deployment on Elastic Beanstalk is concerning, especially since it's occurring after updating to a newer platform version. Here are some suggestions to help troubleshoot and potentially resolve the problem:

  1. Check your application logs: While you mentioned that you don't see errors in /var/log/eb-engine.log, it's worth checking other log files such as /var/log/webapp/production.log or any custom log files your application might be generating. These logs might provide more insight into what's happening during the assets:precompile step.

  2. Verify your Gemfile and Gemfile.lock: Ensure that all your gem dependencies are compatible with Ruby 3.2 and the new platform version. Sometimes, gem incompatibilities can cause silent failures during deployment.

  3. Test assets:precompile locally: Try running the assets:precompile task on your local machine with the same Ruby version. This might help identify if the issue is specific to your application or the Elastic Beanstalk environment.

  4. Increase instance size temporarily: If the asset compilation is resource-intensive, try deploying to a larger instance type temporarily to rule out resource constraints.

  5. Check for timeouts: The Elastic Beanstalk deployment might be timing out. You can try increasing the deployment timeout in your configuration files.

  6. Use a custom deploy hook: You can create a .ebextensions file with a custom deploy hook to run the assets:precompile task with more verbose output, which might reveal the issue.

  7. Roll back to the previous platform version: If possible, try rolling back to the previous platform version (Ruby 3.2 running on 64bit Amazon Linux 2023/4.1.0) to confirm if the issue is indeed related to the platform update.

  8. Check for platform-specific changes: Review the Elastic Beanstalk platform changelog to see if there are any significant changes in the new version that might affect your application's deployment process.

If none of these suggestions resolve the issue, you may need to contact AWS support for further assistance, as there could be an underlying problem with the new platform version or how it interacts with your specific application configuration.

Sources
Deploying a rails application to Elastic Beanstalk - AWS Elastic Beanstalk
Elastic Beanstalk supported platforms - AWS Elastic Beanstalk
Notifications and troubleshooting - AWS Elastic Beanstalk
Deploying Ruby applications with Elastic Beanstalk - AWS Elastic Beanstalk

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.