-
-
Notifications
You must be signed in to change notification settings - Fork 358
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
[DX] Merge RectorConfig cacheDirectory() and containerCacheDirectory() to one to ease changing paths in case of non-writeable cache #4803
Conversation
@@ -49,7 +49,7 @@ public function __construct( | |||
|
|||
$containerFactory = new ContainerFactory(getcwd()); | |||
$this->container = $containerFactory->create( | |||
SimpleParameterProvider::provideStringParameter(Option::CONTAINER_CACHE_DIRECTORY), | |||
sys_get_temp_dir() . '/phpstan-container-for-rector', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
containerCacheDirectory()
is used for user that doesn't have access to the sys_get_temp_dir()
specific dir, and also for multi user purpose, this cause conflict, that's why it is needed, see issue:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also see original issue:
raised because of it, the default container cache dir is not writable because of no access or internal PHP bug on sys_get_temp_dir()
on specific OS/platform.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see original PR that introduce:
it cover usage on shared hosting usage which user can't have access to sys_get_temp_dir()
due to shared usage., that's why containerCacheDirectory()
options set is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, by define this, user will got error:
[ERROR] The file "/var/folders/dv/m3gvpzh94t59l94qz3w2dgfr0000gn/T/phpstan-container-for-rector" does not exist.
The create()
doesn't automatically create directory target, it need to be exists before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see ;). We can go for defaults here And alkw override by user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you mean? I tried this and got error "phpstan-container-for-rector" directory not exist immediatelly, then if multi user is used, it will crash as can't be read by other user, see issue:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added note about PHPStan container so this is known right in the configuration 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at rectorphp/rector#8112, the 2 cache directory options are pretty confusing. There should be just one method to handle both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See what's @stefanides usage of multi user cause container crash error, using configurable container path resolve based on his experience:
rectorphp/rector#8112 (comment)
for what he experienced.
@TomasVotruba please don't remove it, it will crash in the first try, as:
|
I tried locally, by this change, it doesn't work, PHPStan need to fill cache directory to :
For user that doesn't have access to that dir, or require multi user purpose, that will blocked to be used, see issue: |
752dc4e
to
b136b1b
Compare
…container, only by PHPStan
b136b1b
to
4637080
Compare
We should have this test in CI. Could add simple reproducer to check this? |
The directory should be created then. I'll add it 👍 |
81625f9
to
8b3c539
Compare
8b3c539
to
84d4fe5
Compare
@TomasVotruba Merge cache location is causing error:
see https://github.com/rectorphp/rector-src/actions/runs/5888776799/job/15970657037#step:5:26 |
Looking into this. That seems like PHPStan dependency. Give me some time, I'll ask you for more feedback when ready 👍 |
/** | ||
* @info Rector no longer uses compiled container, but Laravel lazy one. | ||
* This option is for PHPStan container in case the sys_get_temp_dir() is not available for the current user. | ||
*/ | ||
public function containerCacheDirectory(string $directoryPath): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if config cache merged, this method can be deprecated and removed on 1.0 as Option::CONTAINER_CACHE_DIRECTORY
no longer be used if cache directory merged.
Note to myself: after this applied, this need to be tried in local on switch on different projects with and without |
The new "unknown cause" error is equal with issue: |
Closing for now, as our focus is somewhere else. This should be revisited once AbstractRector is lighter |
The Symfony container was compiled, but Laravel one is lazy, so doesn't use any kind of dumped cache file. PHPStan handles this in its own way, so we can drop it completely.EDIT: This option is needed for PHPStan container. Yet should be united with other cache directory option to avoid duplicated work and WTFs in rectorphp/rector#8112
Closes: rectorphp/rector#8112