Running Rails 7 with YJIT in Heroku Bash

Created at: 01 May 2024 Last updated: 01 May 2024

I ran into an issue today after running commands like:
heroku run bash
Running bash on β¬’ my-app... up, run.8292 (Standard-1X) 
~ $ rails db:status 
/usr/bin/env: β€˜ruby --yjit’: No such file or directory 
/usr/bin/env: use -[v]S to pass options in shebang lines

Running Rails 7 with YJIT works locally with this shebang which goes at the top of bin/rails:
#!/usr/bin/env ruby --yjit

It was recommended here:
https://netoff.dev/blog/2023-02-01-using-rails-7-with-yjit

But, this doesn't work when running bash on Heroku dynos, even with --yjit enabled via options.
See: https://devcenter.heroku.com/articles/ruby-support#ruby-versions

But this does:

#!/usr/bin/env -S ruby --yjit

Why? See the attached CoPilot chat and this StackExchange thread: https://unix.stackexchange.com/questions/399690/multiple-arguments-in-shebang/477651#477651
This is a crosspost with X, to read the post on that platform click here.

Back