Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error 'The "--input" option does not exist' when rerunning the hooks #243

Open
alfredbez opened this issue Apr 11, 2024 · 1 comment
Open
Assignees

Comments

@alfredbez
Copy link

I had an issue while switching branches that resulted in this message:

Composer autoloader crashed:
  Please update your autoloader by running `composer install`
  You can re-run the hook by executing `vendor/bin/captainhook --configuration=captainhook-with-pre-commit.json --bootstrap=vendor/autoload.php --input= hook:post-checkout 2285979ace8d5a69fde6c68756cac8161c9ec72c b0b2ee197acf4bcfc1e848b1546a507925e3338d 1`

I fixed the underlying issue by running composer install and wanted to rerun the hooks, so I copied the suggested command and executed:

vendor/bin/captainhook --configuration=captainhook-with-pre-commit.json --bootstrap=vendor/autoload.php --input= hook:post-checkout 2285979ace8d5a69fde6c68756cac8161c9ec72c b0b2ee197acf4bcfc1e848b1546a507925e3338d 1

This lead to this error message:

The "--input" option does not exist.

image

I changed the command then manually:

- vendor/bin/captainhook --configuration=captainhook-with-pre-commit.json --bootstrap=vendor/autoload.php --input= hook:post-checkout 2285979ace8d5a69fde6c68756cac8161c9ec72c b0b2ee197acf4bcfc1e848b1546a507925e3338d 1
+ vendor/bin/captainhook --configuration=captainhook-with-pre-commit.json --bootstrap=vendor/autoload.php hook:post-checkout 2285979ace8d5a69fde6c68756cac8161c9ec72c b0b2ee197acf4bcfc1e848b1546a507925e3338d 1

And this worked finally 🎉

Nice feature btw ❤️

@sebastianfeldmann
Copy link
Collaborator

sebastianfeldmann commented Apr 12, 2024

Do your different branches depend on different captainhook versions?

One of the last updates required to re-install the hooks.

What changed:
In order to allow user input for all hooks (ask the user to confirm something) I had to handle the original stdIn hook input differently. That led to a small change in the actual hook scripts.
Now the stdIn is collected and passed to the Cap'n via --input option.

If your branches depend on different versions the actual hook scripts can only be valid for one version.
In order to fix this you could re-install the hooks with vendor/bin/captainhook install -f --only-enabled

You could write a post-checkout hook that checks if the composer.json file changed and blindly run the install command again.
Or write a custom action that checks if the Cap'n version changed. You would have to compare the composer.lock version with the composer.json version.

Again I think it is related to the incompatible hook script. This should not happen too often ... sorry :/
But even a major version update would still have the same problem, because of the version control independent hook scripts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants