GetPublii / Publii

The most intuitive Static Site CMS designed for SEO-optimized and privacy-focused websites.
https://getpublii.com
GNU General Public License v3.0
6.35k stars 419 forks source link

[Bug]: App build on Apple Silicon fails with `Error: Could not find any Python installation to use` #1743

Closed Valgard closed 3 weeks ago

Valgard commented 1 month ago

Operating system

macOS 15.0.1

Publii version

v.0.46.1

Post editor

None

Bug description

I want to debug a problem with my self-written plugin. That's why I checked out the source code from Publii and followed the instructions at https://github.com/GetPublii/Publii/wiki/App-build-process Unfortunately, when I run npm install, I always get the error message Could not find any Python installation to use and

version is 2.7.18 - should be >=3.6.0
THIS PYTHON VERSION IS NOT SUPPORTED.

when installing node-sass.

I am using an Apple MacBook Pro with an M2 processor and MacOS 15.0.1 and am using asdf as the version manager for Python.

XCode and XCode Command Line Tools are installed.

Steps to reproduce

# git clone https://github.com/GetPublii/Publii.git Publii
# cd Publii
# git checkout v.0.46.1
# npm install -g electron@31.3.1 electron-packager node-gyp gulp
# npm install

Relevant log output

npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'isbinaryfile@5.0.2',
npm WARN EBADENGINE   required: { node: '>= 18.0.0' },
npm WARN EBADENGINE   current: { node: 'v16.20.2', npm: '8.19.4' }
npm WARN EBADENGINE }
npm WARN deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs
npm WARN deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs
npm WARN deprecated consolidate@0.15.1: Please upgrade to consolidate v1.0.0+ as it has been modernized with several long-awaited fixes implemented. Maintenance is supported by Forward Email at https://forwardemail.net ; follow/watch https://github.com/ladjs/consolidate for updates and release changelog
npm WARN deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported
npm WARN deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported
npm WARN deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported
npm ERR! code 1
npm ERR! path /Users/valgard/Projects/checkouts/Publii/node_modules/node-sass
npm ERR! command failed
npm ERR! command sh -c -- node scripts/build.js
npm ERR! Binary found at /Users/valgard/Projects/checkouts/Publii/node_modules/node-sass/vendor/darwin-arm64-93/binding.node
npm ERR! Testing binary
npm ERR! Binary has a problem: Error: dlopen(/Users/valgard/Projects/checkouts/Publii/node_modules/node-sass/vendor/darwin-arm64-93/binding.node, 0x0001): tried: '/Users/valgard/Projects/checkouts/Publii/node_modules/node-sass/vendor/darwin-arm64-93/binding.node' (not a mach-o file), '/System/Volumes/Preboot/Cryptexes/OS/Users/valgard/Projects/checkouts/Publii/node_modules/node-sass/vendor/darwin-arm64-93/binding.node' (no such file), '/Users/valgard/Projects/checkouts/Publii/node_modules/node-sass/vendor/darwin-arm64-93/binding.node' (not a mach-o file)
npm ERR!     at Object.Module._extensions..node (node:internal/modules/cjs/loader:1282:18)
npm ERR!     at Module.load (node:internal/modules/cjs/loader:1076:32)
npm ERR!     at Function.Module._load (node:internal/modules/cjs/loader:911:12)
npm ERR!     at Module.require (node:internal/modules/cjs/loader:1100:19)
npm ERR!     at require (node:internal/modules/cjs/helpers:119:18)
npm ERR!     at module.exports (/Users/valgard/Projects/checkouts/Publii/node_modules/node-sass/lib/binding.js:19:10)
npm ERR!     at Object.<anonymous> (/Users/valgard/Projects/checkouts/Publii/node_modules/node-sass/lib/index.js:13:35)
npm ERR!     at Module._compile (node:internal/modules/cjs/loader:1198:14)
npm ERR!     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
npm ERR!     at Module.load (node:internal/modules/cjs/loader:1076:32) {
npm ERR!   code: 'ERR_DLOPEN_FAILED'
npm ERR! }
npm ERR! Building the binary locally
npm ERR! Building: /Users/valgard/.asdf/installs/nodejs/16.20.2/bin/node /Users/valgard/Projects/checkouts/Publii/node_modules/node-sass/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli   '/Users/valgard/.asdf/installs/nodejs/16.20.2/bin/node',
npm ERR! gyp verb cli   '/Users/valgard/Projects/checkouts/Publii/node_modules/node-sass/node_modules/node-gyp/bin/node-gyp.js',
npm ERR! gyp verb cli   'rebuild',
npm ERR! gyp verb cli   '--verbose',
npm ERR! gyp verb cli   '--libsass_ext=',
npm ERR! gyp verb cli   '--libsass_cflags=',
npm ERR! gyp verb cli   '--libsass_ldflags=',
npm ERR! gyp verb cli   '--libsass_library='
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp@8.4.1
npm ERR! gyp info using node@16.20.2 | darwin | arm64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb find Python Python is not set from command line or npm configuration
npm ERR! gyp verb find Python Python is not set from environment variable PYTHON
npm ERR! gyp verb find Python checking if "python3" can be used
npm ERR! gyp verb find Python - executing "python3" to get executable path
npm ERR! gyp verb find Python - "python3" is not in PATH or produced an error
npm ERR! gyp verb find Python checking if "python" can be used
npm ERR! gyp verb find Python - executing "python" to get executable path
npm ERR! gyp verb find Python - executable path is "/Users/valgard/.asdf/installs/python/2.7.18/bin/python"
npm ERR! gyp verb find Python - executing "/Users/valgard/.asdf/installs/python/2.7.18/bin/python" to get version
npm ERR! gyp verb find Python - version is "2.7.18"
npm ERR! gyp verb find Python - version is 2.7.18 - should be >=3.6.0
npm ERR! gyp verb find Python - THIS VERSION OF PYTHON IS NOT SUPPORTED
npm ERR! gyp ERR! find Python
npm ERR! gyp ERR! find Python Python is not set from command line or npm configuration
npm ERR! gyp ERR! find Python Python is not set from environment variable PYTHON
npm ERR! gyp ERR! find Python checking if "python3" can be used
npm ERR! gyp ERR! find Python - "python3" is not in PATH or produced an error
npm ERR! gyp ERR! find Python checking if "python" can be used
npm ERR! gyp ERR! find Python - executable path is "/Users/valgard/.asdf/installs/python/2.7.18/bin/python"
npm ERR! gyp ERR! find Python - version is "2.7.18"
npm ERR! gyp ERR! find Python - version is 2.7.18 - should be >=3.6.0
npm ERR! gyp ERR! find Python - THIS VERSION OF PYTHON IS NOT SUPPORTED
npm ERR! gyp ERR! find Python
npm ERR! gyp ERR! find Python **********************************************************
npm ERR! gyp ERR! find Python You need to install the latest version of Python.
npm ERR! gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
npm ERR! gyp ERR! find Python you can try one of the following options:
npm ERR! gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
npm ERR! gyp ERR! find Python   (accepted by both node-gyp and npm)
npm ERR! gyp ERR! find Python - Set the environment variable PYTHON
npm ERR! gyp ERR! find Python - Set the npm configuration variable python:
npm ERR! gyp ERR! find Python   npm config set python "/path/to/pythonexecutable"
npm ERR! gyp ERR! find Python For more information consult the documentation at:
npm ERR! gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
npm ERR! gyp ERR! find Python **********************************************************
npm ERR! gyp ERR! find Python
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Could not find any Python installation to use
npm ERR! gyp ERR! stack     at PythonFinder.fail (/Users/valgard/Projects/checkouts/Publii/node_modules/node-sass/node_modules/node-gyp/lib/find-python.js:330:47)
npm ERR! gyp ERR! stack     at PythonFinder.runChecks (/Users/valgard/Projects/checkouts/Publii/node_modules/node-sass/node_modules/node-gyp/lib/find-python.js:159:21)
npm ERR! gyp ERR! stack     at PythonFinder.<anonymous> (/Users/valgard/Projects/checkouts/Publii/node_modules/node-sass/node_modules/node-gyp/lib/find-python.js:266:16)
npm ERR! gyp ERR! stack     at PythonFinder.execFileCallback (/Users/valgard/Projects/checkouts/Publii/node_modules/node-sass/node_modules/node-gyp/lib/find-python.js:297:7)
npm ERR! gyp ERR! stack     at ChildProcess.exithandler (node:child_process:394:7)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack     at maybeClose (node:internal/child_process:1100:16)
npm ERR! gyp ERR! stack     at Socket.<anonymous> (node:internal/child_process:458:11)
npm ERR! gyp ERR! stack     at Socket.emit (node:events:513:28)
npm ERR! gyp ERR! stack     at Pipe.<anonymous> (node:net:301:12)
npm ERR! gyp ERR! System Darwin 24.0.0
npm ERR! gyp ERR! command "/Users/valgard/.asdf/installs/nodejs/16.20.2/bin/node" "/Users/valgard/Projects/checkouts/Publii/node_modules/node-sass/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd /Users/valgard/Projects/checkouts/Publii/node_modules/node-sass
npm ERR! gyp ERR! node -v v16.20.2
npm ERR! gyp ERR! node-gyp -v v8.4.1
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/valgard/.npm/_logs/2024-10-08T13_01_25_205Z-debug-0.log
dziudek commented 3 weeks ago

Please try first use node v.20.15.1 (it is defined in .nvmrc) - maybe it help

Valgard commented 3 weeks ago

Ahh right, I overlooked the .nvmrc and the node version defined in it. Also, I switched from Python 2.7 to Python 3.11. Python >= 3.12 won't work because distutils has been removed. Perhaps the wiki page https://github.com/GetPublii/Publii/wiki/App-build-process should be updated with the currently required versions.

dziudek commented 3 weeks ago

@Valgard - I have updated the wiki - it now should be corrected