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

Unable to build nodejs #30949

Closed
lbh8srv68 opened this issue Dec 13, 2019 · 5 comments
Closed

Unable to build nodejs #30949

lbh8srv68 opened this issue Dec 13, 2019 · 5 comments
Labels
build Issues and PRs related to build files or the CI. windows Issues and PRs related to the Windows platform.

Comments

@lbh8srv68
Copy link

lbh8srv68 commented Dec 13, 2019

  • 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?

@pd4d10
Copy link
Contributor

pd4d10 commented Dec 14, 2019

  1. Why does it have two backslashes in C:\Program Files\Python27\python.exe?

It is probably because your python path has a trailing backslash. For compatible with no backslash case the full path would be something like %PATH%\python.exe.

I think this behavior could just be ignored if it does not cause other problems.

@ZYSzys ZYSzys added build Issues and PRs related to build files or the CI. windows Issues and PRs related to the Windows platform. labels Dec 14, 2019
@addaleax
Copy link
Member

Should this fix be added to the master?

I think that seems fine to me, but I’d wonder why it’s not failing for anybody else?

@lbh8srv68
Copy link
Author

I think this behavior could just be ignored if it does not cause other problems.

Sure. Questions 1 and 2 are more important. BTW, my python path does not have trailing slash, even if I change to the path to the exe it still has 2 slashes. But if it is unrelated, we can ignore it I agree.

Should this fix be added to the master?

I think that seems fine to me

so should a pr be opened?

@ghost ghost mentioned this issue Jan 5, 2020
2 tasks
@richardlau
Copy link
Member

Should this fix be added to the master?

I think that seems fine to me, but I’d wonder why it’s not failing for anybody else?

Probably https://bugs.python.org/issue24404 which says it was fixed from Python 2.7.1 onwards (the OP is using Python 2.7.0).

@jasnell
Copy link
Member

jasnell commented Jun 25, 2020

Unable to reproduce and there's been no further activity. Closing but we can reopen if necessary

@jasnell jasnell closed this as completed Jun 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Issues and PRs related to build files or the CI. windows Issues and PRs related to the Windows platform.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants