jeffvli / sonixd

A full-featured Subsonic/Jellyfin compatible desktop music player
GNU General Public License v3.0
1.87k stars 73 forks source link

Auto Light/Dark Mode Themes #368

Open Chaphasilor opened 2 years ago

Chaphasilor commented 2 years ago

Is your feature request related to a problem? Please describe.

I love to have applications set up in a way that they use light mode during the day and dark mode at night. Windows will automatically change the theme at sunset/sunrise, and most web or electron applications use the prefers-color-scheme media query to change the theme appropriately. Sonixd currently only has a single theme that can be configured, and the theming API doesn't support using pure CSS / media queries at the moment, so this is not possible.

Describe the solution you'd like

For the v1.0.0 rewrite, maybe it would be possible to support loading themes as CSS files. That would allow themes to define light and dark color schemes and switch between them automatically. It would also allow overwriting only part of the default theme.
However, the downside would be that this is a less configurable approach. It wouldn't be possible to mix&match different dark and light themes.

As an alternative, there could be two theme selectors, and a color-scheme selector. The two theme selectors would allow you to pick one theme as a dark theme (e.g. Default Dark) and one as a light theme (e.g. Default Light), and the color-scheme selector would allow you to choose between Light Theme, Dark Theme and System/Auto Theme, where the latter would switch between the two themes depending on the OS setting.

Describe alternatives you've considered

Given that the themes are currently defined in JSON, I don't think there's a way to implement this functionality without any code changes.

Additional context

For automatically changing the theme (System/Auto Theme setting), this code snippet could be used:

window.matchMedia("(prefers-color-scheme: dark)").addListener(
  e => e.matches && dispatch(setTheme(selectedDarkTheme));
);
window.matchMedia("(prefers-color-scheme: light)").addListener(
  e => e.matches && dispatch(setTheme(selectedLightTheme));
);

This feature would probably require two new dropdowns in the Look&Feel panel and ~10 additional LoC (for the alternative approach), so I believe it wouldn't be too much effort to slip it into the planned features for v1.0.0.

If you want me to, and still accept PRs for v0.x.x, I'd be happy do try and make a PR for this :)

jeffvli commented 2 years ago

For the v1.0.0 rewrite, maybe it would be possible to support loading themes as CSS files. That would allow themes to define light and dark color schemes and switch between them automatically. It would also allow overwriting only part of the default theme. However, the downside would be that this is a less configurable approach. It wouldn't be possible to mix&match different dark and light themes.

Using styled-components, I slacked on tagging all the DOM elements with ids and classnames, but with the rewrite I'll most likely do this to allow for alternative methods of theming. I'm thinking of using css variables for the theme's color scheme, and then allowing a s(css) file to be attached to the theme as well.

As an alternative, there could be two theme selectors, and a color-scheme selector. The two theme selectors would allow you to pick one theme as a dark theme (e.g. Default Dark) and one as a light theme (e.g. Default Light), and the color-scheme selector would allow you to choose between Light Theme, Dark Theme and System/Auto Theme, where the latter would switch between the two themes depending on the OS setting.

This is a good idea. We definitely want it configurable since there's more than just the default light/dark themes.

This feature would probably require two new dropdowns in the Look&Feel panel and ~10 additional LoC (for the alternative approach), so I believe it wouldn't be too much effort to slip it into the planned features for v1.0.0.

If you want me to, and still accept PRs for v0.x.x, I'd be happy do try and make a PR for this :)

PRs are still appreciated for v0.x.x! Most of my time is spent working on the rewrite, so new features from me for the current version are on hold.

Chaphasilor commented 2 years ago

Okay, so I've been trying to get a development setup going for sonixd, but I've never used electron. Trying to set this up on GitHub Codespaces or Docker results in build errors for node-gyp/gyp during electron-rebuild, which is executed automatically after running yarn install. There are also warnings about unmet dependencies.

I'm using a docker image based on Debian Buster and Node 14.20 and the main branch.
Is there anything I'm doing wrong? Could you maybe try and see if you can recreate my problem, or package your dev environment as a Docker container? I would like to make a PR, but without testing the changes beforehand there really is no point, and I can't seem to get this working...
I've noticed you have a docker-based setup for the rewrite, so maybe I could add the feature there, once you get to that point.

jeffvli commented 2 years ago

Are these the errors you're getting?

Exit code: 1
Command: node-gyp rebuild
Arguments:
Directory: /code/sonixd/node_modules/register-scheme
Output:
gyp info it worked if it ends with ok
gyp info using node-gyp@5.1.0
gyp info using node@14.20.0 | linux | x64
gyp ERR! find Python
gyp ERR! find Python Python is not set from command line or npm configuration
gyp ERR! find Python Python is not set from environment variable PYTHON
gyp ERR! find Python checking if \"python\" can be used
gyp ERR! find Python - \"python\" is not in PATH or produced an error
gyp ERR! find Python checking if \"python2\" can be used
gyp ERR! find Python - \"python2\" is not in PATH or produced an error
gyp ERR! find Python checking if \"python3\" can be used
gyp ERR! find Python - \"python3\" is not in PATH or produced an error
gyp ERR! find Python
gyp ERR! find Python **********************************************************
gyp ERR! find Python You need to install the latest version of Python.
gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
gyp ERR! find Python you can try one of the following options:
gyp ERR! find Python - Use the switch --python=\"/path/to/pythonexecutable\"
gyp ERR! find Python   (accepted by both node-gyp and npm)
gyp ERR! find Python - Set the environment variable PYTHON
gyp ERR! find Python - Set the npm configuration variable python:
gyp ERR! find Python   npm config set python \"/path/to/pythonexecutable\"
gyp ERR! find Python For more information consult the documentation at:
gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
gyp ERR! find Python **********************************************************
gyp ERR! find Python
gyp ERR! configure error
gyp ERR! stack Error: Could not find any Python installation to use
gyp ERR! stack     at PythonFinder.fail 

