-
Notifications
You must be signed in to change notification settings - Fork 218
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
Commands are run from the current path when applying the commit #629
Comments
Hey! Actually with 1.6.0 release I've mad an effort to make lefthook commands run inside the root. Like in this example test:
commands:
ls:
run: echo $(ls)
Could you please provide some logs and config example, so I could reproduce your issue. An example repo would be even better. |
The issue seems to stem from where commands are executed in relation to a virtual environment. Commands run from the root directory (./) do not have access to the virtual environment, whereas commands executed within the ./backend directory are run within an activated virtual environment. This difference in execution context leads to command failures. This setup: # lefthook.yml
test:
commands:
which:
run: echo $(which python) with the folder structure .
├── backend
│ └── .venv
└── lefthook.yml shows that this is the case depending on the folder I run the A suggested approach to resolve this issue could be to consider executing the commands as though they were initiated from the root: directory, aiming for a consistent environment across executions. Or I could just simply setup the python venv at the project root, but this is not really desirable in my case. |
Oh, I see, so, looks like python venv runs some hook when you are inside the If assumption about some I can be wrong since I haven't worked with the pyenv closely. But I'll be glad to figure it out. |
Hey! Have you tried the |
🔧 Summary
If I run a commit in
./
or./backend/
, the results differ. In this case, with Pyright (but other commands are affected too)The python venv is attached to the backend folder.
Lefthook version
1.6.1
Steps to reproduce
Expected results
Pyright (including config) loaded from the backend in both cases
Actual results
A lot of pyright errors such as
Unable to resolve import X
in the first case but not in the secondPossible Solution
Make the command run from the path specified in root.
The text was updated successfully, but these errors were encountered: