Let's say the application name is myApp and the build config in the package.json is the following:
"build": {
"appId": "com.myorg.myapp",
"nsis": {
"include": "nsis/refreshDesktop.nsh",
"artifactName": "MyAppSetup.${ext}"
},
"publish": {
"provider": "generic",
"url": "${env.MYAPP_UPDATE_URL}"
},
"mac": {
"target": [
"pkg",
"zip"
],
"artifactName": "MyAppSetup.${ext}"
}
}
Ok, so repro steps are:
myApp installed into /Applications
myApp not installed into /Applications
Having something already called myApp.app somewhere in the disc like the one generated by electron-builder in the mac folder prevent the myAppl.app folder to be re-created into the /Applications folder.
This is related to this stackoverflow
One of the comment suggest to have the BundleIsRelocatable set to false in the plist file.
Could this be added as a new option for the .pkg target ?
It seems like the generated pkg detects that it should do an upgrade instead of a fresh install. But even though I did two subsequent installs with a different name and build number, the second time, nothing changed.
Repro:
{
"name": "Test1",
"version": "0.3.0-dev",
"build": {
"appId": "com.test.test",
"buildVersion": "1000",
"mac": {
"target": [
"pkg",
"zip"
],
"artifactName": "TestSetup.${ext}"
}
},
}
{
"name": "Test2",
"version": "0.3.0-dev",
"build": {
"appId": "com.test.test",
"buildVersion": "1002",
"mac": {
"target": [
"pkg",
"zip"
],
"artifactName": "TestSetup.${ext}"
}
},
}
Observed:
The app installed in /Applications is still called Test1.
Expected:
I should either see only 1 app installed called Test2 or see both installed: Test1 and Test2.
Diagnostic
Am I missing a config somewhere? It seems like the pkg-specific options do not specify a behaviour or another (update vs overwrite): scripts, installLocation, allowAnywhere, allowCurrentUserHome, allowRootDirectory, identity, artifactName, publish.
I see that electron is using pkgbuild.
Is it possible that the identifier and version are always set to be the same, so that nothing happens? :
(from https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/pkgbuild.1.html)
--identifier pkg-identifier
Specify a unique identifier for this package. The OS X Installer recognizes a package as being an upgrade to an already-installed package only if the package identifiers match, so it is advisable to set a meaningful, consistent identifier when you build the package. pkgbuild will infer an identifier when building a package from a single component, but will fail otherwise if the identifier has not been set.
--version pkg-version
Specify a version for the package. Packages with the same identifier are compared using this version, to determine if the package is an upgrade or downgrade. If you don't specify a version, a default of zero is assumed, but this may prevent proper upgrade/downgrade checking.
Note: Changing the version or the pkg.buildversion doesn't change anything.
I'm facing the same problem with electron builder 19.27.7. Is there anyone manges to get it fixed?
What I am noticing is that when building the app it gets built in release/mac. What seems to happen is that IF the MyApp.app file is present in the release/mac folder, the .pkg always installs to that directory (even if selecting /Applications). I can fix it by deleting the release folder.
Somehow MyApp.app is installed in release/mac instead of /Applications.
I have checked that after running npm run build, the owner of release/mac/foo.app is my account, and after installing the MyApp.pkg, the owner of release/mac/MyApp.app becomes root. That means the installation put MyApp.app in release/mac instead of /Applications.
However like @johnryan said, if I delete the release/mac folder, the installation will install MyApp.app in /Applications
My guess is that macOS somehow find that myApp.app is somehow exists and needs a upgrade install of re-install, so it replaces the myApp.app instead of putting it into /Applications.
Hi @develar,
I am facing the same problem with electron-builder version: '19.54.0'. Is there any way to fix this without deleting existing application from release/mac folder or anywhere from disc?.
I also have the same issue. But with electron-builder 19.55.2.
I don't have a release/ folder, but my app is built into dist/mac/<artifact name>.app. At first I had the same problem that dist/mac/<artifact name>.app changed permission to root:root on install. But now not even that happens. Removing dist/ does not make it install in the correct place either. The installer runs and my app is not installed anywhere.
Oh, wow. I had a very old checkout of the repository in another location, with an old build in it. So the pkg installer somehow detected that old <artifact name>.app and installed into it instead of /Applications. Now I'm back at the original problem where it only installs in /Applications when the app does not exist in any other location.
Most helpful comment
Somehow MyApp.app is installed in
release/macinstead of/Applications.I have checked that after running
npm run build, the owner ofrelease/mac/foo.appis my account, and after installing the MyApp.pkg, the owner ofrelease/mac/MyApp.appbecomes root. That means the installation put MyApp.app inrelease/macinstead of/Applications.However like @johnryan said, if I delete the
release/macfolder, the installation will install MyApp.app in/ApplicationsMy guess is that macOS somehow find that myApp.app is somehow exists and needs a upgrade install of re-install, so it replaces the myApp.app instead of putting it into
/Applications.