electron-userland / electron-builder

A complete solution to package and build a ready for distribution Electron app with “auto update” support out of the box
https://www.electron.build
MIT License
13.49k stars 1.72k forks source link

Electron-build has error in building with "Cannot read property 'channel' of null" #7455

Closed akachi1409 closed 10 months ago

akachi1409 commented 1 year ago

I am using Electron builder to build Electron app for Mac. I have built for Window and Linux successfully, but when I tried in building for Mac, I have the following error.

Can not Cleanup: TypeError: Cannot read property 'channel' of null

Electron version 23.1.1 Electron builder version 23.6.0

How to fix this error?

This is my builder config.


{
  "appId": "com.test.testApp",
  "directories": {
    "output": "dist"
  },
  "files": ["build/**/*", "node_modules/**/*", "public/**/*", "electron.js"],
  "publish": {
    "provider": "github"
  },
  "win": {
    "target": "portable"
  },
  "dmg": {
    "title": "${productName} ${version}"
  },
  "linux": {
    "target": ["AppImage", "deb"]
  }
}
mmaietta commented 1 year ago

Please specify 'repository' in the package.json

Have you tried resolving this message first?

Looking at the codebase, it's unable to resolve your publish config. Since it's github-dependent, I'd recommend fixing the warning first and report back

akachi1409 commented 1 year ago

Please specify 'repository' in the package.json

Have you tried resolving this message first?

Looking at the codebase, it's unable to resolve your publish config. Since it's github-dependent, I'd recommend fixing the warning first and report back

Yes, I added publihconfig like this.

"publish": null,

Now I succeed in publishing the app in Mac, but the problem is the app is not launching in the Mac. (While I not only not only succeed in publshing app in Linux and Win, but also in running in Lunux and Win.)

mmaietta commented 1 year ago

Can you just leave publish empty instead of explicitly null? That seems like it'd be the same purpose, but null isn't working obv.

Aiden0801 commented 1 year ago

Can you just leave publish empty instead of explicitly null? That seems like it'd be the same purpose, but null isn't working obv.

Like this?

"publish": []

akachi1409 commented 1 year ago

Can you just leave publish empty instead of explicitly null? That seems like it'd be the same purpose, but null isn't working obv.

I tried this.

"publish": []

But the app is still launching in the development, not in the production.

mmaietta commented 1 year ago

And to confirm, this only occurs on Mac?

Can you put together a minimum reproducible repo of this issue? Such as via an electron boilerplate project?

akachi1409 commented 1 year ago

And to confirm, this only occurs on Mac?

Can you put together a minimum reproducible repro of this issue? Such as via an electron boilerplate project?

Oh, sorry, please check again. The app is working in the development but not in the production in the Mac.

akachi1409 commented 1 year ago

And to confirm, this only occurs on Mac?

Can you put together a minimum reproducible repo of this issue? Such as via an electron boilerplate project?

https://github.com/akachi1409/dropbox-app Invited you.

akachi1409 commented 1 year ago

Can you just leave publish empty instead of explicitly null? That seems like it'd be the same purpose, but null isn't working obv.

And yes, it is only occur in Mac. Linux and Window works well.

mmaietta commented 1 year ago

Tried to run the project locally with open ./dist/mac-arm64/dropbox.app --args --remote-debugging-port=8080 --inspect-brk and I'm seeing this in the logs

(node:30356) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, mkdir 'dropbox-storage'
(Use `dropbox --trace-warnings ...` to show where the warning was created)

I can't seem to access the remote debugging port, I have ⚠ Remote browser is newer than client browser. in my Inspect and I'm not sure how to resolve that as I'm on latest Chrome AFAICT. About Chrome shows up-to-date 110.0.5481.177 (Official Build) (arm64)

akachi1409 commented 1 year ago

Tried to run the project locally with open ./dist/mac-arm64/dropbox.app --args --remote-debugging-port=8080 --inspect-brk and I'm seeing this in the logs

(node:30356) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, mkdir 'dropbox-storage'
(Use `dropbox --trace-warnings ...` to show where the warning was created)

I can't seem to access the remote debugging port, I have ⚠ Remote browser is newer than client browser. in my Inspect and I'm not sure how to resolve that as I'm on latest Chrome AFAICT. About Chrome shows up-to-date 110.0.5481.177 (Official Build) (arm64)

Can you give me the possible solution? I tried creating "dropbox-storage' folder, but it is not working yet. ( Still without creating that folder, it is working well in Window and Linux.) What is the solution method from this issue?

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] commented 1 year ago

This issue was closed because it has been stalled for 5 days with no activity.

ibc commented 1 year ago

"Issue closed because it has been stalled for 5 days with no activity"? Wow 😀

I'm also experimenting same issue consistently. By looking at the code is clear that something is calling computeChannelNames() in app-builder-lib/src/publish/updateInfoBuilder.ts by passing null in publishConfig function argument:

function computeChannelNames(packager: PlatformPackager<any>, publishConfig: PublishConfiguration): Array<string> {
  const currentChannel: string = (publishConfig as GenericServerOptions).channel || "latest"

So that line throws because it's trying to read null.channel. Interesting thing is that TypeScript doesn't complain in my app.

mmaietta commented 1 year ago

@ibc

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

Can you please create a minimum repro repo of the issue?

Based on the computeChannelNames you linked, I followed it to this code: https://github.com/electron-userland/electron-builder/blob/99f49cf7a86afa33d35652ffc6329fefed2e5f75/packages/app-builder-lib/src/publish/PublishManager.ts#L274-L288

If repositoryInfo != null && repositoryInfo.type === "github" isn't true, then publishConfig = null is returned. What is the output of DEBUG=electron-builder for logged entry getPublishConfigsForUpdateInfo. It should show what repositoryInfo is returning as the next debugging step

ibc commented 1 year ago

Honestly I don't see neither getPublishConfigsForUpdateInfo nor repositoryInfo in debug logs. Note that I'm using electron-builder 23.6.0 and electron-publish 23.6.0. Unfortunately I cannot dig much more since it's not "my project" (I don't really know about building electron, I just saw the error and tried to investigate it a bit).

But I see this in the output:

  • detect github as publish provider
  • calling getInfo  reason=owner or project is not specified explicitly provider=github owner=undefined project=undefined
  • Cannot detect repository by .git/config. Please specify "repository" in the package.json (https://docs.npmjs.com/files/package.json#repository).
Please see https://electron.build/configuration/publish
  • async task error  error=Cannot read properties of null (reading 'channel')
ibc commented 1 year ago

So the problem happens in my end because I have a GITHUB_TOKEN environment variable in my terminal, and somehow the electron-builder or electron-publisher package assumes that, if I have that, then I want to publish, but rest of publish params are not given so here the inconsistency, some bad check in the library internals and booom.

github-actions[bot] commented 11 months ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] commented 10 months ago

This issue was closed because it has been stalled for 30 days with no activity.

Properko commented 3 months ago

So the problem happens in my end because I have a GITHUB_TOKEN environment variable in my terminal, and somehow the electron-builder or electron-publisher package assumes that, if I have that, then I want to publish, but rest of publish params are not given so here the inconsistency, some bad check in the library internals and booom.

Thanks! GITHUB_TOKEN="" electron-builder build --windows --mac --linux --config ./electron-builder.json --publish never looks ridiculous just to build and prevent publishing, but it finally works :D