You'll need to install python in the container with apt install python3 since it's required by node-gyp. I just tested on a debian buster container.

Chaphasilor commented 2 years ago

Nope, python3 is found

here's the full error log (I only ran `yarn install` myself):
```sh-session # node ➜ /workspaces/sonixd (main ✗) $ yarn install yarn install v1.22.19 [1/4] Resolving packages... [2/4] Fetching packages... [3/4] Linking dependencies... warning " > styled-components@5.3.5" has unmet peer dependency "react-is@>= 16.8.0". warning " > electron-redux@1.5.4" has unmet peer dependency "redux@^4.0.1". warning "rsuite > react-virtualized@9.22.3" has incorrect peer dependency "react@^15.3.0 || ^16.0.0-alpha". warning "rsuite > react-virtualized@9.22.3" has incorrect peer dependency "react-dom@^15.3.0 || ^16.0.0-alpha". warning " > browserslist-config-erb@0.0.1" has incorrect peer dependency "electron@^7.0.0". warning " > enzyme-adapter-react-16@1.15.6" has incorrect peer dependency "react@^16.0.0-0". warning " > enzyme-adapter-react-16@1.15.6" has incorrect peer dependency "react-dom@^16.0.0-0". warning "enzyme-adapter-react-16 > enzyme-adapter-utils@1.14.0" has incorrect peer dependency "react@0.13.x || 0.14.x || ^15.0.0-0 || ^16.0.0-0". warning "enzyme-adapter-react-16 > react-test-renderer@16.14.0" has incorrect peer dependency "react@^16.14.0". warning "enzyme-adapter-react-16 > enzyme-adapter-utils > airbnb-prop-types@2.16.0" has incorrect peer dependency "react@^0.14 || ^15.0.0 || ^16.0.0-alpha". warning " > eslint-config-erb@2.0.0" has incorrect peer dependency "eslint-config-airbnb-typescript@^8.0.2". warning " > eslint-config-erb@2.0.0" has incorrect peer dependency "eslint-import-resolver-webpack@^0.12.2". warning " > eslint-config-erb@2.0.0" has incorrect peer dependency "eslint-plugin-jest@^23.13.2". warning " > eslint-config-erb@2.0.0" has incorrect peer dependency "eslint-plugin-jsx-a11y@6.2.3". warning " > eslint-config-erb@2.0.0" has unmet peer dependency "eslint-plugin-testcafe@^0.2.1". warning " > eslint-config-erb@2.0.0" has incorrect peer dependency "react@^16.13.1". warning " > tsc-silent@1.2.2" has unmet peer dependency "yargs@12 - 15". [4/4] Building fresh packages... $ node -r @babel/register .erb/scripts/CheckNativeDep.js && electron-builder install-app-deps && yarn cross-env NODE_ENV=development webpack --config ./.erb/configs/webpack.config.renderer.dev.dll.babel.js && opencollective-postinstall && yarn-deduplicate yarn.lock Debugger listening on ws://127.0.0.1:53800/f8202273-171a-4b19-b071-add16d16949c For help, see: https://nodejs.org/en/docs/inspector Debugger attached. npm ERR! extraneous: register-scheme@0.0.2 /workspaces/sonixd/node_modules/register-scheme Native dependencies could not be checked Waiting for the debugger to disconnect... • electron-builder version=23.0.2 • loaded configuration file=package.json ("build" field) • installing production dependencies platform=linux arch=x64 appDir=/workspaces/sonixd/src ⨯ /usr/local/bin/node process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE Exit code: 1 Output: yarn install v1.22.19 [1/4] Resolving packages... success Already up-to-date. $ yarn electron-rebuild yarn run v1.22.19 $ node -r ../.erb/scripts/BabelRegister.js ../.erb/scripts/ElectronRebuild.js info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command. Error output: Debugger listening on ws://127.0.0.1:53526/cbf50fc4-fcfe-4d15-b80e-c87c6b629707 For help, see: https://nodejs.org/en/docs/inspector Debugger attached. - Searching dependency tree gyp info find Python using Python version 3.9.2 found at "/usr/bin/python3" gyp info spawn /usr/bin/python3 gyp info spawn args [ gyp info spawn args '/workspaces/sonixd/node_modules/node-gyp/gyp/gyp_main.py', gyp info spawn args 'binding.gyp', gyp info spawn args '-f', gyp info spawn args 'make', gyp info spawn args '-I', gyp info spawn args '/workspaces/sonixd/src/node_modules/@nodert-win10-au/windows.foundation/build/config.gypi', gyp info spawn args '-I', gyp info spawn args '/workspaces/sonixd/src/node_modules/@nodert-win10-au/windows.foundation/common.gypi', gyp info spawn args '-I', gyp info spawn args '/workspaces/sonixd/node_modules/node-gyp/addon.gypi', gyp info spawn args '-I', gyp info spawn args '/home/node/.electron-gyp/13.6.3/include/node/common.gypi', gyp info spawn args '-Dlibrary=shared_library', gyp info spawn args '-Dvisibility=default', gyp info spawn args '-Dnode_root_dir=/home/node/.electron-gyp/13.6.3', gyp info spawn args '-Dnode_gyp_dir=/workspaces/sonixd/node_modules/node-gyp', gyp info spawn args '-Dnode_lib_file=/home/node/.electron-gyp/13.6.3/<(target_arch)/node.lib', gyp info spawn args '-Dmodule_root_dir=/workspaces/sonixd/src/node_modules/@nodert-win10-au/windows.foundation', gyp info spawn args '-Dnode_engine=v8', gyp info spawn args '--depth=.', gyp info spawn args '--no-parallel', gyp info spawn args '--generator-output', gyp info spawn args 'build', gyp info spawn args '-Goutput_dir=.' gyp info spawn args ] Debugger listening on ws://127.0.0.1:53324/e93e4547-f683-4637-9056-fc2a6900d55d For help, see: https://nodejs.org/en/docs/inspector Debugger attached. Waiting for the debugger to disconnect... gyp: Call to 'node -e "require('nan')"' returned exit status 0 while in binding.gyp. while trying to load binding.gyp ✖ Rebuild Failed An unhandled error occurred inside electron-rebuild node-gyp failed to rebuild '/workspaces/sonixd/src/node_modules/@nodert-win10-au/windows.foundation'. Error: `gyp` failed with exit code: 1 Error: node-gyp failed to rebuild '/workspaces/sonixd/src/node_modules/@nodert-win10-au/windows.foundation'. Error: `gyp` failed with exit code: 1 at ModuleRebuilder.rebuildNodeGypModule (/workspaces/sonixd/node_modules/electron-rebuild/lib/src/module-rebuilder.js:193:19) at processTicksAndRejections (internal/process/task_queues.js:95:5) at async Rebuilder.rebuildModuleAt (/workspaces/sonixd/node_modules/electron-rebuild/lib/src/rebuild.js:190:9) at async Rebuilder.rebuild (/workspaces/sonixd/node_modules/electron-rebuild/lib/src/rebuild.js:152:17) at async /workspaces/sonixd/node_modules/electron-rebuild/lib/src/cli.js:146:9 Waiting for the debugger to disconnect... child_process.js:866 throw err; ^ Error: Command failed: ../node_modules/.bin/electron-rebuild --no-parallel --force --types prod,dev,optional --module-dir . at checkExecSyncError (child_process.js:790:11) at execSync (child_process.js:863:15) at Object. (/workspaces/sonixd/.erb/scripts/ElectronRebuild.js:18:3) at Module._compile (internal/modules/cjs/loader.js:1085:14) at Module._compile (/workspaces/sonixd/node_modules/pirates/lib/index.js:136:24) at Module._extensions..js (internal/modules/cjs/loader.js:1114:10) at Object.newLoader [as .js] (/workspaces/sonixd/node_modules/pirates/lib/index.js:141:7) at Module.load (internal/modules/cjs/loader.js:950:32) at Function.Module._load (internal/modules/cjs/loader.js:790:12) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12) { status: 255, signal: null, output: [ null, null, null ], pid: 4773, stdout: null, stderr: null } error Command failed with exit code 1. error Command failed with exit code 1. failedTask=installAppDeps stackTrace=Error: /usr/local/bin/node process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE Exit code: 1 Output: yarn install v1.22.19 [1/4] Resolving packages... success Already up-to-date. $ yarn electron-rebuild yarn run v1.22.19 $ node -r ../.erb/scripts/BabelRegister.js ../.erb/scripts/ElectronRebuild.js info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command. Debugger listening on ws://127.0.0.1:53526/cbf50fc4-fcfe-4d15-b80e-c87c6b629707 For help, see: https://nodejs.org/en/docs/inspector Debugger attached. - Searching dependency tree gyp info find Python using Python version 3.9.2 found at "/usr/bin/python3" gyp info spawn /usr/bin/python3 gyp info spawn args [ gyp info spawn args '/workspaces/sonixd/node_modules/node-gyp/gyp/gyp_main.py', gyp info spawn args 'binding.gyp', gyp info spawn args '-f', gyp info spawn args 'make', gyp info spawn args '-I', gyp info spawn args '/workspaces/sonixd/src/node_modules/@nodert-win10-au/windows.foundation/build/config.gypi', gyp info spawn args '-I', gyp info spawn args '/workspaces/sonixd/src/node_modules/@nodert-win10-au/windows.foundation/common.gypi', gyp info spawn args '-I', gyp info spawn args '/workspaces/sonixd/node_modules/node-gyp/addon.gypi', gyp info spawn args '-I', gyp info spawn args '/home/node/.electron-gyp/13.6.3/include/node/common.gypi', gyp info spawn args '-Dlibrary=shared_library', gyp info spawn args '-Dvisibility=default', gyp info spawn args '-Dnode_root_dir=/home/node/.electron-gyp/13.6.3', gyp info spawn args '-Dnode_gyp_dir=/workspaces/sonixd/node_modules/node-gyp', gyp info spawn args '-Dnode_lib_file=/home/node/.electron-gyp/13.6.3/<(target_arch)/node.lib', gyp info spawn args '-Dmodule_root_dir=/workspaces/sonixd/src/node_modules/@nodert-win10-au/windows.foundation', gyp info spawn args '-Dnode_engine=v8', gyp info spawn args '--depth=.', gyp info spawn args '--no-parallel', gyp info spawn args '--generator-output', gyp info spawn args 'build', gyp info spawn args '-Goutput_dir=.' gyp info spawn args ] Debugger listening on ws://127.0.0.1:53324/e93e4547-f683-4637-9056-fc2a6900d55d For help, see: https://nodejs.org/en/docs/inspector Debugger attached. Waiting for the debugger to disconnect... gyp: Call to 'node -e "require('nan')"' returned exit status 0 while in binding.gyp. while trying to load binding.gyp ✖ Rebuild Failed An unhandled error occurred inside electron-rebuild node-gyp failed to rebuild '/workspaces/sonixd/src/node_modules/@nodert-win10-au/windows.foundation'. Error: `gyp` failed with exit code: 1 Error: `gyp` failed with exit code: 1 at processTicksAndRejections (internal/process/task_queues.js:95:5) at async Rebuilder.rebuildModuleAt (/workspaces/sonixd/node_modules/electron-rebuild/lib/src/rebuild.js:190:9) at async Rebuilder.rebuild (/workspaces/sonixd/node_modules/electron-rebuild/lib/src/rebuild.js:152:17) at async /workspaces/sonixd/node_modules/electron-rebuild/lib/src/cli.js:146:9 Waiting for the debugger to disconnect... child_process.js:866 throw err; ^ at checkExecSyncError (child_process.js:790:11) at execSync (child_process.js:863:15) at Object. (/workspaces/sonixd/.erb/scripts/ElectronRebuild.js:18:3) at Module._compile (internal/modules/cjs/loader.js:1085:14) at Module._compile (/workspaces/sonixd/node_modules/pirates/lib/index.js:136:24) at Module._extensions..js (internal/modules/cjs/loader.js:1114:10) at Object.newLoader [as .js] (/workspaces/sonixd/node_modules/pirates/lib/index.js:141:7) at Module.load (internal/modules/cjs/loader.js:950:32) at Function.Module._load (internal/modules/cjs/loader.js:790:12) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12) { status: 255, signal: null, output: [ null, null, null ], pid: 4773, stdout: null, stderr: null } error Command failed with exit code 1. error Command failed with exit code 1. at Object.onceWrapper (events.js:520:26) at ChildProcess.emit (events.js:400:28) at maybeClose (internal/child_process.js:1088:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:296:5) error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command. node ➜ /workspaces/sonixd (main ✗) $ ```
jeffvli commented 2 years ago

Weird, it's trying to build the Windows native dependencies.

If you go into the src/package.json file, you can temporarily remove those dependencies. Check this comment for detailed instructions: https://github.com/jeffvli/sonixd/issues/232#issuecomment-1038148918

Chaphasilor commented 2 years ago
still errors I'm afraid
```sh-session node ➜ /workspaces/sonixd (main ✗) $ yarn install yarn install v1.22.19 [1/4] Resolving packages... [2/4] Fetching packages... [3/4] Linking dependencies... warning " > styled-components@5.3.5" has unmet peer dependency "react-is@>= 16.8.0". warning " > electron-redux@1.5.4" has unmet peer dependency "redux@^4.0.1". warning "rsuite > react-virtualized@9.22.3" has incorrect peer dependency "react@^15.3.0 || ^16.0.0-alpha". warning "rsuite > react-virtualized@9.22.3" has incorrect peer dependency "react-dom@^15.3.0 || ^16.0.0-alpha". warning " > browserslist-config-erb@0.0.1" has incorrect peer dependency "electron@^7.0.0". warning " > enzyme-adapter-react-16@1.15.6" has incorrect peer dependency "react@^16.0.0-0". warning " > enzyme-adapter-react-16@1.15.6" has incorrect peer dependency "react-dom@^16.0.0-0". warning "enzyme-adapter-react-16 > enzyme-adapter-utils@1.14.0" has incorrect peer dependency "react@0.13.x || 0.14.x || ^15.0.0-0 || ^16.0.0-0". warning "enzyme-adapter-react-16 > react-test-renderer@16.14.0" has incorrect peer dependency "react@^16.14.0". warning "enzyme-adapter-react-16 > enzyme-adapter-utils > airbnb-prop-types@2.16.0" has incorrect peer dependency "react@^0.14 || ^15.0.0 || ^16.0.0-alpha". warning " > eslint-config-erb@2.0.0" has incorrect peer dependency "eslint-config-airbnb-typescript@^8.0.2". warning " > eslint-config-erb@2.0.0" has incorrect peer dependency "eslint-import-resolver-webpack@^0.12.2". warning " > eslint-config-erb@2.0.0" has incorrect peer dependency "eslint-plugin-jest@^23.13.2". warning " > eslint-config-erb@2.0.0" has incorrect peer dependency "eslint-plugin-jsx-a11y@6.2.3". warning " > eslint-config-erb@2.0.0" has unmet peer dependency "eslint-plugin-testcafe@^0.2.1". warning " > eslint-config-erb@2.0.0" has incorrect peer dependency "react@^16.13.1". warning " > tsc-silent@1.2.2" has unmet peer dependency "yargs@12 - 15". [4/4] Building fresh packages... $ node -r @babel/register .erb/scripts/CheckNativeDep.js && electron-builder install-app-deps && yarn cross-env NODE_ENV=development webpack --config ./.erb/configs/webpack.config.renderer.dev.dll.babel.js && opencollective-postinstall && yarn-deduplicate yarn.lock Debugger listening on ws://127.0.0.1:53800/f8202273-171a-4b19-b071-add16d16949c For help, see: https://nodejs.org/en/docs/inspector Debugger attached. npm ERR! extraneous: register-scheme@0.0.2 /workspaces/sonixd/node_modules/register-scheme Native dependencies could not be checked Waiting for the debugger to disconnect... • electron-builder version=23.0.2 • loaded configuration file=package.json ("build" field) • installing production dependencies platform=linux arch=x64 appDir=/workspaces/sonixd/src ⨯ /usr/local/bin/node process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE Exit code: 1 Output: yarn install v1.22.19 [1/4] Resolving packages... success Already up-to-date. $ yarn electron-rebuild yarn run v1.22.19 $ node -r ../.erb/scripts/BabelRegister.js ../.erb/scripts/ElectronRebuild.js info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command. Error output: Debugger listening on ws://127.0.0.1:53526/cbf50fc4-fcfe-4d15-b80e-c87c6b629707 For help, see: https://nodejs.org/en/docs/inspector Debugger attached. - Searching dependency tree gyp info find Python using Python version 3.9.2 found at "/usr/bin/python3" gyp info spawn /usr/bin/python3 gyp info spawn args [ gyp info spawn args '/workspaces/sonixd/node_modules/node-gyp/gyp/gyp_main.py', gyp info spawn args 'binding.gyp', gyp info spawn args '-f', gyp info spawn args 'make', gyp info spawn args '-I', gyp info spawn args '/workspaces/sonixd/src/node_modules/@nodert-win10-au/windows.foundation/build/config.gypi', gyp info spawn args '-I', gyp info spawn args '/workspaces/sonixd/src/node_modules/@nodert-win10-au/windows.foundation/common.gypi', gyp info spawn args '-I', gyp info spawn args '/workspaces/sonixd/node_modules/node-gyp/addon.gypi', gyp info spawn args '-I', gyp info spawn args '/home/node/.electron-gyp/13.6.3/include/node/common.gypi', gyp info spawn args '-Dlibrary=shared_library', gyp info spawn args '-Dvisibility=default', gyp info spawn args '-Dnode_root_dir=/home/node/.electron-gyp/13.6.3', gyp info spawn args '-Dnode_gyp_dir=/workspaces/sonixd/node_modules/node-gyp', gyp info spawn args '-Dnode_lib_file=/home/node/.electron-gyp/13.6.3/<(target_arch)/node.lib', gyp info spawn args '-Dmodule_root_dir=/workspaces/sonixd/src/node_modules/@nodert-win10-au/windows.foundation', gyp info spawn args '-Dnode_engine=v8', gyp info spawn args '--depth=.', gyp info spawn args '--no-parallel', gyp info spawn args '--generator-output', gyp info spawn args 'build', gyp info spawn args '-Goutput_dir=.' gyp info spawn args ] Debugger listening on ws://127.0.0.1:53324/e93e4547-f683-4637-9056-fc2a6900d55d For help, see: https://nodejs.org/en/docs/inspector Debugger attached. Waiting for the debugger to disconnect... gyp: Call to 'node -e "require('nan')"' returned exit status 0 while in binding.gyp. while trying to load binding.gyp ✖ Rebuild Failed An unhandled error occurred inside electron-rebuild node-gyp failed to rebuild '/workspaces/sonixd/src/node_modules/@nodert-win10-au/windows.foundation'. Error: `gyp` failed with exit code: 1 Error: node-gyp failed to rebuild '/workspaces/sonixd/src/node_modules/@nodert-win10-au/windows.foundation'. Error: `gyp` failed with exit code: 1 at ModuleRebuilder.rebuildNodeGypModule (/workspaces/sonixd/node_modules/electron-rebuild/lib/src/module-rebuilder.js:193:19) at processTicksAndRejections (internal/process/task_queues.js:95:5) at async Rebuilder.rebuildModuleAt (/workspaces/sonixd/node_modules/electron-rebuild/lib/src/rebuild.js:190:9) at async Rebuilder.rebuild (/workspaces/sonixd/node_modules/electron-rebuild/lib/src/rebuild.js:152:17) at async /workspaces/sonixd/node_modules/electron-rebuild/lib/src/cli.js:146:9 Waiting for the debugger to disconnect... child_process.js:866 throw err; ^ Error: Command failed: ../node_modules/.bin/electron-rebuild --no-parallel --force --types prod,dev,optional --module-dir . at checkExecSyncError (child_process.js:790:11) at execSync (child_process.js:863:15) at Object. (/workspaces/sonixd/.erb/scripts/ElectronRebuild.js:18:3) at Module._compile (internal/modules/cjs/loader.js:1085:14) at Module._compile (/workspaces/sonixd/node_modules/pirates/lib/index.js:136:24) at Module._extensions..js (internal/modules/cjs/loader.js:1114:10) at Object.newLoader [as .js] (/workspaces/sonixd/node_modules/pirates/lib/index.js:141:7) at Module.load (internal/modules/cjs/loader.js:950:32) at Function.Module._load (internal/modules/cjs/loader.js:790:12) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12) { status: 255, signal: null, output: [ null, null, null ], pid: 4773, stdout: null, stderr: null } error Command failed with exit code 1. error Command failed with exit code 1. failedTask=installAppDeps stackTrace=Error: /usr/local/bin/node process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE Exit code: 1 Output: yarn install v1.22.19 [1/4] Resolving packages... success Already up-to-date. $ yarn electron-rebuild yarn run v1.22.19 $ node -r ../.erb/scripts/BabelRegister.js ../.erb/scripts/ElectronRebuild.js info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command. Debugger listening on ws://127.0.0.1:53526/cbf50fc4-fcfe-4d15-b80e-c87c6b629707 For help, see: https://nodejs.org/en/docs/inspector Debugger attached. - Searching dependency tree gyp info find Python using Python version 3.9.2 found at "/usr/bin/python3" gyp info spawn /usr/bin/python3 gyp info spawn args [ gyp info spawn args '/workspaces/sonixd/node_modules/node-gyp/gyp/gyp_main.py', gyp info spawn args 'binding.gyp', gyp info spawn args '-f', gyp info spawn args 'make', gyp info spawn args '-I', gyp info spawn args '/workspaces/sonixd/src/node_modules/@nodert-win10-au/windows.foundation/build/config.gypi', gyp info spawn args '-I', gyp info spawn args '/workspaces/sonixd/src/node_modules/@nodert-win10-au/windows.foundation/common.gypi', gyp info spawn args '-I', gyp info spawn args '/workspaces/sonixd/node_modules/node-gyp/addon.gypi', gyp info spawn args '-I', gyp info spawn args '/home/node/.electron-gyp/13.6.3/include/node/common.gypi', gyp info spawn args '-Dlibrary=shared_library', gyp info spawn args '-Dvisibility=default', gyp info spawn args '-Dnode_root_dir=/home/node/.electron-gyp/13.6.3', gyp info spawn args '-Dnode_gyp_dir=/workspaces/sonixd/node_modules/node-gyp', gyp info spawn args '-Dnode_lib_file=/home/node/.electron-gyp/13.6.3/<(target_arch)/node.lib', gyp info spawn args '-Dmodule_root_dir=/workspaces/sonixd/src/node_modules/@nodert-win10-au/windows.foundation', gyp info spawn args '-Dnode_engine=v8', gyp info spawn args '--depth=.', gyp info spawn args '--no-parallel', gyp info spawn args '--generator-output', gyp info spawn args 'build', gyp info spawn args '-Goutput_dir=.' gyp info spawn args ] Debugger listening on ws://127.0.0.1:53324/e93e4547-f683-4637-9056-fc2a6900d55d For help, see: https://nodejs.org/en/docs/inspector Debugger attached. Waiting for the debugger to disconnect... gyp: Call to 'node -e "require('nan')"' returned exit status 0 while in binding.gyp. while trying to load binding.gyp ✖ Rebuild Failed An unhandled error occurred inside electron-rebuild node-gyp failed to rebuild '/workspaces/sonixd/src/node_modules/@nodert-win10-au/windows.foundation'. Error: `gyp` failed with exit code: 1 Error: `gyp` failed with exit code: 1 at processTicksAndRejections (internal/process/task_queues.js:95:5) at async Rebuilder.rebuildModuleAt (/workspaces/sonixd/node_modules/electron-rebuild/lib/src/rebuild.js:190:9) at async Rebuilder.rebuild (/workspaces/sonixd/node_modules/electron-rebuild/lib/src/rebuild.js:152:17) at async /workspaces/sonixd/node_modules/electron-rebuild/lib/src/cli.js:146:9 Waiting for the debugger to disconnect... child_process.js:866 throw err; ^ at checkExecSyncError (child_process.js:790:11) at execSync (child_process.js:863:15) at Object. (/workspaces/sonixd/.erb/scripts/ElectronRebuild.js:18:3) at Module._compile (internal/modules/cjs/loader.js:1085:14) at Module._compile (/workspaces/sonixd/node_modules/pirates/lib/index.js:136:24) at Module._extensions..js (internal/modules/cjs/loader.js:1114:10) at Object.newLoader [as .js] (/workspaces/sonixd/node_modules/pirates/lib/index.js:141:7) at Module.load (internal/modules/cjs/loader.js:950:32) at Function.Module._load (internal/modules/cjs/loader.js:790:12) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12) { status: 255, signal: null, output: [ null, null, null ], pid: 4773, stdout: null, stderr: null } error Command failed with exit code 1. error Command failed with exit code 1. at Object.onceWrapper (events.js:520:26) at ChildProcess.emit (events.js:400:28) at maybeClose (internal/child_process.js:1088:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:296:5) error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command. node ➜ /workspaces/sonixd (main ✗) $ ```
even after deleting `node_modules`, `.electron-gyp` and running `yarn cache clean`:
```sh-session node ➜ /workspaces/sonixd (main ✗) $ yarn install yarn install v1.22.19 [1/4] Resolving packages... [2/4] Fetching packages... [1/4] Resolving packages... [2/4] Fetching packages... [3/4] Linking dependencies... warning " > @continuous-auth/semantic-release-npm@2.0.0" has unmet peer dependency "semantic-release@>=15.9.0 <16.0.0". warning " > spec-xunit-file@0.0.1-3" has unmet peer dependency "mocha@>=1.7.0". [4/4] Building fresh packages... $ npm run compile npm WARN lifecycle The node binary used for scripts is /tmp/yarn--1658781035061-0.46761410280145266/node but npm is using /usr/local/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with. > electron-devtools-installer@0.0.0-development compile /home/node/.cache/yarn/v6/.tmp/87cd208322c666ac5b5d0473c4474f55.65ffa894bf635745d9399e79fb38682ccfd9c6e0.prepare > tsc [3/4] Linking dependencies... warning " > styled-components@5.3.5" has unmet peer dependency "react-is@>= 16.8.0". warning " > electron-redux@1.5.4" has unmet peer dependency "redux@^4.0.1". warning "rsuite > react-virtualized@9.22.3" has incorrect peer dependency "react@^15.3.0 || ^16.0.0-alpha". warning "rsuite > react-virtualized@9.22.3" has incorrect peer dependency "react-dom@^15.3.0 || ^16.0.0-alpha". warning " > browserslist-config-erb@0.0.1" has incorrect peer dependency "electron@^7.0.0". warning " > enzyme-adapter-react-16@1.15.6" has incorrect peer dependency "react@^16.0.0-0". warning " > enzyme-adapter-react-16@1.15.6" has incorrect peer dependency "react-dom@^16.0.0-0". warning "enzyme-adapter-react-16 > enzyme-adapter-utils@1.14.0" has incorrect peer dependency "react@0.13.x || 0.14.x || ^15.0.0-0 || ^16.0.0-0". warning "enzyme-adapter-react-16 > react-test-renderer@16.14.0" has incorrect peer dependency "react@^16.14.0". warning "enzyme-adapter-react-16 > enzyme-adapter-utils > airbnb-prop-types@2.16.0" has incorrect peer dependency "react@^0.14 || ^15.0.0 || ^16.0.0-alpha". warning " > eslint-config-erb@2.0.0" has incorrect peer dependency "eslint-config-airbnb-typescript@^8.0.2". warning " > eslint-config-erb@2.0.0" has incorrect peer dependency "eslint-import-resolver-webpack@^0.12.2". warning " > eslint-config-erb@2.0.0" has incorrect peer dependency "eslint-plugin-jest@^23.13.2". warning " > eslint-config-erb@2.0.0" has incorrect peer dependency "eslint-plugin-jsx-a11y@6.2.3". warning " > eslint-config-erb@2.0.0" has unmet peer dependency "eslint-plugin-testcafe@^0.2.1". warning " > eslint-config-erb@2.0.0" has incorrect peer dependency "react@^16.13.1". warning " > tsc-silent@1.2.2" has unmet peer dependency "yargs@12 - 15". [4/4] Building fresh packages... $ node -r @babel/register .erb/scripts/CheckNativeDep.js && electron-builder install-app-deps && yarn cross-env NODE_ENV=development webpack --config ./.erb/configs/webpack.config.renderer.dev.dll.babel.js && opencollective-postinstall && yarn-deduplicate yarn.lock Debugger listening on ws://127.0.0.1:53316/f83d4225-0db8-4fa6-97ba-5d06f6fba791 For help, see: https://nodejs.org/en/docs/inspector Debugger attached. npm ERR! extraneous: register-scheme@0.0.2 /workspaces/sonixd/node_modules/register-scheme Native dependencies could not be checked Waiting for the debugger to disconnect... • electron-builder version=23.0.2 • loaded configuration file=package.json ("build" field) • installing production dependencies platform=linux arch=x64 appDir=/workspaces/sonixd/src ⨯ /usr/local/bin/node process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE Exit code: 1 Output: yarn install v1.22.19 [1/4] Resolving packages... success Already up-to-date. $ yarn electron-rebuild yarn run v1.22.19 $ node -r ../.erb/scripts/BabelRegister.js ../.erb/scripts/ElectronRebuild.js info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command. Error output: Debugger listening on ws://127.0.0.1:53177/c986b1a4-e1d3-43e9-b3e5-ed8b792d4d13 For help, see: https://nodejs.org/en/docs/inspector Debugger attached. - Searching dependency tree gyp info find Python using Python version 3.9.2 found at "/usr/bin/python3" gyp info spawn /usr/bin/python3 gyp info spawn args [ gyp info spawn args '/workspaces/sonixd/node_modules/node-gyp/gyp/gyp_main.py', gyp info spawn args 'binding.gyp', gyp info spawn args '-f', gyp info spawn args 'make', gyp info spawn args '-I', gyp info spawn args '/workspaces/sonixd/src/node_modules/abstract-socket/build/config.gypi', gyp info spawn args '-I', gyp info spawn args '/workspaces/sonixd/node_modules/node-gyp/addon.gypi', gyp info spawn args '-I', gyp info spawn args '/home/node/.electron-gyp/13.6.3/include/node/common.gypi', gyp info spawn args '-Dlibrary=shared_library', gyp info spawn args '-Dvisibility=default', gyp info spawn args '-Dnode_root_dir=/home/node/.electron-gyp/13.6.3', gyp info spawn args '-Dnode_gyp_dir=/workspaces/sonixd/node_modules/node-gyp', gyp info spawn args '-Dnode_lib_file=/home/node/.electron-gyp/13.6.3/<(target_arch)/node.lib', gyp info spawn args '-Dmodule_root_dir=/workspaces/sonixd/src/node_modules/abstract-socket', gyp info spawn args '-Dnode_engine=v8', gyp info spawn args '--depth=.', gyp info spawn args '--no-parallel', gyp info spawn args '--generator-output', gyp info spawn args 'build', gyp info spawn args '-Goutput_dir=.' gyp info spawn args ] Debugger listening on ws://127.0.0.1:53008/a14082a7-510c-434a-b022-9250642d0ecd For help, see: https://nodejs.org/en/docs/inspector Debugger attached. Waiting for the debugger to disconnect... gyp: Call to 'node -e "require('nan')"' returned exit status 0 while in binding.gyp. while trying to load binding.gyp ✖ Rebuild Failed An unhandled error occurred inside electron-rebuild node-gyp failed to rebuild '/workspaces/sonixd/src/node_modules/abstract-socket'. Error: `gyp` failed with exit code: 1 Error: node-gyp failed to rebuild '/workspaces/sonixd/src/node_modules/abstract-socket'. Error: `gyp` failed with exit code: 1 at ModuleRebuilder.rebuildNodeGypModule (/workspaces/sonixd/node_modules/electron-rebuild/lib/src/module-rebuilder.js:193:19) at processTicksAndRejections (internal/process/task_queues.js:95:5) at async Rebuilder.rebuildModuleAt (/workspaces/sonixd/node_modules/electron-rebuild/lib/src/rebuild.js:190:9) at async Rebuilder.rebuild (/workspaces/sonixd/node_modules/electron-rebuild/lib/src/rebuild.js:152:17) at async /workspaces/sonixd/node_modules/electron-rebuild/lib/src/cli.js:146:9 Waiting for the debugger to disconnect... child_process.js:866 throw err; ^ Error: Command failed: ../node_modules/.bin/electron-rebuild --no-parallel --force --types prod,dev,optional --module-dir . at checkExecSyncError (child_process.js:790:11) at execSync (child_process.js:863:15) at Object. (/workspaces/sonixd/.erb/scripts/ElectronRebuild.js:18:3) at Module._compile (internal/modules/cjs/loader.js:1085:14) at Module._compile (/workspaces/sonixd/node_modules/pirates/lib/index.js:136:24) at Module._extensions..js (internal/modules/cjs/loader.js:1114:10) at Object.newLoader [as .js] (/workspaces/sonixd/node_modules/pirates/lib/index.js:141:7) at Module.load (internal/modules/cjs/loader.js:950:32) at Function.Module._load (internal/modules/cjs/loader.js:790:12) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12) { status: 255, signal: null, output: [ null, null, null ], pid: 7806, stdout: null, stderr: null } error Command failed with exit code 1. error Command failed with exit code 1. failedTask=installAppDeps stackTrace=Error: /usr/local/bin/node process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE Exit code: 1 Output: yarn install v1.22.19 [1/4] Resolving packages... success Already up-to-date. $ yarn electron-rebuild yarn run v1.22.19 $ node -r ../.erb/scripts/BabelRegister.js ../.erb/scripts/ElectronRebuild.js info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command. Error output: Debugger listening on ws://127.0.0.1:53177/c986b1a4-e1d3-43e9-b3e5-ed8b792d4d13 For help, see: https://nodejs.org/en/docs/inspector Debugger attached. - Searching dependency tree gyp info find Python using Python version 3.9.2 found at "/usr/bin/python3" gyp info spawn /usr/bin/python3 gyp info spawn args [ gyp info spawn args '/workspaces/sonixd/node_modules/node-gyp/gyp/gyp_main.py', gyp info spawn args 'binding.gyp', gyp info spawn args '-f', gyp info spawn args 'make', gyp info spawn args '-I', gyp info spawn args '/workspaces/sonixd/src/node_modules/abstract-socket/build/config.gypi', gyp info spawn args '-I', gyp info spawn args '/workspaces/sonixd/node_modules/node-gyp/addon.gypi', gyp info spawn args '-I', gyp info spawn args '/home/node/.electron-gyp/13.6.3/include/node/common.gypi', gyp info spawn args '-Dlibrary=shared_library', gyp info spawn args '-Dvisibility=default', gyp info spawn args '-Dnode_root_dir=/home/node/.electron-gyp/13.6.3', gyp info spawn args '-Dnode_gyp_dir=/workspaces/sonixd/node_modules/node-gyp', gyp info spawn args '-Dnode_lib_file=/home/node/.electron-gyp/13.6.3/<(target_arch)/node.lib', gyp info spawn args '-Dmodule_root_dir=/workspaces/sonixd/src/node_modules/abstract-socket', gyp info spawn args '-Dnode_engine=v8', gyp info spawn args '--depth=.', gyp info spawn args '--no-parallel', gyp info spawn args '--generator-output', gyp info spawn args 'build', gyp info spawn args '-Goutput_dir=.' gyp info spawn args ] Debugger listening on ws://127.0.0.1:53008/a14082a7-510c-434a-b022-9250642d0ecd For help, see: https://nodejs.org/en/docs/inspector Debugger attached. Waiting for the debugger to disconnect... gyp: Call to 'node -e "require('nan')"' returned exit status 0 while in binding.gyp. while trying to load binding.gyp ✖ Rebuild Failed An unhandled error occurred inside electron-rebuild node-gyp failed to rebuild '/workspaces/sonixd/src/node_modules/abstract-socket'. Error: `gyp` failed with exit code: 1 Error: node-gyp failed to rebuild '/workspaces/sonixd/src/node_modules/abstract-socket'. Error: `gyp` failed with exit code: 1 at ModuleRebuilder.rebuildNodeGypModule (/workspaces/sonixd/node_modules/electron-rebuild/lib/src/module-rebuilder.js:193:19) at processTicksAndRejections (internal/process/task_queues.js:95:5) at async Rebuilder.rebuildModuleAt (/workspaces/sonixd/node_modules/electron-rebuild/lib/src/rebuild.js:190:9) at async Rebuilder.rebuild (/workspaces/sonixd/node_modules/electron-rebuild/lib/src/rebuild.js:152:17) at async /workspaces/sonixd/node_modules/electron-rebuild/lib/src/cli.js:146:9 Waiting for the debugger to disconnect... child_process.js:866 throw err; ^ Error: Command failed: ../node_modules/.bin/electron-rebuild --no-parallel --force --types prod,dev,optional --module-dir . at checkExecSyncError (child_process.js:790:11) at execSync (child_process.js:863:15) at Object. (/workspaces/sonixd/.erb/scripts/ElectronRebuild.js:18:3) at Module._compile (internal/modules/cjs/loader.js:1085:14) at Module._compile (/workspaces/sonixd/node_modules/pirates/lib/index.js:136:24) at Module._extensions..js (internal/modules/cjs/loader.js:1114:10) at Object.newLoader [as .js] (/workspaces/sonixd/node_modules/pirates/lib/index.js:141:7) at Module.load (internal/modules/cjs/loader.js:950:32) at Function.Module._load (internal/modules/cjs/loader.js:790:12) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12) { status: 255, signal: null, output: [ null, null, null ], pid: 7806, stdout: null, stderr: null } error Command failed with exit code 1. error Command failed with exit code 1. at ChildProcess. (/workspaces/sonixd/node_modules/builder-util/src/util.ts:250:14) at Object.onceWrapper (events.js:520:26) at ChildProcess.emit (events.js:400:28) at maybeClose (internal/child_process.js:1088:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:296:5) error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command. node ➜ /workspaces/sonixd (main ✗) $ ```
thanks for your help though :)
jeffvli commented 2 years ago

Have you tried using a node-specific container?

Very simple Dockerfile that you can add the the repo root and build:

FROM node:14-buster
WORKDIR /sonixd
COPY . .
RUN yarn
Chaphasilor commented 2 years ago

Okay, tried that as well. Had to install some additional packages (apt install libxshmfence1 libglu1 libnss3-dev libgdk-pixbuf2.0-dev libgtk-3-dev libxss-dev libasound2) to get yarn install to complete (as root), but I still can't run yarn start because chromium wants the --no-sandbox flag when running as root and I can't add that (as I'm not running the command myself).
So I tried adding a new user and running yarn start as it, but there are still errors:

Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted
/sonixd/node_modules/electron/dist/electron exited with signal SIGTRAP

Maybe v0.x.x simply isn't docker-compatible? I'm afraid I don't have any vanilla linux available, only docker and WSL. I'll give it another try on Windows now...

Chaphasilor commented 2 years ago

So Windows doesn't work either for me. Problem being that https://github.com/MarshallOfSound/electron-devtools-installer doesn't seem to support password-protected ssh keys, nor https-based git access.

$ yarn install
yarn install v1.22.19
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/4] Resolving packages...
[2/4] Fetching packages...
error Command failed.
Exit code: 128
Command: git
Arguments: ls-remote --tags --heads ssh://git@github.com/MarshallOfSound/electron-devtools-installer.git
Directory: D:\Code\misc\sonixd
Output:
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

If I run ssh -vT git@github.com or git ls-remote --tags --heads ssh://git@github.com/MarshallOfSound/electron-devtools-installer.git it prompts me for the password for the key and everything works.

I'm sorry, but I think I'll wait until the v1.0 release before contribution this feature, if it's necessary at that point :)
I just don't have the time or motivation to figure this out...

You might get a PR with a few themes though :)

jeffvli commented 2 years ago

Yeah unfortunately I've never used nor tested docker for my dev environment. Probably better to push any new features to the next version anyways!