Skip to content

Instantly share code, notes, and snippets.

@jamesmontalvo3
Created June 26, 2019 23:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesmontalvo3/7b18fd8df74c3388f9bf4e8bb5daf068 to your computer and use it in GitHub Desktop.
Save jamesmontalvo3/7b18fd8df74c3388f9bf4e8bb5daf068 to your computer and use it in GitHub Desktop.
Composer issue

Getting a weird error due to Composer installs right now.

[Wed Jun 26 16:16:18.364715 2019] [php7:warn] [pid 12304] [client my.ip.add.ress:46156] PHP Warning:  require(/opt/htdocs/mediawiki/vendor/composer/../jetbrains/phpstorm-stubs/PhpStormStubsMap.php): failed to open stream: No such file or directory in /opt/htdocs/mediawiki/vendor/composer/autoload_real.php on line 70, referer: https://example.com/
[Wed Jun 26 16:16:18.364896 2019] [php7:error] [pid 12304] [client my.ip.add.ress:46156] PHP Fatal error:  require(): Failed opening required '/opt/htdocs/mediawiki/vendor/composer/../jetbrains/phpstorm-stubs/PhpStormStubsMap.php' (include_path='/opt/htdocs/mediawiki/vendor/pear/console_getopt:/opt/htdocs/mediawiki/vendor/pear/mail:/opt/htdocs/mediawiki/vendor/pear/mail_mime:/opt/htdocs/mediawiki/vendor/pear/mail_mime-decode:/opt/htdocs/mediawiki/vendor/pear/net_smtp:/opt/htdocs/mediawiki/vendor/pear/net_socket:/opt/htdocs/mediawiki/vendor/pear/pear-core-minimal/src:/opt/htdocs/mediawiki/vendor/pear/pear_exception:.:/usr/share/pear:/usr/share/php') in /opt/htdocs/mediawiki/vendor/composer/autoload_real.php on line 70, referer: https://example.com/

If I remove my composer.lock file and get composer dependencies with --no-dev:

rm -f composer.lock
composer install --no-dev
sudo systemctl reload httpd  # need to do this on my system to make sure opcache gives me new files

Then I have no issues loading MW pages (e.g. no error as shown above). I can then install dev dependencies by doing:

composer install
sudo systemctl reload httpd

Note that I did not remove the lock file this time. That would have caused my MW page loads to fail whereas doing this does not. I'm assuming this is because removing the lock file would cause Composer to reevaluate the non-dev dependencies and the problem at hand is somewhere in those. By not removing the lock file Composer is purely looking at th dev dependencies and installing those.

Now when I do:

composer update
sudo systemctl reload httpd

I get the output:

> ComposerHookHandler::onPreUpdate
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
  - Updating jetbrains/phpstorm-stubs dev-master (9d01ce3 => 1b99060):  Checking out 1b9906084d
Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.
Generating optimized autoload files
> ComposerVendorHtaccessCreator::onEvent

So jetbrains/phpstorm-stubs is updated, presumably because using composer update Composer doesn't care what's in composer.lock and reevaluates the non-dev dependencies (where the problem resides).

I think this must be a problem with extensions installed via Composer and/or extensions that install their own dependencies with Composer. My composer.local.json is:

{
	"require": {
		"mediawiki/semantic-media-wiki": "3.0.0",
		"mediawiki/semantic-result-formats": "3.0.0",
		"mediawiki/semantic-compound-queries": "1.2.0",
		"mediawiki/sub-page-list": "1.5.0",
		"mediawiki/maps": "6.0.3",
		"pear/net_smtp": "1.8.0"
	},
	"extra": {
		"merge-plugin": {
			"include": [
				"extensions/SyntaxHighlight_GeSHi/composer.json",
				"extensions/Elastica/composer.json"
			]
		}
	}
}

For both SyntaxHighlight_GeSHi and Elastica I have the REL1_31 versions checked out. They both haven't changed in a year and their composer.json files specify dependencies by exact versions. Of course those dependencies' dependencies could have changed, but that's true across the board.

Running composer show --tree | grep phpstorm after each of the different composer commands outlined above doesn't show why something is driving jetbrains/phpstorm-stubs to change versions. I can't find phpstorm-stubs anywhere in https://codesearch.wmflabs.org/search/ (it was removed from MW core in 1.33, I'm on REL1_31). MW's composer.json on REL1_31 hasn't changed since early May and I've run these commands many times since then...so it's something else.

Any thoughts on how to troubleshoot this? In the mean time I'll just do --no-dev to make my wikis work, but clearly something is wrong that it's getting the wrong dependencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment