Skip to content

get_node_bin_url fails on Windows ARM64 #381

Closed

Description

@robmoss2k

When installing pre-commit hooks, I get the following error:

pre-commit installed at .git\hooks\pre-commit
[INFO] Installing environment for https://github.com/pre-commit/mirrors-eslint.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('C:\\Users\\me\\AppData\\Local\\pypoetry\\Cache\\virtualenvs\\project-ocqm_prM-py3.13\\Scripts\\python.exe', '-mnodeenv', '--prebuilt', '--clean-src', '\\\\?\\C:\\Users\\me\\.cache\\pre-commit\\repoh0bp6qr4\\node_env-default')
return code: 1
stdout: (none)
stderr:
     * Install prebuilt node (23.9.0)
    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\me\AppData\Local\pypoetry\Cache\virtualenvs\project-ocqm_prM-py3.13\Lib\site-packages\nodeenv.py", line 1548, in <module>
        main()
        ~~~~^^
      File "C:\Users\me\AppData\Local\pypoetry\Cache\virtualenvs\project-ocqm_prM-py3.13\Lib\site-packages\nodeenv.py", line 1130, in main
        create_environment(env_dir, args)
        ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
      File "C:\Users\me\AppData\Local\pypoetry\Cache\virtualenvs\project-ocqm_prM-py3.13\Lib\site-packages\nodeenv.py", line 1006, in create_environment
        install_node(env_dir, src_dir, args)
        ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\me\AppData\Local\pypoetry\Cache\virtualenvs\project-ocqm_prM-py3.13\Lib\site-packages\nodeenv.py", line 763, in install_node
        install_node_wrapped(env_dir, src_dir, args)
        ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\me\AppData\Local\pypoetry\Cache\virtualenvs\project-ocqm_prM-py3.13\Lib\site-packages\nodeenv.py", line 779, in install_node_wrapped
        node_url = get_node_bin_url(args.node)
      File "C:\Users\me\AppData\Local\pypoetry\Cache\virtualenvs\project-ocqm_prM-py3.13\Lib\site-packages\nodeenv.py", line 570, in get_node_bin_url
        'arch': archmap[platform.machine()],
                ~~~~~~~^^^^^^^^^^^^^^^^^^^^
    KeyError: 'ARM64'
Check the log at C:\Users\me\.cache\pre-commit\pre-commit.log

The fix appears relatively simple - use platform.machine().lower() instead of platform.machine() when accessing archmap. I've tested that locally but no doubt you guys will know better than I do.

PS C:\Users\me> C:\Python313\python.exe
Python 3.13.2 (tags/v3.13.2:4f8bb39, Feb  4 2025, 15:23:48) [MSC v.1942 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import platform
>>> print(platform.machine())
ARM64

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions