1

I'm trying to deploy an API-only Rails 5 application to AppEngine Flex w/ the standard Ruby runtime, and I'm getting the following error at the very end:

Updating service [default] (this may take several minutes)...failed.                                                                                                                                                                                                                         
ERROR: (gcloud.app.deploy) Error Response: [9] 
Application startup error:
/usr/bin/env: 'ruby2.5': No such file or directory

I'm specifying ruby '2.5.1' in my Gemfile and I've added an explicit .ruby-version file to the root of my project set to 2.5.1 as well.

I have no other debugging information available to me in the logs, no other fancieness. My entrypoint command is:

bundle exec rails server Puma -p $PORT

I can provide more details if needed, not sure what else might be relevant. Any pointers? As far as I can tell, nothing on my side is asking for a version of ruby that specifically at execution time.

Thanks!

EDIT: Here's my app.yaml file

entrypoint: bundle exec rails server Puma -p $PORT
env: flex
runtime: ruby

UPDATE:

I can verify that I'm having similar problems when trying to exec rake tasks like db:migrate:

--------- EXECUTE COMMAND ----------
bundle exec rake db:migrate
/usr/bin/env: 'ruby2.5': No such file or directory
ERROR
ERROR: build step 0 "gcr.io/google-appengine/exec-wrapper:latest" failed: exit status 127
--------------------------------------------------------------------------------------------------------------------------------------------------------
Dee
  • 41
  • 5
  • When you say _...w/ the standard Ruby runtime..._, what do you mean? Can you please start with this [tutorial](https://cloud.google.com/ruby/rails/appengine#set_up_an_app_engine_flexible_environment_app) and see if it works? – Victor M Perez Jun 26 '18 at 14:04
  • Hi there, thats exactly what I did and got this problem on the other side. Adding my app.yaml to question. – Dee Jun 26 '18 at 15:30
  • In the app.yaml there is also a section like this: `env_variables: SECRET_KEY_BASE: some-generated-key` I think it would be better for you if you follow the tutorial in [this link](https://cloud.google.com/ruby/rails/appengine). I see an `app.yaml` similar to the one you show in https://cloud.google.com/appengine/docs/flexible/ruby/runtime but this is only an overview of the runtime. – Victor M Perez Jun 26 '18 at 16:00
  • Hi Victor, I have that section as well, but for obvious reasons I left that out. As mentioned, I followed the tutorial you linked to and this was the result of running gcloud app deploy. – Dee Jun 26 '18 at 16:49
  • 1
    FWIW rackup did work, the puma change did not, sorry I realize I didn't mention that. My mistake. I saw that for rack systems but wasn't sure that was the best idea for an actual rails project. – Dee Jun 26 '18 at 16:51
  • I am glad it worked. Please post it as an answer so that the community can benefit from that example :-) – Victor M Perez Jun 26 '18 at 17:36
  • Hey so actually I retried this as discussed and it has the exact same error...not working for me. – Dee Jun 28 '18 at 04:25
  • Your issue is very similar to this https://stackoverflow.com/questions/40386726/ruby-on-rails-usr-bin-env-ruby2-3-no-such-file-or-directory Try the solutions suggested there please – Victor M Perez Jun 28 '18 at 13:51
  • Hi Victor, how would that work in appengine exactly? It runs fine locally so I don't think this would help. Agreed it does sound familiar. I filed a bug with the appengine Ruby-docker project to see if they have any guidance. – Dee Jun 29 '18 at 02:42
  • I haven't been able to reproduce your issue. What you have done (Opening the [issue in github](https://github.com/GoogleCloudPlatform/ruby-docker/issues/150)) is the best thing to do in this case. – Victor M Perez Jul 02 '18 at 07:42

1 Answers1

3

OK I now see what has happened after debugging the docker image locally. Because I was on ubuntu and had used system ruby to install gems it had embedded /usr/bin/env ruby2.5 into every executable script that was bundled into my app. I deleted all gems and switched to rbenv for managing Ruby version which mitigated this odd behavior between unbuntu's ruby and my app.

Dee
  • 41
  • 5
  • I think you can accept you own answer and the community will know the case is solved. – Victor M Perez Jul 17 '18 at 10:33
  • Do you know how the system pulled `ruby2.5` ? I'm hitting the same issue on a docker image and `which ruby` returns just fine. Not sure where the string `ruby2.5` is coming from. – Schneems Dec 14 '18 at 16:42
  • Looks like `which ruby` is symlinked to a `ruby2.5` file https://gist.github.com/schneems/c62fc2359983b57d3e27166ed23432f6 – Schneems Dec 14 '18 at 16:48