I'm using ruby27
in GAE Standard for Ruby. It currently resolves to 2.7.7. Previously, under 2.7.6, the GAE builder successfully precompiled assets. Now, even with /public/assets
properly in .gcloudignore
and ruby ~> "2.7.0"
in Gemfile, the GAE depoyment build logs show errors like:
Step #2 - "build": Running Rails asset precompilation
Step #2 - "build": 2023/01/31 08:15:26 [DEBUG] GET https://registry.npmjs.org/yarn
Step #2 - "build": DEBUG: ***** CACHE HIT: "yarn"
Step #2 - "build": Yarn cache hit, skipping installation.
Step #2 - "build": DEBUG: Setting environment variable PATH=/layers/google.ruby.rails/yarn/bin:/layers/google.ruby.runtime/ruby/bin:/builder/google-cloud-sdk/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Step #2 - "build": --------------------------------------------------------------------------------
Step #2 - "build": Running "bundle exec ruby bin/rails assets:precompile (RAILS_ENV=production MALLOC_ARENA_MAX=2 RAILS_LOG_TO_STDOUT=true LANG=C.utf8)"
Step #2 - "build": rails aborted!
Step #2 - "build": ExecJS::RuntimeUnavailable: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.
Step #2 - "build": /layers/google.ruby.bundle/gems/.bundle/gems/ruby/2.7.0/gems/execjs-2.8.1/lib/execjs/runtimes.rb:58:in `autodetect'
...
Some have similar problem because Yarn isn't installed, though we see above it is. I noticed that in the traceback, it references ruby 2.7.0 instead of 2.7.7. I also noticed that the buildpack seems to use Ruby 3.0
Step #2 - "build": Pulling image: us.gcr.io/gae-runtimes/buildpacks/google-gae-18/ruby/builder:ruby30_20230123a_3_0_5_RC00
Step #2 - "build": ruby30_20230123a_3_0_5_RC00: Pulling from gae-runtimes/buildpacks/google-gae-18/ruby/builder
Is the problem I'm seeing due to a weird ruby version mismatch within GAE's Cloud Builder system?
Lastly, we can see in the same GAE build logs that NodeJS is installed, and that the expected Ruby 2.7.7 is also installed for at least part of the build process:
Step #2 - "build": Setting Nodejs runtime version GOOGLE_NODEJS_VERSION: 12.22.12
Step #2 - "build": DEBUG: ***** CACHE MISS: "ruby"
Step #2 - "build": Installing Ruby Runtime v2.7.7.
Step #2 - "build": 2023/01/31 08:09:48 [DEBUG] GET https://dl.google.com/runtimes/ubuntu1804/ruby/ruby-2.7.7.tar.gz
Step #2 - "build": --------------------------------------------------------------------------------
We also see from the logs that execjs
is installed even though it's not in the Gemfile.
Step #2 - "build": Fetching execjs 2.8.1
Step #2 - "build": Installing execjs 2.8.1
This gem should autodetect a JS interpreter in the system (NodeJS), yet it doesn't seem to be. How can i fix this? Or more to the point, how can I get GAE to precompile Ruby on Rails assets again?