By using AWS re:Post, you agree to the AWS re:Post Terms of Use

Elastic Beanstalk Rails 7 app doesn't compile application.scss

0

I've prepared a Rails 7 app in Elastic Beanstalk, on the Ruby 3.2 running on 64bit Amazon Linux 2023/4.0.12 platform, arm64 processor. To use SCSS instead of CSS, I've changed the application.css file to application.scss. Precompiling assets in production mode in my local environment works just fine RAILS_ENV=production bundle exec rails assets:precompile, but when I deploy, EB doesn't compile the application.scss at all. EB seems to run the task in a different way using rake, it ignores the sass compiler, and doesn't produce a stylesheet at all. The command in question is this one:

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

Is there some configuration I need to change in EB? Do I need to get it to run rails assets:precompile instead?

asked 2 months ago78 views
1 Answer
0

Hello there,

Hope you are doing well.

==========

From your response I’ve understood that Elastic Beanstalk is not able to compile ‘application.scss’. You have tried using ‘rails assets:precompile’ in your local environment and it works fine. But when you deploy using Beanstalk it is failing.

I tried to create a sample Beanstalk ruby application and found that Beanstalk runs the below command during deployment :


/bin/su webapp -c bundle exec /opt/elasticbeanstalk/config/private/checkforraketask.rb assets:precompile


Here I would like to tell you that you can skip this by setting the ‘RAILS_SKIP_ASSET_COMPILATION’ [1] to true. Then you can try compiling using ebextensions [2] or hooks [3] depending on the use case. You can specify your own command ‘rails assets:precompile’. You can go through this Instance deployment workflow [4] doc to understand how the deployment process works in Beanstalk.

If it is still failing then we would have to look at your environment logs [5] to investigate this issue further. Thus, currently due to the limited information available, I would suggest you to reach out to AWS Elastic Beanstalk Support team with a case efficient troubleshooting. Please share your logs, environment name, Application name, region when you create a case. We’ll be more than happy to assist you with this case.

I sincerely hope that you find the above information useful.

Have a safe and good day ahead.

====

References:

[1] https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_Ruby.container.html [2] https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html [3] https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.hooks.html [4] https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.workflow.html [5] https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.logging.html

AWS
SUPPORT ENGINEER
answered 2 months ago
  • Thank you for the recommendations. Unfortunately, the server still refuses to recognize the application.scss file even when executing rails assets:precompile instead. The precompile task will work if I explicitly add a scss file to the manifest or assets initializer config, but it won't process the scss syntax and just output the original content of the file, sass functions, directives, and all.

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.

Guidelines for Answering Questions