heroku/cli

Run command: Cannot pass additional options

kwent opened this issue · 11 comments

kwent commented

Do you want to request a feature or report a bug?

Very recently we would be able to pass additional options to run command. Unsure since what version it broke but it's not working anymore.

What is the current behavior?

heroku run rails console --writable -a my-app                                                                                                                                                  
Error: Nonexistent flag: --writable
See more help with --help

What is the expected behavior?

heroku run rails console --writable -a my-app                                                                                                                                                  
# Should go through and accept additional options
heroku run "rails console --writable" -a my-app
# When quoting is added it's working correctly tho

Thank you for letting us know! That is an odd one, we'll take a look at it.

@kwent I've verified that this is in fact a bug. I've filed a ticket for the team and we will get a fix prioritized.

GUS ticket

Until we are able to get this fixed, it appears that a workaround is to add -- before your additional options. So @kwent your command may look like heroku run rails console -a my-app -- --writable. Please let us know if that doesn't work for you.

@kwent I did some more digging this morning and, as it turns out, this is not necessarily a bug, but rather a change in behavior we did not realize was necessary. I apologize. The workaround I posted above is actually how the run command should function. Any commands or flags that need to be passed through should come after a --. This is shown in the documentation for that command as the second example.

If I'm not mistaken, (and from what I recall during my time at Heroku, where we had some truly convoluted custom CLI plugins 😆) the most consistent and correct way to do this is:

heroku run --app=my-app -- rails console --writable

Where everything after the -- is what gets substituted in and run on the Dyno. The non -- shorthand does work, sometimes. But it get confusing (as a human) to know which options/flags are meant for the heroku CLI and which are meant for the command being run on the Dyno. The same goes for heroku local:run.

G-Rath commented

I feel like this is probably related but happy to create a new ticket - we've just had our CI start failing on a run command that was previously working, as the Heroku CLI is reordering flags after -- that appear multiple times, i.e.:

❯ heroku run --app my-app ./manage.py -- --help
Running ./manage.py --help on ⬢ my-app... done

~ took 6s
❯ heroku run --app my-app ./manage.py -- --help --help
Running ./manage.py --help --help on ⬢ my-app... done

~ took 4s
❯ heroku run --app my-app ./manage.py -- --help value --help
Running ./manage.py --help --help value on ⬢ my-app... done

~ took 3s
❯ heroku run --app my-app ./manage.py -- --help=value --help
Running ./manage.py --help=value --help on ⬢ my-app... done

Note how in the second-to-last run the Heroku CLI has swapped the position of value and the last --help.

Our last successful deployment was using v8.1.9, and now we're failing with v8.3.1 which matches with what you've said @ryanbrainard in your PR about the @oclif/core upgrade being released in v8.2.0

Our last successful deployment was using v8.1.9, and now we're failing with v8.3.1 which matches with what you've said @ryanbrainard in your PR about the @oclif/core upgrade being released in v8.2.0

@G-Rath wrong Ryan?

G-Rath commented

@ryanbrainard yup sorry I was aiming for @ryandagg 😅

@G-Rath that's interesting, thank you for all of the detail. I'm pretty sure this is related, too. We are hoping to release a fix today.

The initial issue was fixed in v8.4.2.
@G-Rath Your issue is related but potentially distinct. Can you verify after running heroku update stable?
If not, I have another potential fix that you can verify with heroku update beta.

G-Rath commented

@ryandagg can confirm that this is fixed in v8.4.2:

❯ heroku run --app my-app ./manage.py -- --help
Running ./manage.py --help on ⬢ my-app... done

~ took 3s
❯ heroku run --app my-app ./manage.py -- --help --help
Running ./manage.py --help --help on ⬢ my-app... done

~ took 3s
❯ heroku run --app my-app ./manage.py -- --help value --help
Running ./manage.py --help value --help on ⬢ my-app... done

~ took 3s
❯ heroku run --app my-app ./manage.py -- --help=value --help
Running ./manage.py --help=value --help on ⬢ my-app... done