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

Permission denied ... Kernel.php on line 486 #3067

Closed
UFTimmy opened this issue Mar 25, 2020 · 14 comments · Fixed by #3106
Closed

Permission denied ... Kernel.php on line 486 #3067

UFTimmy opened this issue Mar 25, 2020 · 14 comments · Fixed by #3106

Comments

@UFTimmy
Copy link
Contributor

UFTimmy commented Mar 25, 2020

Bug Report

Subject Details
Rector version 0.7.7
Installed as both

When running rector I started getting the following errors:

When run regular (rector/rector)

vendor\bin\rector process src --set=php74 --dry-run
PHP Notice:  include(): read of 4096 bytes failed with errno=13 Permission denied in \rector-test-2\vendor\symfony\http-kernel\Kernel.php on line 486
Notice: include(): read of 4096 bytes failed with errno=13 Permission denied in \rector-test-2\vendor\symfony\http-kernel\Kernel.php on line 486

When run prefixed:

vendor\bin\rector process src --set=php74 --dry-run
PHP Notice:  include(): read of 4096 bytes failed with errno=13 Permission denied in phar://.../rector-test/vendor/rector/rector-prefixed/rector/vendor/symfony/http-kernel/Kernel.php on line 487
Notice: include(): read of 4096 bytes failed with errno=13 Permission denied in phar://.../rector-test/vendor/rector/rector-prefixed/rector/vendor/symfony/http-kernel/Kernel.php on line 487

I made a new folder and then included rector via composer and nothing else:
composer require rector/rector-prefixed OR composer require rector/rector

Then I made a super simple PHP file in src called HelloWorld.php that's blank.

We started getting this error in our real setup when upgrading rector, but I hope the above is a simple enough way to replicate it.

So right now it's happening in our real, more complex project, and in these two super simple test cases. It's happening on multiple computers.

I've tried setting windows permissions to give full control of the files to everyone, but it hasn't helped.

These are all Windows computers. I do not get the error when doing same thing from Ubuntu.

If there are changes to be made, Rector will still make them. But it always put those two lines of error at the top, which breaks JSON parsing of the output.

@TomasVotruba
Copy link
Member

What happens with --debug option?

How did you debug Kernel.php on line 486?

@UFTimmy
Copy link
Contributor Author

UFTimmy commented Mar 25, 2020

Here's the debug output

C:\...\rector-test-2>vendor\bin\rector process src --set=php74 --dry-run --debug
File "C:\...\rector-test-2/vendor/autoload.php" is about to be loaded in "AutoloadIncluder::includeCwdVendorAutoloadIfExists()" on line 63"
File "C:\...\rector-test-2\vendor\rector\rector/../../autoload.php" is about to be loaded in "AutoloadIncluder::autoloadProjectAutoloaderFile()" on line 95"
PHP Notice:  include(): read of 4096 bytes failed with errno=13 Permission denied in C:\...\rector-test-2\vendor\symfony\http-kernel\Kernel.php on line 486
Notice: include(): read of 4096 bytes failed with errno=13 Permission denied in C:\...\rector-test-2\vendor\symfony\http-kernel\Kernel.php on line 486
Rector v0.7.7



 [OK] Rector is done!

Sorry, I don't understand your question about me debugging that line. I did not. But that's the full error that it gives, it says Permission denied on that line.

@TomasVotruba
Copy link
Member

In the report I see Kernel.php on line 486

You can open that file on that line and debug it. I think there will be more intell on your problem.

@UFTimmy
Copy link
Contributor Author

UFTimmy commented Mar 25, 2020

I'm sorry, can you tell me what you mean by debug it? Do you mean step through with Xdebug?

@UFTimmy
Copy link
Contributor Author

UFTimmy commented Mar 25, 2020

Ok, I think I see what you mean. I assumed it was erroring trying to load the Kernel.php file, but it looks like that line is responsible for loading the Symfony cache. It looks like it's trying to load cache from this path:

C:\Users\Tim\AppData\Local\Temp/_rector/Rector_Core_HttpKernel_RectorKernelProd169155Container.php

How do I fix permissions there? I've tried running the cmd prompt as an admin, but that has no effect.

@TomasVotruba
Copy link
Member

I don't work with Windows for ~8 years, so I have no idea.

@UFTimmy
Copy link
Contributor Author

UFTimmy commented Mar 27, 2020

So I don't have a solution for this, but I'm going to close it anyway.

The RectorKernel is telling Symfony to create the cache in sys_get_temp_dir() . '/_rector';

That should be fine, I should have permission to that folder, since I can create files there. But I don't. I've tried changing the path to other places, and I've tried giving full control to every user, but nothing works.

@UFTimmy UFTimmy closed this as completed Mar 27, 2020
@TomasVotruba
Copy link
Member

TomasVotruba commented Mar 27, 2020

It's only thing that comes to my mind:

-sys_get_temp_dir() . '/_rector';
+sys_get_temp_dir() . DIRECTORY_SEPARATOR . '_rector';

@UFTimmy
Copy link
Contributor Author

UFTimmy commented Mar 27, 2020

Good suggestion, but it didn't seem to help.

@TomasVotruba
Copy link
Member

TomasVotruba commented Mar 27, 2020

Then you can add option to change this path via parameter.
Just send PR.

@UFTimmy
Copy link
Contributor Author

UFTimmy commented Mar 27, 2020

So I did some more sleuthing into that code in the Symfony Kernel, and I realized it's trying to read from a file that it has locked. And then I was able to find a GitHub issue from Symfony that references it. It is indeed a Symfony/PHP7.4 bug in Windows.

Here's the GitHub issue:
symfony/symfony#36132

And here's the Symfony fix:
symfony/symfony#36169

I think if you upgrade Rector's Symfony version to 4.4.6 then it will be fixed.

I appreciate your help in looking into it.

@TomasVotruba
Copy link
Member

I think if you upgrade Rector's Symfony version to 4.4.6 then it will be fixed.

Could you try that locally?

If it works, send PR here to composer.json

Awesome work 👏 👍

@UFTimmy
Copy link
Contributor Author

UFTimmy commented Mar 27, 2020

So I did a composer update rector/rector --with-dependencies locally, and it updated all of the Symfony packages from 5.0.5 to 5.0.6 (including symfony/http-kernel where the fix is).

That fixed the error for me. Since rector's composer.json files allow you to get the fix, I'm not sure there's merit in restricting it to 4.4.6 or 5.0.6, but if you'd like me I will make the PR.

@TomasVotruba
Copy link
Member

...but if you'd like me I will make the PR.

Yes, go for it!

TomasVotruba added a commit that referenced this issue Nov 15, 2022
rectorphp/rector-src@fa9a953 [Php80] Skip possible numeric string switch cond with all integer case cond on ChangeSwitchToMatchRector (#3067)
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 a pull request may close this issue.

2 participants