| Subject | Details |
| :------------- | :---------------------------------------------------------------|
| Rector version | e.g. v0.8.56 |
| Installed as | composer dependency |
I want to upgrade ECS to ^9.0 but dependencies cannot be resolved:
$ composer update symplify/easy-coding-standard --with-dependencies
Loading composer repositories with package information
Restricting packages listed in "symfony/symfony" to "^5.1"
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- rector/rector is locked to version 0.8.56 and an update of this package was not requested.
- rector/rector 0.8.56 requires symplify/autowire-array-parameter ^8.3.48 -> found symplify/autowire-array-parameter[8.3.48] but it conflicts with another require.
Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
$ composer why-not symplify/easy-coding-standard ^9.0
symplify/easy-coding-standard 9.0.11 requires symplify/coding-standard (^9.0.11)
__root__ dev-master does not require symplify/coding-standard (but 8.3.48 is installed)
symplify/easy-coding-standard 9.0.11 requires symplify/package-builder (^9.0.11)
__root__ dev-master does not require symplify/package-builder (but 8.3.48 is installed)
symplify/easy-coding-standard 9.0.11 requires symplify/set-config-resolver (^9.0.11)
__root__ dev-master does not require symplify/set-config-resolver (but 8.3.48 is installed)
symplify/easy-coding-standard 9.0.11 requires symplify/symplify-kernel (^9.0.11)
__root__ dev-master does not require symplify/symplify-kernel (but 8.3.48 is installed)
symplify/easy-coding-standard 9.0.11 requires symplify/smart-file-system (^9.0.11)
__root__ dev-master does not require symplify/smart-file-system (but 8.3.48 is installed)
symplify/easy-coding-standard 9.0.11 requires symplify/autowire-array-parameter (^9.0.11)
__root__ dev-master does not require symplify/autowire-array-parameter (but 8.3.48 is installed)
symplify/easy-coding-standard 9.0.11 requires symplify/console-color-diff (^9.0.11)
__root__ dev-master does not require symplify/console-color-diff (but 8.3.48 is installed)
symplify/easy-coding-standard 9.0.11 requires symplify/easy-testing (^9.0.11)
__root__ dev-master does not require symplify/easy-testing (but 8.3.48 is installed)
Create composer.json with content:
{
"type": "project",
"license": "proprietary",
"require": {
"rector/rector": "^0.8",
"symplify/easy-coding-standard": "^9.0"
},
"config": {
"optimize-autoloader": true,
"preferred-install": {
"*": "dist"
},
"sort-packages": true
}
}
and run composer install.
It should be possible to use newest versions of Rector and ECS in the same project.
Hi, this is not a bug but version constraint.
Rector 0.9 will be compatible with Symplify 9.
I'm the meantime, we need more testing.
How does "dev-master" work for you?
From user's perspective this is like a bug, but I understand your PoV.
Tried dev-master but unfortunately it failed to run Rector:
$ php vendor/bin/rector
PHP Warning: require_once(/var/www/html/vendor/rector/rector/bin/rector.php): failed to open stream: No such file or directory in /var/www/html/vendor/rector/rector/bin/rector on line 4
PHP Fatal error: require_once(): Failed opening required '/var/www/html/vendor/rector/rector/bin/rector.php' (include_path='.:/usr/local/lib/php') in /var/www/html/vendor/rector/rector/bin/rector on line 4
I checked vendor/rector/rector/bin and there wasn't rector.php file even though I see it in the repo. I've deleted vendor/rector/rector and reinstalled it:
$ php composer install
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Package operations: 1 install, 0 updates, 0 removals
- Installing rector/rector (dev-master 3489c8a): Extracting archive
Skipped installation of bin bin/rector for package rector/rector: name conflicts with an existing file
Generating optimized autoload files
composer/package-versions-deprecated: Generating version class...
composer/package-versions-deprecated: ...done generating version class
136 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
Run composer recipes at any time to see the status of your Symfony recipes.
Executing script cache:clear [OK]
Executing script assets:install public [OK]
and file is still missing. Looks like it's discarded by Github when creating ZIP file. I've created this file with content taken from Github and got other issues, fixed one by one:
bundles.php (wrong FQCN for ComposerJsonManipulatorBundle, non-existing ConsoleColorDiffBundle reference)EXCLUDE_RECTORS option (changed to SKIP)EXCLUDE_PATHS (had to change PATHS definition to change excluding policy)Some of these issues should be addressed, I think :slightly_smiling_face:
The vendor/rector/rector/bin does not look familiar. The correct is vendor/bin/rector
What OS do you use? There might be OS-based issue with symlinks
I've removed /vendor on another project, run composer update with rector/rector: dev-master and this works fine:
➜ symplify git:(master) vendor/bin/rector --version
Rector dev-master@3489c8a
The steps you've described are part of upgrade from 0.8 to 0.9.
I'll create an upgrade file to mentioned them, thank you :+1:
I use Ubuntu 20.10 but all commands mentioned earlier were executed in Docker container.
vendor/rector/rector/bin is Rector's repo relative path to binary file, where vendor/bin/rector is a path to proxy file (or symlink) created by Composer on package install (based on "bin": ["bin/rector"] in composer.json). This is totally correct. vendor/bin/rector calls vendor/rector/rector/bin/rector and there is require_once __DIR__ . '/rector.php'; in this file. And this is actual problem, that file is missing. This is not OS-based issue, you can download Rector as ZIP from Github (linked it in previous comment) and there won't be this file in the archive. Most probably your project does not have "preferred-install": {"*": "dist"} but installs packages with Git/SSH so file was cloned along with the others. In my project packages are downloaded as ZIP files (and you can see it in the provided output → "Extracting archive"), and there is not bin/rector.php file.
I've compare it with v0.8.56 and there isn't bin/rector.php too, BUT bin/rector does not include it, there is proper code instead.
I think this is root cause of the problem (see) :slightly_smiling_face:
Most probably your project does not have "preferred-install": {"*": "dist"}
That's it! Any idea how to fix this for Zips?
https://github.com/rectorphp/rector/blob/d6adfda6996d53f89dbc192b916c5a4e1c03d0e2/.gitattributes#L22
That should be only for root rector.php, does it apply for any file with this name?
How can we fix it?
The fix for dist files would be ensuring that bin/rector.php is bundled in the archive. I thought that changing to ./rector.php in .gitattributes would solve it but unfortunately it doesn't. Because rector.php is definition for Rector itself I would go with renaming bin/rector.php or going back to simple bin/rector. I see here that the reason of this change was:
decouple rector.php to allow static analysis and coding standards
but wouldn't it be better to explicitely add bin/rector to PHPStan's and ECS' configurations? Because if I understood correctly it wasn't checked because it does not have *.php extension?
but wouldn't it be better to explicitely add bin/rector to PHPStan's and ECS' configurations
That was the way in the past. But it was unexpected behavior, so it had to be added everywhere manually.
Same we had in Symplify, where 15 files were not checked by any tool.
.gitattributes would solve it but unfortunately it doesn't.
What about something like:
rector.php
!bin/rector.php
Not sure what the negation sign is here !, but you get the idea
@TomasVotruba from the docs:
negative patterns are forbidden
and
Sometimes you would need to override a setting of an attribute for a path to Unspecified state. This can be done by listing the name of the attribute prefixed with an exclamation point !.
So the solution is adding bin/.gitattributes with:
rector.php !export-ignore
PS. this works only after commiting this file to the repo, since git archive -o rector.zip HEAD will use attributes from head, not from working directory. Let me create PR for that :)
Installed dev-master#495e2b5 and it seems to be working :+1:
When Rector 0.9 will be released? Because I don't know if I should stick with dev-master or wait a bit and upgrade to stable release.
Installed dev-master#495e2b5 and it seems to be working +1
That's good news! Thanks for solving the issue.
Could you test Rector behavior for 2-3 days? I plan to release it in a week, so we have time to solve breaking bugs like this.
OK, I'll use it for daily work and will let you know if I find any issues :+1:
@TomasVotruba so far I did not have any issues. Any news on the release?
Thank you for report.
So far we have 2 blockers reported in: https://github.com/rectorphp/rector/issues/4913