Skip to content

setup.cfg prevent pre-commit to install #425

@wilfriedroset

Description

@wilfriedroset

For some reason I have a setup.cfg file in the root directory of my repo for my app where the parameter install_scripts is set to /usr/sbin. This prevent pre-commit to set up and crash.
Here is a repro in a fresh git repository containing only setup.cfg file and .pre-commit-config.yaml (for the install guide

$ mkdir repro; cd repro
$ git init
Dépôt Git vide initialisé dans /home/wilfried/repro/.git/
$ pre-commit clean
Cleaned /home/wilfried/.pre-commit.
$ pre-commit install
pre-commit installed at /home/wilfried/repro/.git/hooks/pre-commit
$ cat setup.cfg 
[install]
install_scripts=/usr/sbin
$ cat .pre-commit-config.yaml 
-   repo: git://github.com/pre-commit/pre-commit-hooks
    sha: v0.4.2
    hooks:
    -   id: trailing-whitespace

Now, with those two files setup, I try to run a simple pre-commit run which try to initiate the virtualenv.

$ pre-commit run --all-files
[INFO] Initializing environment for git://github.com/pre-commit/pre-commit-hooks.
[INFO] Installing environment for git://github.com/pre-commit/pre-commit-hooks.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: Command: ('/usr/bin/python', '-m', 'virtualenv', '/home/wilfried/.pre-commit/repoaXLSIv/py_env-default', '-p', '/usr/bin/python2.7')
Return code: 1
Expected return code: 0
Output: 
    New python executable in /home/wilfried/.pre-commit/repoaXLSIv/py_env-default/bin/python2.7
    Also creating executable in /home/wilfried/.pre-commit/repoaXLSIv/py_env-default/bin/python
    Installing setuptools, pip, wheel...
      Complete output from command /home/wilfried/.pre-...efault/bin/python2.7 - setuptools pip wheel:
    ...Installing setuptools, pip, wheel...done.
    Running virtualenv with interpreter /usr/bin/python2.7
    
Errors: 
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 2327, in 
        main()
      File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 711, in main
        symlink=options.symlink)
      File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 944, in create_environment
        download=download,
      File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 900, in install_wheel
        call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
      File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 792, in call_subprocess
        logger.notify('\n'.join(all_output) + '\n----------------------------------------')
      File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 199, in notify
        self.log(self.NOTIFY, msg, *args, **kw)
      File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 231, in log
        consumer.write(rendered+'\n')
    UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 2254: ordinal not in range(128)
    

Check the log at ~/.pre-commit/pre-commit.log

You'll find the content on pre-commit.log on pastebin.

Now the if I comment out the install_scripts parameter, everything works fine

$ cat setup.cfg 
[install]
#install_scripts=/usr/sbin
$ pre-commit clean
Cleaned /home/wilfried/.pre-commit.
$ pre-commit run --all-files
[INFO] Initializing environment for git://github.com/pre-commit/pre-commit-hooks.
[INFO] Installing environment for git://github.com/pre-commit/pre-commit-hooks.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
Trim Trailing Whitespace.............................(no files to check)Skipped

I'm running on a linux mint 18, with python 2.7.12 and pre-commit 0.9.2

$ python --version
Python 2.7.12
$ pre-commit --version
pre-commit 0.9.2

Let my know if you need anything else.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions