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

Drupal 8 installation instructions #222

Closed
justafish opened this issue Apr 1, 2021 · 8 comments
Closed

Drupal 8 installation instructions #222

justafish opened this issue Apr 1, 2021 · 8 comments
Labels
bug Something isn't working

Comments

@justafish
Copy link

How is drupal-check installed?

drupal-check is installed as a dependency to my project

Environment:

  • OS: Linux
  • PHP Version: 7.4
  • Drupal core: 8.x.x

Describe the bug
I ran into a few conflicts that weren't obvious when installing this for Drupal 8 -

  • You can't require drupal/core-dev if you're using composer 2 as it'll dump a version of composer 1 into vendor/bin
  • If you do composer require phpunit/phpunit you get a version that's too high for Drupal 8 support

Once I required phpunit:^7 (corresponding to the highest version supported in Drupal\TestTools), everything worked great

Should the core-dev require be removed from the tests in https://github.com/mglaman/drupal-check/blob/master/.github/workflows/php.yml and replaced with just phpunit?

Console output

PHP Warning:  Class 'PHPUnit\Framework\MockObject\Matcher\InvokedRecorder' not found in /app/web/core/tests/bootstrap.php on line 198
Warning: Class 'PHPUnit\Framework\MockObject\Matcher\InvokedRecorder' not found in /app/web/core/tests/bootstrap.php on line 198
PHP Warning:  Class 'Drupal\TestTools\PhpUnitCompatibility\PhpUnit9\TestCompatibilityTrait' not found in /app/web/core/tests/Drupal/Tests/PhpunitCompatibilityTrait.php on line 11
Warning: Class 'Drupal\TestTools\PhpUnitCompatibility\PhpUnit9\TestCompatibilityTrait' not found in /app/web/core/tests/Drupal/Tests/PhpunitCompatibilityTrait.php on line 11
PHP Fatal error:  Trait 'Drupal\Tests\PhpunitVersionDependentTestCompatibilityTrait' not found in /app/web/core/tests/Drupal/Tests/PhpunitCompatibilityTrait.php on line 17
Fatal error: Trait 'Drupal\Tests\PhpunitVersionDependentTestCompatibilityTrait' not found in /app/web/core/tests/Drupal/Tests/PhpunitCompatibilityTrait.php on line 17

@piridium
Copy link

piridium commented Apr 6, 2021

Thank you! I ran into some similar warnings and errors about missing phpunit classes. After ...
composer global require phpunit/phpunit:^7
... I was able to use drupal-check.

@mglaman
Copy link
Owner

mglaman commented Jul 20, 2021

You can't require drupal/core-dev if you're using composer 2 as it'll dump a version of composer 1 into vendor/bin

This shouldn't cause an issue, though. I have various runs going against 8.9 and 9.0 Requiring drupal/core-dev seems to be fine

@mrdavidburns
Copy link

When it dumps a version of composer 1 into vendor/bin I've noticed that the site starts using Composer 1 instead of 2 which creates conflicts when composer commands run, especially if the main branch is already committed a composer.lock file built w/ Composer 2.

For me, the benefits of Composer 2 outweigh having easy access to all the packages in drupal/core-dev at least for the sites I've been working with. So I've been removing drupal/core-dev and then require --dev the packages I know I want from that directly in composer.json.

@mglaman
Copy link
Owner

mglaman commented Jul 20, 2021

That's interesting. I haven't experienced that, which is why I'm a bit confused.

So when you run Composer scripts, it's loading the local version to execute them than the globally installed one?

Is there an easy to reproduce sample so that I can make a test workflow? The tests all use v2

@davereid
Copy link

davereid commented Jul 21, 2021

https://www.drupal.org/project/drupal/issues/3128631 is the core issue at hand. When you first run composer, everything works fine and runs using Composer 2. But because drupal/core-dev requires composer/composer:^1.9.1 (see https://packagist.org/packages/drupal/core-dev#8.9.x-dev), it installs the composer binary to /vendor/bin/composer and composer prefers to use that once it's available, therefore making every subsequent composer run use Composer 1.

We had to workaround this on a Drupal 8 site by getting rid of the drupal/core-dev dependency and instead requiring each of those dependencies manually, using the same version requirements as the core-dev package specifies. But excluding the composer/composer dependency.

This was fixed in drupal/core-dev as of Drupal 9.1.

@mglaman
Copy link
Owner

mglaman commented Jul 22, 2021

🤯 @davereid thanks. I'll need to find time to try and work with this.

@mglaman mglaman added the bug Something isn't working label Jul 22, 2021
@joestewart
Copy link

Curious if those reporting the issue have vendor/bin in their PATH?

@mglaman
Copy link
Owner

mglaman commented Feb 3, 2022

No activity on this. Closing. If you have issues with drupal-check, use phpstan directly

@mglaman mglaman closed this as completed Feb 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants