How to install pre-commit globally with uv - Stack Overflow

I have in the past installed pre-commit using:pipx install -g pre-commitI've moved to using uv no

I have in the past installed pre-commit using:

pipx install -g pre-commit

I've moved to using uv now, and I see documentation on the web that says to install something globally, you use almost the same syntax:

uv pip install -g pre-commit

However, when I run that, I get the following error:

❯ uv pip install -g pre-commit
error: unexpected argument '-g' found

  tip: to pass '-g' as a value, use '-- -g'

Usage: uv pip install [OPTIONS] <PACKAGE|--requirements <REQUIREMENTS>|--editable <EDITABLE>>

For more information, try '--help'.

I've read the tip, but that did not work for me either:

❯ uv pip install -- -g pre-commit
error: Failed to parse: `-g`
  Caused by: Expected package name starting with an alphanumeric character, found `-`
-g

Am I thinking about this all wrong? Should I be installing it into a venv that is 'global', in that I usually activate it? Something like a 'dev' venv that I activate in login, and then if a project needs it, it would be in that projects .venv folder.

My goal is to have it available for all my projects (many non-Python) so that the hooks run.

I have in the past installed pre-commit using:

pipx install -g pre-commit

I've moved to using uv now, and I see documentation on the web that says to install something globally, you use almost the same syntax:

uv pip install -g pre-commit

However, when I run that, I get the following error:

❯ uv pip install -g pre-commit
error: unexpected argument '-g' found

  tip: to pass '-g' as a value, use '-- -g'

Usage: uv pip install [OPTIONS] <PACKAGE|--requirements <REQUIREMENTS>|--editable <EDITABLE>>

For more information, try '--help'.

I've read the tip, but that did not work for me either:

❯ uv pip install -- -g pre-commit
error: Failed to parse: `-g`
  Caused by: Expected package name starting with an alphanumeric character, found `-`
-g

Am I thinking about this all wrong? Should I be installing it into a venv that is 'global', in that I usually activate it? Something like a 'dev' venv that I activate in login, and then if a project needs it, it would be in that projects .venv folder.

My goal is to have it available for all my projects (many non-Python) so that the hooks run.

Share Improve this question edited Mar 13 at 19:02 anthony sottile 70.7k19 gold badges191 silver badges243 bronze badges asked Mar 12 at 15:28 nycyniknycynik 7,5378 gold badges64 silver badges88 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

It's solvable by having a global python virtual env or installing pre-commit in whatever system python you happen to have.

I choose to have a dev virtual environment. I created it and then added pre-commit to that, so it's mostly there when I need it.

❯ . ~/.venv/dev/bin/activate
❯ uv pip install pre-commit
Using Python 3.10.12 environment at: /home/mike/.venv/dev
Resolved 9 packages in 197ms
Prepared 2 packages in 146ms
Installed 8 packages in 53ms
 + cfgv==3.4.0
 + distlib==0.3.9
 + filelock==3.17.0
 + identify==2.6.9
 + nodeenv==1.9.1
 + platformdirs==4.3.6
 + pre-commit==4.1.0
 + virtualenv==20.29.3

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744744530a4591223.html

相关推荐

  • How to install pre-commit globally with uv - Stack Overflow

    I have in the past installed pre-commit using:pipx install -g pre-commitI've moved to using uv no

    22小时前
    50

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信