Skip to content

Bug located in ansys license header hook #401

@dipinknair

Description

@dipinknair

🔍 Before submitting the issue

  • I have searched among the existing issues
  • I am using a Python virtual environment

🐞 Description of the bug

Windows blocking the symlink that the add-license-headers pre‑commit hook tries to create under .reuse/templates. On Windows, creating a symbolic link requires either administrator privileges or Developer Mode (or an explicit user right), otherwise you get WinError 1314: A required privilege is not held by the client.
The Ansys hook intentionally creates symlinks from its packaged assets (e.g., ...site-packages\ansys\pre_commit_hooks\assets.reuse\templates\ansys.jinja2) into your repo (.reuse/templates/ansys.jinja2). That’s happening in link_assets() / mkdirs_and_link() inside ansys.pre_commit_hooks.add_license_headers, which uses Path.symlink_to(...).

Add License Headers......................................................Failed
- hook id: add-license-headers
- exit code: 1

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\user\.cache\pre-commit\repo5s85p_69\py_env-python3\Scripts\add-license-headers.EXE\__main__.py", line 5, in <module>
  File "C:\Users\user\.cache\pre-commit\repo5s85p_69\py_env-python3\Lib\site-packages\ansys\pre_commit_hooks\add_license_headers.py", line 800, in main
    link_assets(assets, git_root, args)
  File "C:\Users\user\.cache\pre-commit\repo5s85p_69\py_env-python3\Lib\site-packages\ansys\pre_commit_hooks\add_license_headers.py", line 215, in link_assets
    mkdirs_and_link(value["path"], hook_asset_dir, repo_asset_dir, value["default_file"])
  File "C:\Users\user\.cache\pre-commit\repo5s85p_69\py_env-python3\Lib\site-packages\ansys\pre_commit_hooks\add_license_headers.py", line 280, in mkdirs_and_link
    dest.symlink_to(src)
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\pathlib.py", line 1386, in symlink_to
    os.symlink(target, self, target_is_directory)
OSError: [WinError 1314] A required privilege is not held by the client: 'C:\\Users\\user\\.cache\\pre-commit\\repo5s85p_69\\py_env-python3\\Lib\\site-packages\\ansys\\pre_commit_hooks\\assets\\.reuse\\templates\\ansys.jinja2' -> 'D:\\01_Repos\\PyMechanical-group\\01\\pymechanical\\.reuse\\templates\\ansys.jinja2'

📝 Steps to reproduce

I am not sure how to reproduce it but it started appearing after working with new system(laptop)

💻 Which operating system are you using?

Windows

📀 Which ANSYS version are you using?

No response

🐍 Which Python version are you using?

3.12

📦 Installed packages

NA.

Can be reproduced in pymechanical environment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions