Git autocommitting broken on a fresh install of Statamic
Bug description
Please see the thread: https://discord.com/channels/489818810157891584/1240373773279039499/1240374342303350876
for reference.
Autocommit to git fails with messages like:
[2024-05-16 21:39:36] production.ERROR: Process Class: Git
Command: -c "user.name=Amadeusz Annissimo" -c "[email protected]" commit -m "Content saved"
Error: sh: 1:
-c: not found
Replacing config('statamic.git.binary') to hardcoded git fixes the issue. Most likely this bug was introduced here:
https://github.com/statamic/cms/commit/770dc485dd2b330b40816c68727f080e45f18bfc
How to reproduce
Fresh install of Statamic. Set up git autocommit as per docs. Make any changes in the entry. Check application logs for errors.
Logs
No response
Environment
Environment
Application Name: *****
Laravel Version: 10.48.8
PHP Version: 8.3.3-1+ubuntu22.04.1+deb.sury.org+1
Composer Version: 2.7.6
Environment: production
Debug Mode: OFF
URL: *****
Maintenance Mode: OFF
Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED
Drivers
Broadcasting: log
Cache: statamic
Database: mysql
Logs: stack / single
Mail: mailgun
Queue: sync
Session: file
Statamic
Addons: 2
Antlers: runtime
Sites: 1
Stache Watcher: Enabled
Static Caching: Disabled
Version: 4.56.1 PRO
Statamic Addons
statamic/seo-pro: 5.4.4
stefangalescu/statamic-heroicons: 2.1.1
Installation
Fresh statamic/statamic site via CLI
Additional details
No response
Did you try clearing your config cache?
php artisan config:clear
It sounds like the config('statamic.git.binary') is returning empty which should not be happening if you have this line in your config: https://github.com/statamic/cms/blob/4.x/config/git.php#L119
'binary' => env('STATAMIC_GIT_BINARY', 'git'),
@godismyjudge95 Yes, I did. My guess is that you can't reference config values from the same config file you're on.
I tested it to on a fresh install of Statamic.
When you run in tinker:
config('statamic.git.binary'), you get git.
When you run:
config('statamic.git.commands'), you get:
[ " add {{ paths }}", " -c "user.name={{ name }}" -c "user.email={{ email }}" commit -m "{{ message }}"", ]
Meaning, the config('statamic.git.binary') is not read from config. Doesn't matter if I set STATAMIC_GIT_BINARY to git, or even hardcode statamic.git.binary to git. The value is always blank when referenced dynamically from statamic.git.commands.
It worked fine before this: https://github.com/statamic/cms/commit/770dc485dd2b330b40816c68727f080e45f18bfc
I didn't think you could reference from the same file either, but when I tested that PR it seemed to work. Maybe I had something weird setup and got a false positive. We can check it over.