statamic / cms

The core Laravel CMS Composer package
https://statamic.com
Other
4.09k stars 536 forks source link

Filesystems not loaded when installing a starter kit with `starter-kit:install` command #9884

Open robdekort opened 7 months ago

robdekort commented 7 months ago

Bug description

I'm sorry for this one in advance.

To test my post install script in Peak I install Statamic v5 using composer create-project and then run starter-kit:install --local. After creating a super user I get an InvalidArgumentException:

  Disk [favicons] does not have a configured driver.

  at vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemManager.php:137
    133▕     {
    134▕         $config ??= $this->getConfig($name);
    135▕
    136▕         if (empty($config['driver'])) {
  ➜ 137▕             throw new InvalidArgumentException("Disk [{$name}] does not have a configured driver.");
    138▕         }
    139▕
    140▕         $name = $config['driver'];
    141▕

      +20 vendor frames

  21  [internal]:0
      Statamic\Assets\QueryBuilder::Statamic\Assets\{closure}("favicons")
      +13 vendor frames

  35  [internal]:0
      Statamic\Assets\AssetRepository::Statamic\Assets\{closure}(Object(Statamic\Assets\AssetContainer))

Peak contains a bunch of custom filesystems that are being used by the asset containers it ships with. It seems those don't get properly loaded during the install. This does work as expected in v4.

The solution is to run the install command a second time.

How to reproduce

  1. composer create-project --prefer-dist --stability=dev statamic/statamic:dev-master
  2. php please starter-kit:install studio1902/statamic-peak --local

Note: I'm installing a local version of Peak because the v5 version isn't released yet. You could replicate this using this statamic-peak.zip.

You will also need: peak-addons.zip

Logs

No response

Environment

Environment
Application Name: My app
Laravel Version: 11.3.1
PHP Version: 8.3.6
Composer Version: 2.7.1
Environment: local
Debug Mode: ENABLED
URL: localhost
Maintenance Mode: OFF

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: NOT CACHED

Drivers
Broadcasting: log
Cache: statamic
Database: sqlite
Logs: stack / single
Mail: smtp
Queue: sync
Session: file

Statamic
Addons: 4
Sites: 1
Stache Watcher: Enabled
Static Caching: Disabled
Version: 5.0.0-alpha.3 PRO

Statamic Addons
studio1902/statamic-peak-browser-appearance: 3.3.4
studio1902/statamic-peak-commands: 6.1.0
studio1902/statamic-peak-seo: 8.2.0
studio1902/statamic-peak-tools: 4.4.2

Installation

Fresh statamic/statamic site via CLI

Antlers Parser

None

Additional details

No response

duncanmcclean commented 7 months ago

From digging into this, it looks like the issue is actually happening when Statamic attempts to create the super user, which is the step before a starter kit's post-install script runs.

For some reason, it looks like the custom disks configured in Peak's filesystems.php file aren't loaded by the point the make:user command is run via $this->console->call(). Not sure why it'd suddenly be breaking on v5, unless it was a change somewhere in Laravel 11. 🤔

Probably needs some more digging.

robdekort commented 7 months ago

Odd thing is also: it doesn't seem to go wrong consistently.

duncanmcclean commented 7 months ago

I've done a little more testing and it seems like this issue also exists on Statamic 4 too, it only happens when you install a starter kit into an existing site, not when creating a fresh site with the CLI.

  1. Run statamic new brand-new-site
  2. Run php please starter-kit:install studio1902/statamic-peak
  3. When it prompts you about creating a new user, do it
  4. When it goes to save the user, it'll error
robdekort commented 7 months ago

I've done a little more testing and it seems like this issue also exists on Statamic 4 too, it only happens when you install a starter kit into an existing site, not when creating a fresh site with the CLI.

Ah, nice find. Yeah I'd never actually done that until now, to test v5. It's not a blocker then, glass half full!