question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wrong shebang line generated for my setyp (Windows10 + pyenv-win + pre-commit installed in virtual env)

See original GitHub issue

pre-commit generates the following shebang in the hook:

#!/usr/bin/env python.exe

It works when I have a virtual env activated, but not outside because I install python with pyenv-win that makes python accessible through a python shim installed in %USERPROFILE%\.pyenv\pyenv-win\shims\python.

Right now my workaround is to edit manually the hook and replace “python.exe” with “python”. I don’t want to change my PATH to have “python.exe” accessible from it because I may change the global python I use with pyenv and I would have to remember to update my PATH in that case.

Is there a command line argument to specify the command to use in the shebang ? (I don’t see any with pre-commit --help or pre-commit install --help). If not do you think it would be a good idea to offer such option ?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
Celeborn2BeAlivecommented, Sep 9, 2020

Ok the pipeline finished and the only test that fail is test_shebang_windows. I’m updating the pull request with updated tests.

1reaction
asottilecommented, Aug 28, 2020

the problem with that is that executable often points at a virtualenv which can go missing (most of the git hook script is trying to re-discover a suitable pre-commit executable)

Read more comments on GitHub >

github_iconTop Results From Across the Web

pre-commit
It is a multi-language package manager for pre-commit hooks. You specify a list of hooks you want and pre-commit manages the installation and...
Read more >
What shebang to use for Python scripts run under a pyenv ...
The pyenv virtualenv venv_name does. I tried getting the path of the Python executable from the virtualenv.
Read more >
PyScaffold Documentation - Read the Docs
PyScaffold is a project generator for bootstrapping high-quality Python packages, ready to be shared on PyPI and installable via pip.
Read more >
Pipenv: promises a lot, delivers very little | Chris Warrick
I create ~/git/website and run pipenv install Django in that directory. Pipenv: automatically creates a virtualenv somewhere in my home ...
Read more >
Changelog — Python 3.11.1 documentation
gh-98745: Update py.exe launcher to install 3.11 by default and 3.12 on request. gh-98692: Fix the Python Launcher for Windows ignoring unrecognized shebang...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found