Python 2 is required to develop GitLab

Summary

Python 2 is required to develop GitLab since node-sass 4.12.0 requires node-gyp@3.8.0, which requires Python 2 on its installation. But in many recent Linux distributions, we do not have Python 2, so yarn install would fail.

Log

$ yarn
yarn install v1.22.5
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/5] Validating package.json...
[2/5] Resolving packages...
warning Resolution field "ts-jest@24.0.0" is incompatible with requested version "ts-jest@^23.10.5"
[3/5] Fetching packages...
info fsevents@2.1.3: The platform "linux" is incompatible with this module.
info "fsevents@2.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@1.2.13: The platform "linux" is incompatible with this module.
info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
[4/5] Linking dependencies...
warning " > monaco-yaml@2.4.1" has incorrect peer dependency "monaco-editor@^0.19.2".
warning "@gitlab/eslint-plugin > eslint-plugin-jest > @typescript-eslint/experimental-utils > @typescript-eslint/typescript-estree > tsutils@3.17.1" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
warning " > eslint-import-resolver-jest@2.1.2" has unmet peer dependency "eslint-plugin-import@>=1.4.0".
warning " > eslint-import-resolver-webpack@0.12.1" has unmet peer dependency "eslint-plugin-import@>=1.4.0".
[5/5] Building fresh packages...
[1/6] ⠄ bootstrap-vue
[-/6] ⠄ waiting...
[-/6] ⠄ waiting...
[6/6] ⠄ nodemon
error /home/tnir/gdk/gitlab/node_modules/node-sass: Command failed.
Exit code: 1
Command: node scripts/build.js
Arguments:
Directory: /home/tnir/gdk/gitlab/node_modules/node-sass
Output:
Building: /home/tnir/.nvm/versions/node/v14.13.0/bin/node /home/tnir/gdk/gitlab/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [
gyp verb cli   '/home/tnir/.nvm/versions/node/v14.13.0/bin/node',
gyp verb cli   '/home/tnir/gdk/gitlab/node_modules/node-gyp/bin/node-gyp.js',
gyp verb cli   'rebuild',
gyp verb cli   '--verbose',
gyp verb cli   '--libsass_ext=',
gyp verb cli   '--libsass_cflags=',
gyp verb cli   '--libsass_ldflags=',
gyp verb cli   '--libsass_library='
gyp verb cli ]
gyp info using node-gyp@3.8.0
gyp info using node@14.13.0 | linux | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed     at getNotFoundError (/home/tnir/gdk/gitlab/node_modules/which/which.js:13:12)
gyp verb `which` failed     at F (/home/tnir/gdk/gitlab/node_modules/which/which.js:68:19)
gyp verb `which` failed     at E (/home/tnir/gdk/gitlab/node_modules/which/which.js:80:29)
gyp verb `which` failed     at /home/tnir/gdk/gitlab/node_modules/which/which.js:89:16
gyp verb `which` failed     at /home/tnir/gdk/gitlab/node_modules/isexe/index.js:42:5
gyp verb `which` failed     at /home/tnir/gdk/gitlab/node_modules/isexe/mode.js:8:5
gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:177:21)
gyp verb `which` failed  python2 Error: not found: python2
gyp verb `which` failed     at getNotFoundError (/home/tnir/gdk/gitlab/node_modules/which/which.js:13:12)
gyp verb `which` failed     at F (/home/tnir/gdk/gitlab/node_modules/which/which.js:68:19)
gyp verb `which` failed     at E (/home/tnir/gdk/gitlab/node_modules/which/which.js:80:29)
gyp verb `which` failed     at /home/tnir/gdk/gitlab/node_modules/which/which.js:89:16
gyp verb `which` failed     at /home/tnir/gdk/gitlab/node_modules/isexe/index.js:42:5
gyp verb `which` failed     at /home/tnir/gdk/gitlab/node_modules/isexe/mode.js:8:5
gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:177:21) {
gyp verb `which` failed   code: 'ENOENT'
gyp verb `which` failed }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` failed Error: not found: python
gyp verb `which` failed     at getNotFoundError (/home/tnir/gdk/gitlab/node_modules/which/which.js:13:12)
gyp verb `which` failed     at F (/home/tnir/gdk/gitlab/node_modules/which/which.js:68:19)
gyp verb `which` failed     at E (/home/tnir/gdk/gitlab/node_modules/which/which.js:80:29)
gyp verb `which` failed     at /home/tnir/gdk/gitlab/node_modules/which/which.js:89:16
gyp verb `which` failed     at /home/tnir/gdk/gitlab/node_modules/isexe/index.js:42:5
gyp verb `which` failed     at /home/tnir/gdk/gitlab/node_modules/isexe/mode.js:8:5
gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:177:21)
gyp verb `which` failed  python Error: not found: python
gyp verb `which` failed     at getNotFoundError (/home/tnir/gdk/gitlab/node_modules/which/which.js:13:12)
gyp verb `which` failed     at F (/home/tnir/gdk/gitlab/node_modules/which/which.js:68:19)
gyp verb `which` failed     at E (/home/tnir/gdk/gitlab/node_modules/which/which.js:80:29)
gyp verb `which` failed     at /home/tnir/gdk/gitlab/node_modules/which/which.js:89:16
gyp verb `which` failed     at /home/tnir/gdk/gitlab/node_modules/isexe/index.js:42:5
gyp verb `which` failed     at /home/tnir/gdk/gitlab/node_modules/isexe/mode.js:8:5
gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:177:21) {
gyp verb `which` failed   code: 'ENOENT'
gyp verb `which` failed }
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at PythonFinder.failNoPython (/home/tnir/gdk/gitlab/node_modules/node-gyp/lib/configure.js:484:19)
gyp ERR! stack     at PythonFinder.<anonymous> (/home/tnir/gdk/gitlab/node_modules/node-gyp/lib/configure.js:406:16)
gyp ERR! stack     at F (/home/tnir/gdk/gitlab/node_modules/which/which.js:68:16)
gyp ERR! stack     at E (/home/tnir/gdk/gitlab/node_modules/which/which.js:80:29)
gyp ERR! stack     at /home/tnir/gdk/gitlab/node_modules/which/which.js:89:16
gyp ERR! stack     at /home/tnir/gdk/gitlab/node_modules/isexe/index.js:42:5
gyp ERR! stack     at /home/tnir/gdk/gitlab/node_modules/isexe/mode.js:8:5
gyp ERR! stack     at FSReqCallback.oncomplete (fs.js:177:21)
gyp ERR! System Linux 5.4.0-1025-gcp
gyp ERR! command "/home/tnir/.nvm/versions/node/v14.13.0/bin/node" "/home/tnir/gdk/gitlab/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /home/tnir/gdk/gitlab/node_modules/node-sass
gyp ERR! node -v v14.13.0

Python 3 did not help it

Even with export PYTHON=$(which python3), I was not able to fix it.

$ yarn
yarn install v1.22.5
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/5] Validating package.json...
[2/5] Resolving packages...
warning Resolution field "ts-jest@24.0.0" is incompatible with requested version "ts-jest@^23.10.5"
[3/5] Fetching packages...
info fsevents@2.1.3: The platform "linux" is incompatible with this module.
info "fsevents@2.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@1.2.13: The platform "linux" is incompatible with this module.
info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
[4/5] Linking dependencies...
warning " > monaco-yaml@2.4.1" has incorrect peer dependency "monaco-editor@^0.19.2".
warning "@gitlab/eslint-plugin > eslint-plugin-jest > @typescript-eslint/experimental-utils > @typescript-eslint/typescript-estree > tsutils@3.17.1" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
warning " > eslint-import-resolver-jest@2.1.2" has unmet peer dependency "eslint-plugin-import@>=1.4.0".
warning " > eslint-import-resolver-webpack@0.12.1" has unmet peer dependency "eslint-plugin-import@>=1.4.0".
[5/5] Building fresh packages...
[1/6] ⢀ bootstrap-vue
[-/6] ⢀ waiting...
[6/6] ⢀ nodemon
[-/6] ⢀ waiting...
error /home/tnir/gdk/gitlab/node_modules/node-sass: Command failed.
Exit code: 1
Command: node scripts/build.js
Arguments:
Directory: /home/tnir/gdk/gitlab/node_modules/node-sass
Output:
Building: /home/tnir/.nvm/versions/node/v14.13.0/bin/node /home/tnir/gdk/gitlab/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [
gyp verb cli   '/home/tnir/.nvm/versions/node/v14.13.0/bin/node',
gyp verb cli   '/home/tnir/gdk/gitlab/node_modules/node-gyp/bin/node-gyp.js',
gyp verb cli   'rebuild',
gyp verb cli   '--verbose',
gyp verb cli   '--libsass_ext=',
gyp verb cli   '--libsass_cflags=',
gyp verb cli   '--libsass_ldflags=',
gyp verb cli   '--libsass_library='
gyp verb cli ]
gyp info using node-gyp@3.8.0
gyp info using node@14.13.0 | linux | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "/usr/bin/python3" in the PATH
gyp verb `which` succeeded /usr/bin/python3 /usr/bin/python3
gyp ERR! configure error
gyp ERR! stack Error: Command failed: /usr/bin/python3 -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack   File "<string>", line 1
gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack                       ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:308:12)
gyp ERR! stack     at ChildProcess.emit (events.js:314:20)
gyp ERR! stack     at maybeClose (internal/child_process.js:1047:16)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
gyp ERR! System Linux 5.4.0-1025-gcp
gyp ERR! command "/home/tnir/.nvm/versions/node/v14.13.0/bin/node" "/home/tnir/gdk/gitlab/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /home/tnir/gdk/gitlab/node_modules/node-sass
gyp ERR! node -v v14.13.0

Environments

  • git: 3df1baec
  • OS: Ubuntu "20.04.1 LTS (Focal Fossa)"
  • Node.js (node --version): v14.13.0
  • Yarn (yarn --version): 1.22.5
  • GitLab Development Kit

Possible fixes