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

Clearing caches after defining webroot => 'public/' alias removes gitignore in cpresources #7361

Closed
Wiejeben opened this issue Jan 7, 2021 · 3 comments
Labels

Comments

@Wiejeben
Copy link
Contributor

Wiejeben commented Jan 7, 2021

Description

Basically as the title says. I have never understood the red message when clearing caches until I saw #7286 in the changelog.

I use the public directory instead of web, so I added the following to my general config:

'aliases' => [
    'webroot' => 'public/',
]

Unrelated: Isn't the public directory supposed to automatically be detected in my scenario?

If your web root is something besides web/, public/, public_html/, or html/, or it’s not located alongside your craft executable, you will also need to override the @webroot alias, so it can be defined properly for console commands. (docs)

After executing ./craft clear-caches/all I noticed the red message was gone! But when I went to commit the change I noticed the public/cpresources/.gitignore was now also being deleted.

Even after going to /admin to regenerate the cpresources it does not recreate the .gitignore file.

Additional info

  • Craft version: 3.5.17.1
  • PHP version: 7.4.13
  • Database driver & version: MySQL 5.7
  • Plugins & versions: -
@Wiejeben Wiejeben added the bug label Jan 7, 2021
@Wiejeben
Copy link
Contributor Author

Wiejeben commented Jan 7, 2021

Regression of #2823

@Wiejeben Wiejeben changed the title Clearing all caches after defining webroot => 'public/' alias removes gitignore in cpuresources Clearing caches after defining webroot => 'public/' alias removes gitignore in cpuresources Jan 7, 2021
@brandonkelly
Copy link
Member

Thanks for pointing that out! From the looks of it, maybe #2823 was never really resolved in the first place. Not sure why I couldn’t reproduce it at the time, but was able to now, and just fixed for the next release.

I use the public directory instead of web, so I added the following to my general config:

'aliases' => [
    'webroot' => 'public/',
]

You might run into issues setting the @webroot alias to just 'public/'. Better to go with an absolute path:

'aliases' => [
    '@webroot' => dirname(__DIR__) . '/public',
],

@Wiejeben Wiejeben changed the title Clearing caches after defining webroot => 'public/' alias removes gitignore in cpuresources Clearing caches after defining webroot => 'public/' alias removes gitignore in cpresources Jan 12, 2021
@brandonkelly
Copy link
Member

Craft 3.5.18 is out now with that fix ✨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants