-
-
Notifications
You must be signed in to change notification settings - Fork 22
Description
What were you trying to do?
I was trying to build my NativePHP desktop application for macOS with the GitHub auto-updater enabled. I configured the updater settings in my .env file:
NATIVEPHP_UPDATER_ENABLED=true
NATIVEPHP_UPDATER_PROVIDER=github
GITHUB_REPO=myrepository
GITHUB_OWNER=myuser
GITHUB_PRIVATE=true
When running the build command, electron-builder failed because it couldn't detect the repository information from the .git/config file in the vendor/nativephp/desktop/resources/electron/ directory.
What happened?
Pour le champ "What happened?", vous pouvez écrire :
The build process failed with this error:
⨯ 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/publish
The error occurs because electron-builder tries to read the .git/config file from the vendor/nativephp/desktop/resources/electron/ directory to determine the repository information, but that directory doesn't contain a .git folder (only the project root does).
Even though I have a valid Git repository initialized at the project root with the correct remote configured, electron-builder can't access it because it's running from within the vendor directory.
How to reproduce the bug
Create a new NativePHP Laravel project
Initialize a Git repository at the project root:
git init
git remote add origin https://github.com/username/repo.git
Configure the GitHub auto-updater in your .env file:
NATIVEPHP_UPDATER_ENABLED=true
NATIVEPHP_UPDATER_PROVIDER=github
GITHUB_REPO=your-repo
GITHUB_OWNER=your-username
GITHUB_PRIVATE=true
GITHUB_TOKEN=your-token
Run the NativePHP build command:
php artisan native:build mac
The build will fail with the error: Cannot detect repository by .git/config
The issue occurs because electron-builder runs from vendor/nativephp/desktop/resources/electron/ and tries to read .git/config from that location, which doesn't exist.
Debug Output
Pour le champ "Debug Output", vous pouvez copier-coller la sortie complète de votre build. Voici un exemple formaté :
✓ built in 2.75s
• electron-builder version=25.1.8 os=23.6.0
• updater config {
provider: 'github',
repo: 'myrepository',
owner: 'myuser',
vPrefixedTagName: true,
private: true,
channel: 'latest',
releaseType: 'draft'
}
• loaded configuration file=/Users/gael/Sites/tests/nativPHP-laravel11-beta/vendor/nativephp/desktop/resources/electron/electron-builder.mjs
• writing effective config file=/Users/gael/Sites/tests/nativPHP-laravel11-beta/nativephp/electron/dist/builder-effective-config.yaml
• building php binary - exec php.js --mac --arm64
• skipped dependencies rebuild reason=npmRebuild is set to false
• packaging platform=darwin arch=arm64 electron=38.7.2 appOutDir=/Users/gael/Sites/tests/nativPHP-laravel11-beta/nativephp/electron/dist/mac-arm64
• file source doesn't exist from=/Users/gael/Sites/tests/nativPHP-laravel11-beta/extras
⨯ 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/publish failedTask=build stackTrace=Error: 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/publish
at getInfo (/Users/gael/Sites/tests/nativPHP-laravel11-beta/vendor/nativephp/desktop/resources/electron/node_modules/app-builder-lib/src/publish/PublishManager.ts:550:13)
at getResolvedPublishConfig (/Users/gael/Sites/tests/nativPHP-laravel11-beta/vendor/nativephp/desktop/resources/electron/node_modules/app-builder-lib/src/publish/PublishManager.ts:559:18)
at resolvePublishConfigurations (/Users/gael/Sites/tests/nativPHP-laravel11-beta/vendor/nativephp/desktop/resources/electron/node_modules/app-builder-lib/src/publish/PublishManager.ts:442:16)
at getPublishConfigs (/Users/gael/Sites/tests/nativPHP-laravel11-beta/vendor/nativephp/desktop/resources/electron/node_modules/app-builder-lib/src/publish/PublishManager.ts:416:10)
at getAppUpdatePublishConfiguration (/Users/gael/Sites/tests/nativPHP-laravel11-beta/vendor/nativephp/desktop/resources/electron/node_modules/app-builder-lib/src/publish/PublishManager.ts:248:73)
at /Users/gael/Sites/tests/nativPHP-laravel11-beta/vendor/nativephp/desktop/resources/electron/node_modules/app-builder-lib/src/publish/PublishManager.ts:118:29
Which operating systems have you seen this occur on?
macOS
Notes
Temporary Workaround:
The issue can be temporarily fixed by manually editing vendor/nativephp/desktop/resources/electron/electron-builder.mjs and adding a repository field to the extraMetadata section:
js
extraMetadata: {
name: fileName,
homepage: appUrl,
version: appVersion,
author: appAuthor,
repository: {
type: 'git',
url: 'https://github.com/username/repo.git'
}
},
However, this modification is lost every time the NativePHP package is updated via Composer.
Suggested Solution:
Add environment variables like NATIVEPHP_REPOSITORY_TYPE and NATIVEPHP_REPOSITORY_URL to allow users to configure the repository information without modifying vendor files.