Closed sneakyvv closed 1 year ago
Hello,
Thanks for the pr.
I'm wondering why you can't just configure the command to run through devenv by configuring EXEC_GRUMPHP_COMMAND
?
Similar to configuring docker and other tools:
https://github.com/phpro/grumphp/blob/master/doc/parameters.md
Thanks for the pointer. That will probably work! I'll test it asap.
For anyone looking, this worked:
git_hook_variables:
EXEC_GRUMPHP_COMMAND: $HOME/.nix-profile/bin/devenv shell
This PR adds support for usage of GrumPHP when developing with a devenv environment.
Problem
Devenv basically allows to run different PHP versions per project (amongst other services), but unlike Docker the services run natively.
In my setup, devenv is running in a WSL2 environment (Ubuntu). Doing commits from within WSL2 is not a problem, because direnv is automatically hooking into each bash command so that the correct PHP version is used for example.
The problem is that my git client (Fork) is running in Windows itself (and is proxying its git commands to WSL2 via wslgit). Therefore when the
pre-commit
hook is running its PHP command, the devenv shell is not loaded, so it's using the wrong PHP version, resulting in Psalm errors (but there might be others of course due to the wrong environment being used).Solution
Alter the
pre-commit
hook install script so that the GrumPHP command is running inside the devenv shellPS: I also wondered if the
commit-msg
hook should also be adapted, but since that's only using git afaics it's not necessary.