Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Python2 regression with 1.15.3 #698

Open
1 task done
Hufschmidt opened this issue Mar 14, 2017 · 4 comments · Fixed by #703
Open
1 task done

Python2 regression with 1.15.3 #698

Hufschmidt opened this issue Mar 14, 2017 · 4 comments · Fixed by #703

Comments

@Hufschmidt
Copy link

Hufschmidt commented Mar 14, 2017

Prerequisites

Description

It seems like b364c3c introduced a regression for Arch-Linux users, as node-gyp tries to use python3 instead of python2 when beeing executed via apm.

This is the same issue as with #95, but due to the aforementioned commit the workarounds export PYTHON=python2 or npm config set python /usr/bin/python2 -g do no work anymore.

Steps to Reproduce

Method 1

  1. Boot into an arch-linux system (eg. Manjaro LiveCD)
  2. Install atom-editor from AUR (Version 1.15.0 at the time of this writing)
  3. Install git-blame via apm (which uses node-gyp)

Method 2

  1. Temporary symlink /usr/bin/python to /usr/bin/python3 instead of /usr/bin/python2.
  2. Try (re-)installing git-blame via apm (which uses node-gyp)

Expected behavior: git-blame installs

Actual behavior: git blame fails with

$ apm install git-blame
Installing git-blame to /home/hufschmt/.atom/packages ✗

> runas@3.1.1 install /tmp/apm-install-dir-117214-7034-190qczt/node_modules/git-blame/node_modules/runas                                                                                                               
> node-gyp rebuild                                                                                                                                                                                                     

/tmp/apm-install-dir-117214-7034-190qczt                                                                                                                                                                               
└── (empty)                                                                                                                                                                                                            


gyp ERR! configure error                                                                                                                                                                                               
gyp ERR! stack Error: Python executable "/usr/share/atom/resources/app/apm/bin/python-interceptor.sh" is v3.6.0, which is not supported by gyp.                                                                        
gyp ERR! stack You can pass the --python switch to point to Python >= v2.5.0 & < 3.0.0.                                                                                                                                
gyp ERR! stack     at failPythonVersion (/usr/share/atom/resources/app/apm/node_modules/node-gyp/lib/configure.js:454:14)                                                                                              
gyp ERR! stack     at /usr/share/atom/resources/app/apm/node_modules/node-gyp/lib/configure.js:443:9                                                                                                                   
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:204:7)                                                                                                                                                
gyp ERR! stack     at emitTwo (events.js:87:13)                                                                                                                                                                        
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)                                                                                                                                                              
gyp ERR! stack     at maybeClose (internal/child_process.js:827:16)                                                                                                                                                    
gyp ERR! stack     at Socket.<anonymous> (internal/child_process.js:319:11)                                                                                                                                            
gyp ERR! stack     at emitOne (events.js:77:13)                                                                                                                                                                        
gyp ERR! stack     at Socket.emit (events.js:169:7)                                                                                                                                                                    
gyp ERR! stack     at Pipe._onclose (net.js:477:12)                                                                                                                                                                    
gyp ERR! System Linux 4.10.1-1-MANJARO                                                                                                                                                                                 
gyp ERR! command "/usr/share/atom/resources/app/apm/bin/node" "/usr/share/atom/resources/app/apm/node_modules/.bin/node-gyp" "rebuild"
gyp ERR! cwd /tmp/apm-install-dir-117214-7034-190qczt/node_modules/git-blame/node_modules/runas
gyp ERR! node -v v4.4.5
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok 
[...]

Reproduces how often: Always

Versions

$ apm --version
apm  1.15.3
npm  3.10.5
node 4.4.5 x64
python 3.6.0
git 2.12.0
$ atom --version
Atom    : 1.15.0
Electron: 1.3.13
Chrome  : 52.0.2743.82
Node    : 6.5.0

OS: Manjaro (based on Arch-Linux)

Additional Information

Dirty workaround:
Uncomment export PYTHON="${binDir}/python-interceptor.sh" in /usr/bin/apm, this yields a working build-chain with:

$ apm --version
apm  1.15.3
npm  3.10.5
node 4.4.5 x64
python 2.7.13
git 2.12.0

Suggested fix
Make python-interceptor.sh use the python-executable set via environment variable instead of hard-coding it to python.

Or read the value from the --python switch, such that the fix matches the one given by node-gyp. 😊

@MoritzKn
Copy link

MoritzKn commented Apr 1, 2017

This also occurs when building Atom from source.
In the Arch section of the the build instructions for Linux it says one should export PYTHON=/usr/bin/python2. However because this environment variable is ignored by the mentioned python-interceptor.sh script, It will still use /usr/bin/python which under Arch Linux links to /usr/bin/python3.
I could work around this problem by changing /usr/bin/python from linking to /usr/bin/python3 to link to /usr/bin/python2. But this no real solution.

How to reproduce this

  1. Make /usr/bin/python link to something other then python2 (like it is on Arch Linux)
  2. Set the PYTHON environment variable to the real location of python2
  3. Build Atom from source

This will cause an error like this one:

$ git clone https://github.com/atom/atom.git
$ cd atom
$ export PYTHON=/usr/bin/python2
$ script/build
Node:	v6.10.1
Npm:	v4.4.4
Installing script dependencies
prebuild-install info begin Prebuild-install version 2.1.1
prebuild-install info looking for local prebuild @ prebuilds/leveldown-v1.6.0-node-v48-linux-x64.tar.gz
prebuild-install info looking for cached prebuild @ /home/moritz/.npm/_prebuilds/https-github.com-level-leveldown-releases-download-v1.6.0-leveldown-v1.6.0-node-v48-linux-x64.tar.gz
prebuild-install info found cached prebuild 
prebuild-install info unpacking @ /home/moritz/.npm/_prebuilds/https-github.com-level-leveldown-releases-download-v1.6.0-leveldown-v1.6.0-node-v48-linux-x64.tar.gz
prebuild-install info unpack resolved to /home/moritz/code/atom/atom/script/node_modules/leveldown/build/Release/leveldown.node
prebuild-install info unpack required /home/moritz/code/atom/atom/script/node_modules/leveldown/build/Release/leveldown.node successfully
prebuild-install info install Prebuild successfully installed!
Installing apm
../src/onig-string.cc: In Konstruktor »OnigString::OnigString(v8::Local<v8::String>)«:
../src/onig-string.cc:25:40: Warnung: Vergleich zwischen vorzeichenbehafteten und vorzeichenlosen Ganzzahlausdrücken [-Wsign-compare]
   hasMultiByteChars = (value->Length() != utf8_length_);
                        ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
../deps/libgit2/deps/zlib/inflate.c: In Funktion »inflateMark«:
../deps/libgit2/deps/zlib/inflate.c:1507:61: Warnung: left shift of negative value [-Wshift-negative-value]
     if (strm == Z_NULL || strm->state == Z_NULL) return -1L << 16;
                                                             ^~
gyp ERR! configure error 
gyp ERR! stack Error: Command failed: /home/moritz/code/atom/atom/apm/node_modules/atom-package-manager/bin/python-interceptor.sh -c import platform; print(platform.python_version());
gyp ERR! stack /home/moritz/code/atom/atom/apm/node_modules/atom-package-manager/bin/python-interceptor.sh: Zeile 40: exec: python: Nicht gefunden.
gyp ERR! stack 
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:206:12)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at maybeClose (internal/child_process.js:877:16)
gyp ERR! stack     at Socket.<anonymous> (internal/child_process.js:334:11)
gyp ERR! stack     at emitOne (events.js:96:13)
gyp ERR! stack     at Socket.emit (events.js:188:7)
gyp ERR! stack     at Pipe._handle.close [as _onclose] (net.js:498:12)
gyp ERR! System Linux 4.10.6-1-ARCH
gyp ERR! command "/home/moritz/code/atom/atom/apm/node_modules/atom-package-manager/bin/node" "/home/moritz/code/atom/atom/apm/node_modules/atom-package-manager/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/moritz/code/atom/atom/apm/node_modules/atom-package-manager/node_modules/oniguruma
gyp ERR! node -v v6.9.5
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok 

npm ERR! Linux 4.10.6-1-ARCH
npm ERR! argv "/home/moritz/code/atom/atom/apm/node_modules/atom-package-manager/bin/node" "/home/moritz/code/atom/atom/apm/node_modules/atom-package-manager/node_modules/.bin/npm" "rebuild"
npm ERR! node v6.9.5
npm ERR! npm  v3.10.5
npm ERR! code ELIFECYCLE
npm ERR! oniguruma@6.1.1 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the oniguruma@6.1.1 install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the oniguruma package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs oniguruma
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls oniguruma
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/moritz/code/atom/atom/apm/node_modules/atom-package-manager/npm-debug.log
module.js:471
    throw err;
    ^

Error: Cannot find module 'node-gyp/bin/node-gyp'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.resolve (internal/module.js:27:19)
    at Install.module.exports.Install.installNode (/home/moritz/code/atom/atom/apm/node_modules/atom-package-manager/lib/install.js:103:67)
    at /home/moritz/code/atom/atom/apm/node_modules/atom-package-manager/lib/install.js:3:59
    at fn (/home/moritz/code/atom/atom/apm/node_modules/atom-package-manager/node_modules/async/lib/async.js:582:34)
    at Immediate.<anonymous> (/home/moritz/code/atom/atom/apm/node_modules/atom-package-manager/node_modules/async/lib/async.js:498:34)
    at runCallback (timers.js:649:20)
    at tryOnImmediate (timers.js:622:5)
    at processImmediate [as _immediateCallback] (timers.js:594:5)
child_process.js:504
    throw err;
    ^

Error: Command failed: /home/moritz/code/atom/atom/apm/node_modules/atom-package-manager/bin/apm --loglevel=error install
    at checkExecSyncError (child_process.js:481:13)
    at Object.execFileSync (child_process.js:501:13)
    at module.exports (/home/moritz/code/atom/atom/script/lib/install-atom-dependencies.js:15:16)
    at Object.<anonymous> (/home/moritz/code/atom/atom/script/bootstrap:28:1)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)

@jaromero
Copy link

Arch user here as well. I was able to work around this by applying the following patch:

diff --git a/bin/python-interceptor.sh b/bin/python-interceptor.sh
index 7ce1965..12cc72f 100755
--- a/bin/python-interceptor.sh
+++ b/bin/python-interceptor.sh
@@ -34,9 +34,9 @@ case $1 in
       ARGS+=("--format=safemake.py")
     fi
 
-    exec python "${ARGS[@]}"
+    exec python2 "${ARGS[@]}"
     ;;
   *)
-    exec python "$@"
+    exec python2 "$@"
     ;;
 esac

and then also patching atom so it installs my locally patched apm (obviously replace file:///path/to/patched/apm with your actual path):

diff --git a/apm/package.json b/apm/package.json
index 732ab20..0e75319 100644
--- a/apm/package.json
+++ b/apm/package.json
@@ -6,6 +6,6 @@
     "url": "https://github.com/atom/atom.git"
   },
   "dependencies": {
-    "atom-package-manager": "1.16.1"
+    "atom-package-manager": "file:///path/to/patched/apm"
   }
 }

@smashwilson
Copy link
Contributor

This is still happening - it looks like setting ${PYTHON} isn't actually enough for all node-gyp builds.

@DeeDeeG
Copy link
Contributor

DeeDeeG commented Aug 11, 2020

I believe this can be closed now. As of #887, apm has Node-gyp 5.1, which supports both Python 2 and Python 3.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants