Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#270 Removing a provider breaks Acorn until removing the packages cache #295

Merged
merged 10 commits into from
Mar 18, 2024

Conversation

chrillep
Copy link
Contributor

@chrillep chrillep commented Jun 20, 2023

fixes #270

  • tested on radicle

  • needs more testing in other contexts

did some digging and laravels default method is not invoking a new Process of the command via cli. Its removing the cache files in the same instance.

https://github.com/laravel/framework/blob/e217dca49e20cd2840970f8d307c8392012bc5be/src/Illuminate/Foundation/ComposerScripts.php#L48-L69

While acorn is initiating new Process of wp acorn cli command. It fails returning exit code 1. Since the Provider may have been removed when executing.

$console->clearCompiled();

/**
* Execute acorn clear-compiled command.
*
* @return int
*/
public function clearCompiled(): int
{
return $this->acorn('clear-compiled');
}

/**
* Execute acorn command.
*
* @param array $command
* @return int
*/
public function acorn($command): int
{
$command = array_merge($this->findWpCli(), ['acorn'], (array) $command);
return $this->getProcess($command)->run();
}

Possible solution.

Reuse laravels method and make sure

getCachedConfigPath() resolves to
{projectpath}/storage/framework/cache/config.php

getCachedServicesPath() resolves to
{projectpath}/storage/framework/cache/services.php

getCachedPackagesPath() resolves to
{projectPath}/storage/framework/cache/packages.php

instead of
{projectpath}/bootstrap/cache/config.php
{projectpath}/bootstrap/cache/services.php
{projectPath}/bootstrap/cache/packages.php

Copy link
Sponsor Member

@QWp6t QWp6t left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! 🙏

I haven't tested this, but I noticed an issue with your approach. Let me know if you want me to jump in and help get this over the finish line or if you prefer to tackle it.

src/Roots/Acorn/ComposerScripts.php Outdated Show resolved Hide resolved
@chrillep
Copy link
Contributor Author

Thanks for the PR! 🙏

I haven't tested this, but I noticed an issue with your approach. Let me know if you want me to jump in and help get this over the finish line or if you prefer to tackle it.

Yeah that would be great! You jump in and get it over the finish line. 😀

I just wanted to get the ball rolling with what I found.

@chrillep
Copy link
Contributor Author

@QWp6t Sry ping 😂

@chrillep
Copy link
Contributor Author

chrillep commented Dec 7, 2023

@QWp6t Sry ping again

@retlehs
Copy link
Sponsor Member

retlehs commented Jan 25, 2024

This PR doesn't work for me 👀 Steps tested on a regular Bedrock install:

  1. composer require roots/acorn
  2. composer require roots/acorn-prettify
  3. wp acorn optimize:clear
  4. Pull in the changes from this PR
  5. composer remove roots/acorn-prettify
  6. wp acorn
Skipping provider [Roots\AcornPrettify\AcornPrettifyServiceProvider] because it does not exist.

@Log1x Log1x requested a review from QWp6t March 18, 2024 18:12
Copy link
Sponsor Member

@QWp6t QWp6t left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! :shipit:

@Log1x Log1x merged commit b6a0171 into roots:main Mar 18, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Removing a provider breaks Acorn until removing the packages cache
4 participants