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

Composer InstalledVersions not found #620

Closed
dantleech opened this issue Oct 25, 2024 · 8 comments · Fixed by #621
Closed

Composer InstalledVersions not found #620

dantleech opened this issue Oct 25, 2024 · 8 comments · Fixed by #621
Assignees
Labels

Comments

@dantleech
Copy link
Contributor

Hi @localheinz 👋

Steps required to reproduce the problem

  1. Use enable and use this extensions as a PHAR then
  2. Try and use InstalledVersions in a PHPUnit test case:
\Composer\InstalledVersions::getVersion('some/package')

Expected Result

Returns the composer package version for the given package.

Actual Result

"fail" with the warning:

include(phar:///data/.tools/phpunit/extension/phpunit-slow-test-detector.phar/vendor/composer/../composer/InstalledVersions.php): Failed to open stream: phar error: "vendor/composer/InstalledVersions.php" is not a file in phar "/data/.tools/phpunit/extension/phpunit-slow-test-detector.phar"

It seems that the slow-test-detector's PHAR vendorcomposer/autoload_classmap.php has the following entry:

    'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',

and starting from version 2.15.1 it no longer exists.

@dantleech
Copy link
Contributor Author

... I can't actually reproduce this problem in isolation, I'll check later today when I can.

@localheinz localheinz self-assigned this Oct 25, 2024
@localheinz localheinz added the bug label Oct 25, 2024
@localheinz
Copy link
Member

Thank you, @dantleech - let me know if I should take a look!

@dantleech
Copy link
Contributor Author

dantleech commented Oct 25, 2024

ok, I could reproduce it I just wasn't showing the warning details 😅

see here: https://github.com/dantleech/slow-test-dector-gh-620

Let me know if you have any ideas at this point as I'm happy to investigate it further (and am getting paid to do so), I don't want to dump work on you 😄

@dantleech
Copy link
Contributor Author

dantleech commented Oct 25, 2024

ok, it is due to adding the src directory somehow as reverting that ensures that vendor/composer/InstalledVersions.php remains in place (confirmed using latest Box version as one on CI doesn't run on PHP8.2..)

diff --git a/box.json b/box.json
index 7a107ea..a3d2ee6 100644
--- a/box.json
+++ b/box.json
@@ -5,9 +5,6 @@
     "KevinGH\\Box\\Compactor\\Php"
   ],
   "compression": "GZ",
-  "directories": [
-    "src/"
-  ],
   "files": [
     "manifest.xml"
   ],

dantleech added a commit to dantleech/phpunit-slow-test-detector that referenced this issue Oct 25, 2024
…lled.php` in PHAR

The autoloadmap includes a mapping `Composer\InstalledVersions` but as
of explicitly including `src` this file is no longer included.

This commit explicitly adds both `vendor/composer/InstalledVersions.php`
and `vendor/composer/installed.php` to ensure that the previous behavior
is preserved and WARNINGS are not issued when other packages use
`InstalledVersions::getVersion(// ...)`.
@dantleech
Copy link
Contributor Author

ok, and this is a "fix": #621

Incidentally calling InstalledVersions::getVersion('my/version') returns the project's package version as expected - so I'm not sure how/why it's trying to autoload (and subsequently include installed.php) from the PHAR's vendor dir.

So I'm not sure I have the courage to call it a "fix" but it will at least preserve the original behavior.

localheinz pushed a commit to dantleech/phpunit-slow-test-detector that referenced this issue Oct 25, 2024
…lled.php` in PHAR

The autoloadmap includes a mapping `Composer\InstalledVersions` but as
of explicitly including `src` this file is no longer included.

This commit explicitly adds both `vendor/composer/InstalledVersions.php`
and `vendor/composer/installed.php` to ensure that the previous behavior
is preserved and WARNINGS are not issued when other packages use
`InstalledVersions::getVersion(// ...)`.
localheinz pushed a commit to dantleech/phpunit-slow-test-detector that referenced this issue Oct 25, 2024
…lled.php` in PHAR

The autoloadmap includes a mapping `Composer\InstalledVersions` but as
of explicitly including `src` this file is no longer included.

This commit explicitly adds both `vendor/composer/InstalledVersions.php`
and `vendor/composer/installed.php` to ensure that the previous behavior
is preserved and WARNINGS are not issued when other packages use
`InstalledVersions::getVersion(// ...)`.
localheinz added a commit that referenced this issue Oct 25, 2024
gh-620: Explicitly include `InstalledVersions.php` and `installed.php` in PHAR
@localheinz
Copy link
Member

Released with ergebnis/phpunit-slow-test-detector:2.16.1!

@dantleech
Copy link
Contributor Author

wow, thanks 🎉

@localheinz
Copy link
Member

Thank you for reporting and fixing, @dantleech!

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