Skip to content
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

pre-commit requires system-installed dotnet #2314

Closed
Walluce opened this issue Mar 30, 2022 · 17 comments
Closed

pre-commit requires system-installed dotnet #2314

Walluce opened this issue Mar 30, 2022 · 17 comments
Labels

Comments

@Walluce
Copy link
Contributor

Walluce commented Mar 30, 2022

describe your issue

I was trying to write a commit-msg hook in dotnet and got this error:

AssertionError: For now, pre-commit requires system-installed dotnet

pre-commit --version

2.17.0

.pre-commit-config.yaml

# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
-   repo: c:\Dev\checkov\hook\my-hook
    rev: v1.0.1
    hooks:
    -   id: my-hook
        stages: [commit-msg]

default_language_version:
    dotnet: dotnet

default_stages: [commit, push, post-merge, post-checkout]
#fail_fast: true

Execution:

pre-commit run --verbose --commit-msg-filename .\msg.txt --hook-stage commit-msg my-hook

~/.cache/pre-commit/pre-commit.log (if present)

version information

pre-commit version: 2.17.0
git --version: git version 2.29.0.windows.1
sys.version:
    3.10.3 (tags/v3.10.3:a342a49, Mar 16 2022, 13:07:40) [MSC v.1929 64 bit (AMD64)]
sys.executable: C:\Users\user1p\AppData\Local\Programs\Python\Python310\python.exe
os.name: nt
sys.platform: win32

error information

An unexpected error has occurred: AssertionError: For now, pre-commit requires system-installed dotnet
Traceback (most recent call last):
  File "C:\Users\user1p\AppData\Local\Programs\Python\Python310\lib\site-packages\pre_commit\error_handler.py", line 70, in error_handler
    yield
  File "C:\Users\user1p\AppData\Local\Programs\Python\Python310\lib\site-packages\pre_commit\main.py", line 396, in main
    return run(args.config, store, args)
  File "C:\Users\user1p\AppData\Local\Programs\Python\Python310\lib\site-packages\pre_commit\commands\run.py", line 416, in run
    install_hook_envs(to_install, store)
  File "C:\Users\user1p\AppData\Local\Programs\Python\Python310\lib\site-packages\pre_commit\repository.py", line 224, in install_hook_envs
    _hook_install(hook)
  File "C:\Users\user1p\AppData\Local\Programs\Python\Python310\lib\site-packages\pre_commit\repository.py", line 82, in _hook_install
    lang.install_environment(
  File "C:\Users\user1p\AppData\Local\Programs\Python\Python310\lib\site-packages\pre_commit\languages\dotnet.py", line 42, in install_environment
    helpers.assert_version_default('dotnet', version)
  File "C:\Users\user1p\AppData\Local\Programs\Python\Python310\lib\site-packages\pre_commit\languages\helpers.py", line 70, in assert_version_default
    raise AssertionError(
AssertionError: For now, pre-commit requires system-installed dotnet
@asottile
Copy link
Member

the message is not wrong? is there something you don't understand about it?

@Walluce
Copy link
Contributor Author

Walluce commented Mar 30, 2022

I don't know what system-installed dotnet means. I don't mind installing it, but IMHO we need more information here as to what this means.

@asottile
Copy link
Member

do you have dotnet installed on your system?

@Walluce
Copy link
Contributor Author

Walluce commented Mar 30, 2022

Yes:

PS C:\Dev\checkov\checks> dotnet --version
6.0.200

@asottile
Copy link
Member

fill out the issue template?

@Walluce
Copy link
Contributor Author

Walluce commented Mar 30, 2022

What is system-installed? Is there another option, e.g. local install? How do I make sure it's system-installed?

@Walluce
Copy link
Contributor Author

Walluce commented Mar 30, 2022

fill out the issue template?
Apologies, I thought I did?

@asottile
Copy link
Member

asottile commented Mar 30, 2022

fill out the issue template?

Apologies, I thought I did?

you haven't shown your .pre-commit-config.yaml -- you put a command in that textbox for some reason

@Walluce
Copy link
Contributor Author

Walluce commented Mar 30, 2022

I didn't think it mattered, since I was testing only my new hook?

This is it:

# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
-   repo: c:\Dev\checkov\hook\my-hook
    rev: v1.0.1
    hooks:
    -   id: my-hook
        stages: [commit-msg]

default_language_version:
    dotnet: dotnet

default_stages: [commit, push, post-merge, post-checkout]
#fail_fast: true

@asottile
Copy link
Member

ok why do you have default_language_version: ?

@Walluce
Copy link
Contributor Author

Walluce commented Mar 30, 2022

I saw it one of the examples. I can definitely remove that.

@Walluce
Copy link
Contributor Author

Walluce commented Mar 30, 2022

That seems to have solved the issue, thank you!

@asottile
Copy link
Member

which example?

@Walluce
Copy link
Contributor Author

Walluce commented Mar 30, 2022

It was this example:

default_language_version:
    python: python3.7

https://pre-commit.com/#pre-commit-configyaml---top-level

It referred to python and not dotnet, but was thinking that maybe I could specify dotnet3.1 or dotnet6 or something, although I didn't see much in the documentation about what the valid options were

@asottile
Copy link
Member

yeah there are no such valid values for dotnet -- that's what the error message is for

@Walluce
Copy link
Contributor Author

Walluce commented Mar 30, 2022

Ok, thanks for solving my problem, but the error just isn't very clear, IMHO

@asottile
Copy link
Member

yeah I guess it's just weird that you would have reached for an option you didn't need to solve a problem you didn't have -- I've added the selected values in #2315

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants