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

Adds install script for Electron compatibility #31

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zlshames
Copy link

@zlshames zlshames commented Apr 1, 2022

Without this, building an Electron app will fail

Copy link

@Helvio88 Helvio88 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Helps with BlueBubblesApp

@zlshames
Copy link
Author

Hi @Helvio88 what are the next steps? Not hugely required right now since I can patch it in, but just curious

@KishanBagaria
Copy link
Contributor

Have been using in an Electron app without this patch btw.

@zlshames
Copy link
Author

zlshames commented Jun 1, 2022

Have been using in an Electron app without this patch btw.

@KishanBagaria, Are you using Electron Builder? If so, what version?

@KishanBagaria
Copy link
Contributor

Yep, been working fine with the latest over the past two years. What do you see?

@zlshames
Copy link
Author

zlshames commented Jun 2, 2022

@KishanBagaria this is the output when I try to build my Electron app (without the patched package.json):

webpack 5.72.1 compiled successfully in 6609 ms
  • electron-builder  version=22.14.13 os=20.6.0
  • loaded configuration  file=package.json ("build" field)
  • writing effective config  file=release/builder-effective-config.yaml
  • rebuilding native dependencies  [email protected], [email protected] platform=darwin arch=x64
  • install prebuilt binary  name=better-sqlite3 version=7.5.3 platform=darwin arch=x64 napi=
  • rebuilding native dependency  name=node-mac-contacts version=1.5.0
  ⨯ cannot execute  cause=exit status 1
                    errorOut=npm ERR! Missing script: "install"
    npm ERR! 
    npm ERR! Did you mean this?
    npm ERR!     npm uninstall # Remove a package
    npm ERR! 
    npm ERR! To see a list of scripts, run:
    npm ERR!   npm run
    
    npm ERR! A complete log of this run can be found in:
    npm ERR!     /Users/xxxxx.npm/_logs/2022-06-02T16_51_44_548Z-debug-0.log
    
                    command=/usr/local/bin/node /usr/local/lib/node_modules/npm/bin/npm-cli.js run install
                    workingDir=/Users/xxxxx/Development/Projects/bluebubbles-server/node_modules/node-mac-contacts
npm ERR! Lifecycle script `dist` failed with error: 
npm ERR! Error: command failed 
npm ERR!   in workspace: @bluebubbles/[email protected] 
npm ERR!   at location: /Users/xxxxx/Development/Projects/bluebubbles-server/packages/server 
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@KishanBagaria
Copy link
Contributor

I've been using yarn which may have different behavior. You could also try upgrading npm, node and electron-builder (atm I'm on node v16.15.0, electron-builder v23.0.6, yarn v3.)

@zlshames
Copy link
Author

zlshames commented Jun 2, 2022

I've been using yarn which may have different behavior. You could also try upgrading npm, node and electron-builder (atm I'm on node v16.15.0, electron-builder v23.0.6, yarn v3.)

I'm also using yarn, just yarn 1.22.4, however, I wouldn't think that's the issue, but possibly... I'm just hesitant to use yarn v2 or 3 because technically they aren't "stable", right?

@KishanBagaria
Copy link
Contributor

Iirc yarn v1 worked too earlier then we moved to v2/v3.

node-mac-contacts is built on NAPI which doesn't require rebuilding. We've been rebuilding native deps by passing the -o flag, like electron-rebuild -o foo,better-sqlite3,bar

Copy link
Owner

@codebytere codebytere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be necessary - this should work as a function of ensuring correct electron-packager/electron-builder & package manager settings.

@zlshames
Copy link
Author

Ok, let me reconfigure electron build and see if I can bypass needing this. Thanks @KishanBagaria for the sample

@zlshames
Copy link
Author

zlshames commented Jun 21, 2022

Removing electron-builder install-app-deps as my postinstall script and replacing it with electron-rebuild -o better-sqlite3 seemed to fix the issue. Closing.

Edit 1: Never-mind, it didn't fix the issue as the issue seems to lie in using electron-builder to build my app.

Edit 2: Electron builder will automatically rebuild all native dependencies when build is called. The only way to disable rebuilding dependencies is set npmRebuild to false. But doing so will prevent other packages from being rebuilt. I can't find a way to specifically ignore certain packages. I looked into beforeBuild as a parameter, but the context that's given doesn't provide the package name being rebuilt. Just the electron and platform information.

@zlshames zlshames closed this Jun 21, 2022
@zlshames zlshames reopened this Jun 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants