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
[2.2.2+] $this->composer->getConfig()->get('bin-dir') returns incorrect path on Windows #10504
Comments
Just in case anyone is wondering how I got the output I'm showing:
|
Based on the changelog I suspect this is related to #10402 |
Oh I guess COMPOSER_BIN_DIR as defined in the .bat file is then read by Composer inside your process somehow? Depends how you run the test suite but if you start the test suite via a Composer script probably this might happen. So I guess that name was poorly chosen as it clashes with the existing COMPOSER_BIN_DIR env var that Composer reads. Probably should rename that to something else (but what?).. But I am unsure why this would only break on Windows.. Kinda would like to understand this more before messing with things. Do you have a way to access the build system, to perhaps change the .bat file so COMPOSER_BIN_DIR is called something else see if that fixes? |
@Seldaek I'm not actually calling Composer via the |
No I don't mean composer I mean phpunit or whatever test runner. |
The only way I see this could corrupt things is if you have a workflow like:
|
Ah, I see. Yes, calling PHPUnit via You can see the basic principle of the setup I'm using here: PHPCSStandards/composer-installer#153 This doesn't include the specific test through which I found this issue yet, but I can put that online in a follow-up branch (can't pull it yet until the above mentioned PR has been merged). |
OK so if you run vendor/bin/phpunit directly.. I guess this is also the same mechanism as above, the first two steps are actually not needed I don't know what I was thinking :) All that's needed is that you run a .bat file first, then run Composer within your tests. To confirm this suspicion you could try to change your CI run to use |
@Seldaek I'll get a test running when I finish what I'm currently working on and will report back. FYI: for this particular plugin I have actually lined up a work-around in the plugin already, but yes, that doesn't negate the underlying issue. |
Test run showing the problem using Test run using Both runs are selective, only running the specific test via which I discovered the issue, and both contain debug logging output in the test run output (for both for the successful as well as the failed test runs) which shows the |
OK great, thanks! |
…s as env var since Composer 2.2.2) to COMPOSER_RUNTIME_BIN_DIR to fix a regression due to a name clash, fixes composer#10504
Context
I'm currently in the process of writing End-to-End tests for the DealerDirect PHPCS Composer Installer plugin and discovered the following due to tests failing.
Problem description
In the plugin we call PHPCS using the following code, which should be executed either in the Composer global or the project local directory, depending on the context in which a Composer
install
/update
is being run:This used to work correctly in all cases, but since Composer 2.2.2, it appears to be broken on Windows (server).
Based on my debugging:
Output of
$this->composer->getConfig()->get('bin-dir')
for Composer < 2.2.2 on Windows (via GitHub actions)This output is correct and as expected:
/tmp/PHPCSPluginTest/PreexistingPHPCSInstalledPathsConfigTest_61fa7843f015f2.37374271/global/vendor/bin
C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\PHPCSPluginTest\\PreexistingPHPCSInstalledPathsConfigTest_61fa786d7645e1.82846304\\global/vendor/bin
/tmp/PHPCSPluginTest/PreexistingPHPCSInstalledPathsConfigTest_61fa784784d707.70495208/local/vendor/bin
C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\PHPCSPluginTest\\PreexistingPHPCSInstalledPathsConfigTest_61fa787cb36404.36256677\\local/vendor/bin
Output of
$this->composer->getConfig()->get('bin-dir')
for Composer 2.2.2 up to snapshot on Windows (via GitHub actions)This output is wrong for Windows, correct for Ubuntu:
/tmp/PHPCSPluginTest/PreexistingPHPCSInstalledPathsConfigTest_61fa783fcdb903.30230172/global/vendor/bin
D:\\a\\phpcodesniffer-composer-installer\\phpcodesniffer-composer-installer\\vendor\\bin
/tmp/PHPCSPluginTest/PreexistingPHPCSInstalledPathsConfigTest_61fa7842c99229.60312001/local/vendor/bin
D:\\a\\phpcodesniffer-composer-installer\\phpcodesniffer-composer-installer\\vendor\\bin
The text was updated successfully, but these errors were encountered: