Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7170511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:13:40+00:00 2026-05-28T15:13:40+00:00

This is my pre-commit script: #!/bin/bash for f in .git/hooks/pre-commit.d/*; do if [ -x

  • 0

This is my pre-commit script:

#!/bin/bash
for f in .git/hooks/pre-commit.d/*; do
    if [ -x "$f" ]; then
        if ! "$f"; then
            echo "DID NOT COMMIT YOUR CHANGES!";
            exit 1
        fi
    fi
done

One of the executables in pre-commit.d is a python script (pre-commit-pylint.py) that starts with:

#!/usr/bin/env python
import pylint

pylint is installed on my virtualenv. My problem is that git runs pre-commit prepending /usr/libexec/git-core:/usr/bin to $PATH, so even if my virtualenv is activated the pre-commit.d/pre-commit-pylint.py script runs with the system /usr/bin/python (instead of running with the virtualenv python).

I want to have hooks that are compatible for developers that are not using virtualenv. Is there any way to run my python script with virtualenv transparently (ie, staying compatible with developers that are using their system python)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T15:13:41+00:00Added an answer on May 28, 2026 at 3:13 pm

    You can check in your pre-commit script for the $VIRTUAL_ENV variable and prepend it to $PATH accordingly:

    #!/bin/bash
    
    if [ -n $VIRTUAL_ENV ]; then
        PATH=$VIRTUAL_ENV/bin:$PATH
    fi
    
    for f in .git/hooks/pre-commit.d/*; do
        if [ -x "$f" ]; then
            if ! "$f"; then
                echo "DID NOT COMMIT YOUR CHANGES!";
                exit 1
            fi
        fi
    done
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following in my .git/hooks/pre-commit file #!/bin/sh exec c:/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -ExecutionPolicy RemoteSigned -Command
I have this simple php script <?php echo '<pre>'; // Outputs all the result
Using this hook with VisualSVN Server, added to the Repository/hooks folder as pre-commit.bat. My
How do you manage git pre/post commit hooks across various platforms (say, *nix and
i'm trying to write a SVN pre-commit hook script in Linux Bash that will
I'm running this small C# test program launched from a pre-commit batch file private
Basically what this does is fadeIn pre-existing divs and then loads an image. When
I am trying to write a pre-commit hook script that will alter a specific
I wrote the following pre-commit script for SVN to validate that a user has
There is already a similar Hosted Solution for Version Control — with pre-commit hooks?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.