Skip to content

Unable to build nodejs #30949

@lbh8srv68

Description

@lbh8srv68
  • Version: master branch from the github repo
  • Platform: windows
  • Subsystem: build

Installed python 2.7 and python 3.6 and added both pythons to PATH and started vcbuild.bat, and got error:

Looking for Python
Python found in C:\Program Files\Python27\\python.exe
Looking for NASM
Looking for Visual Studio 2019
Looking for Visual Studio 2017
Found MSVS version 15.0
configure  --dest-cpu=x64
Node.js configure: Found Python 2.7.0...
Traceback (most recent call last):
  File "configure", line 26, in <module>
    import configure
  File "C:\nodejs\node\configure.py", line 1683, in <module>
    configure_intl(output)
  File "C:\nodejs\node\configure.py", line 1550, in configure_intl
    with bz2.BZ2File(compressed_data, 'rb') as inf:
AttributeError: __exit__
Failed to create vc project files.

Now the questions are:

  1. Why does it fail?
  2. Why does it use python 2 instead of python 3 while documentation says "If both are installed Python 3 will be used. If only Python 2 is available it will be used instead."
  3. Why does it have two backslashes in C:\Program Files\Python27\\python.exe?

Google search tells me that BZ2File does not support the context manager protocol. The following patch fixes the issue for me:

--- a/configure.py
+++ b/configure.py
@@ -1547,8 +1547,11 @@ def configure_intl(o):
     os.mkdir(icu_tmp_path)
     icu_data_path = os.path.join(icu_tmp_path, icu_data_file_l)
     with open(icu_data_path, 'wb') as outf:
-        with bz2.BZ2File(compressed_data, 'rb') as inf:
+        inf = bz2.BZ2File(compressed_data, 'rb')
+        try:
             shutil.copyfileobj(inf, outf)
+        finally:
+            inf.close()
     # Now, proceed..

   # relative to dep..

Should this fix be added to the master?

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildIssues and PRs related to build files or the CI.windowsIssues and PRs related to the Windows platform.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions