ekalinin/nodeenv

Failed to download node at environment creation

g0di opened this issue · 2 comments

g0di commented

I'm working on a Windows machine which is behind a company proxy and have a bunch of self signed certificates in the Windows certificate store.

I've recently tried to use pyright on a project which is using nodeenv behind the scene to download node. However, as soon as I try to run pyright it fails with an error indicating that it failed downloading node.

I've tried to installed nodeenv and use it directly but I end up with the exact same error. I think this is caused by the proxy/certificates stuff of my company. I've tried to use the without_ssl = True in a ~/.nodeenvrc file and also passing the --ignore_ssl_certs without any success (I've tried all combinations of those options).

nodeenv env --ignore_ssl_certs --verbose
 * Install prebuilt node (20.4.0) .Failed to download from https://nodejs.org/download/release/v20.4.0/node-v20.4.0-win-x64.zip
..
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\TBEBGOD\Developement\myrepo\.venv\Scripts\nodeenv.EXE\__main__.py", line 7, in <module>
  File "C:\Users\TBEBGOD\Developement\myrepo\.venv\Lib\site-packages\nodeenv.py", line 1122, in main
    create_environment(env_dir, args)
  File "C:\Users\TBEBGOD\Developement\myrepo\.venv\Lib\site-packages\nodeenv.py", line 998, in create_environment
    install_node(env_dir, src_dir, args)
  File "C:\Users\TBEBGOD\Developement\myrepo\.venv\Lib\site-packages\nodeenv.py", line 755, in install_node
    install_node_wrapped(env_dir, src_dir, args)
  File "C:\Users\TBEBGOD\Developement\myrepo\.venv\Lib\site-packages\nodeenv.py", line 790, in install_node_wrapped
    copy_node_from_prebuilt(env_dir, src_dir, args.node)
  File "C:\Users\TBEBGOD\Developement\myrepo\.venv\Lib\site-packages\nodeenv.py", line 681, in copy_node_from_prebuilt
    src_folder, = glob.glob(src_folder_tpl)
    ^^^^^^^^^^^
ValueError: not enough values to unpack (expected 1, got 0)

This might be not a bug from nodeenv actually but I'm not sure what I can do from here.

nodeenv version: 1.8.0
python version: 3.10.11
System info

{
  "implementation_name": "cpython",
  "implementation_version": "3.10.11",
  "os_name": "nt",
  "platform_machine": "AMD64",
  "platform_release": "10",
  "platform_system": "Windows",
  "platform_version": "10.0.19044",
  "python_full_version": "3.10.11",
  "platform_python_implementation": "CPython",
  "python_version": "3.10",
  "sys_platform": "win32"
}

I think it’s an error that nodeenv continues, despite the download failing, then the glob.glob line fails due to not finding any folder.

g0di commented

Yep indeed this is a thing that nodeenv should not go further if the download fails. The thing is, I actually understood why this is not working on my company environment thanks to using another unrelated tool. In simple words, the download is blocked by company policy so there is nothing nodeenv can do here.

However, I would take advantage of that issue to raise that it could be interesting that:

  • Nodeenv does not go further when the download of node fails
  • Nodeenv provide (a way to get) more information about what actually happened during download. Using the --verbose flag does not help. Being able to see the details of the HTTP request/response performed behind the scene would greatly help because I would have seen the 403 Download blocked by policy error that way.