Page MenuHomePhabricator

Composer unable to create /var/www/html/vendor when installing mediawiki-docker on Rootless Docker
Open, Needs TriagePublic

Description

I was following the instructions from
https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/core/+/master/DEVELOPERS.md#start-environment-and-install-mediawiki
(on Linux Mint 19.3, using Docker version 19.03.8, build afacb8b7f0, and docker-compose version 1.25.4, build 8d51620a).

$ docker-compose up -d
Pulling mediawiki (docker-registry.wikimedia.org/dev/stretch-php72-fpm-apache2-xdebug:0.3.0)...
0.3.0: Pulling from dev/stretch-php72-fpm-apache2-xdebug
fae6c542f7a1: Pull complete
168919ddb442: Pull complete
b231067dc468: Pull complete
57fb5bae16b5: Pull complete
1684ef30dd73: Pull complete
20045f8ca69d: Pull complete
fcd523a7bc52: Pull complete
80a739e993fb: Pull complete
d2d9ad737940: Pull complete
b3870bf0d18f: Pull complete
de094d352a6b: Pull complete
9ffc51ceacfe: Pull complete
67e04a60b3ac: Pull complete
c78226aaafd7: Pull complete
fb6f53114fce: Pull complete
cb92fcc1c404: Pull complete
64bf0ff56504: Pull complete
1910da5aef65: Pull complete
e81744403b92: Pull complete
Digest: sha256:869ead71c490e00f33ab485b4b2252859ddf0680c5e59f4343b7ab2d1b667a5a
Status: Downloaded newer image for docker-registry.wikimedia.org/dev/stretch-php72-fpm-apache2-xdebug:0.3.0
Creating mediawiki_mediawiki_1 ... done

When I open http://localhost:8080/, it shows the following page:

screenshot.png (768×1 px, 70 KB)

However, when I continued with

$ docker-compose exec mediawiki composer update

I got the following error:

Cannot create cache directory /var/www/html/cache/composer/repo/https---packagist.org/, or directory is not writable. Proceeding without cache
Cannot create cache directory /var/www/html/cache/composer/files/, or directory is not writable. Proceeding without cache
> ComposerHookHandler::onPreUpdate
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 109 installs, 0 updates, 0 removals

                                                                 
  [RuntimeException]                                             
  /var/www/html/vendor does not exist and could not be created.  
                                                                 

update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [--with-dependencies] [--with-all-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [-i|--interactive] [--root-reqs] [--] [<packages>]...

Event Timeline

@He7d3r what is in your .env and docker-compose.override.yml files?

$ cat .env 
MW_DOCKER_PORT=8080
MW_SCRIPT_PATH=/
MW_SERVER=http://localhost:8080
MEDIAWIKI_USER=Admin
MEDIAWIKI_PASSWORD=dockerpass
XDEBUG_CONFIG=''
MW_DOCKER_UID=1000
MW_DOCKER_GID=1000
$ cat docker-compose.override.yml
version: '3.7'
services:
  mediawiki:
    # On Linux, these lines ensure file ownership is set to your host user/group
    user: "${MW_DOCKER_UID}:${MW_DOCKER_GID}"

Is it possible you ran “docker-compose up” before you created those files? In any case can you delete the cache directory and vendor directory (if it exists) and then try again with the ”docker-compose exec mediawiki composer update” command?

Is it possible you ran “docker-compose up” before you created those files?

It is possible. However, even after running the following

$ docker exec -u 0 -i -t cdb774203c44 /bin/bash
root@cdb774203c44:/var/www/html# rm -rf /var/www/html/cache/
root@cdb774203c44:/var/www/html# rm -rf /var/www/html/vendor

when I exit and then run docker-compose exec mediawiki composer update, I get exactly the same RuntimeException error reported above.

I mentioned to @kostajh on IRC that I was using this Docker setup:
https://docs.docker.com/engine/security/rootless/
It is worth mentioning something about this on the DEVELOPERS.md, since with his suggestion, I got the following:

$ docker-compose down
$ rm docker-compose.override.yml
$ docker-compose exec mediawiki composer update
Do not run Composer as root/super user! See https://getcomposer.org/root for details
> ComposerHookHandler::onPreUpdate
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 109 installs, 0 updates, 0 removals
  - Installing wikimedia/composer-merge-plugin (v1.4.1): Downloading (100%)         
  - Installing cssjanus/cssjanus (v1.3.0): Downloading (100%)         
  - Installing ralouphie/getallheaders (3.0.3): Downloading (100%)         
  - Installing psr/http-message (1.0.1): Downloading (100%)         
  - Installing guzzlehttp/psr7 (1.6.1): Downloading (100%)         
  - Installing guzzlehttp/promises (v1.3.1): Downloading (100%)         
  - Installing guzzlehttp/guzzle (6.5.2): Downloading (100%)         
  - Installing oojs/oojs-ui (v0.37.1): Downloading (100%)         
  - Installing pear/pear_exception (v1.0.1): Downloading (100%)         
  - Installing pear/console_getopt (v1.4.3): Downloading (100%)         
  - Installing pear/pear-core-minimal (v1.10.10): Downloading (100%)         
  - Installing pear/mail (v1.4.1): Downloading (100%)         
  - Installing pear/mail_mime (1.10.7): Downloading (100%)         
  - Installing pear/net_socket (v1.2.2): Downloading (100%)         
  - Installing pear/net_smtp (1.9.0): Downloading (100%)         
  - Installing wikimedia/base-convert (v2.0.1): Downloading (100%)         
  - Installing wikimedia/cdb (1.4.1): Downloading (100%)         
  - Installing wikimedia/cldr-plural-rule-parser (v1.0.0): Downloading (100%)         
  - Installing wikimedia/html-formatter (1.0.2): Downloading (100%)         
  - Installing wikimedia/at-ease (v2.0.0): Downloading (100%)         
  - Installing wikimedia/ip-set (2.1.0): Downloading (100%)         
  - Installing wikimedia/less.php (v3.0.0): Downloading (100%)         
  - Installing psr/container (1.0.0): Downloading (100%)         
  - Installing wikimedia/object-factory (v2.1.0): Downloading (100%)         
  - Installing pleonasm/bloom-filter (1.0.2): Downloading (100%)         
  - Installing wikimedia/password-blacklist (v0.1.4): Downloading (100%)         
  - Installing psr/log (1.1.3): Downloading (100%)         
  - Installing wikimedia/php-session-serializer (v1.0.7): Downloading (100%)         
  - Installing wikimedia/purtle (v1.0.7): Downloading (100%)         
  - Installing wikimedia/relpath (2.1.1): Downloading (100%)         
  - Installing wikimedia/running-stat (v1.2.1): Downloading (100%)         
  - Installing wikimedia/utfnormal (v2.0.0): Downloading (100%)         
  - Installing wikimedia/wait-condition-loop (v1.0.1): Downloading (100%)         
  - Installing wikimedia/wrappedstring (v3.0.1): Downloading (100%)         
  - Installing wikimedia/timestamp (v3.0.0): Downloading (100%)         
  - Installing wikimedia/scoped-callback (v3.0.0): Downloading (100%)         
  - Installing wikimedia/xmp-reader (0.7.0): Downloading (100%)         
  - Installing zordius/lightncandy (v1.2.5): Downloading (100%)         
  - Installing doctrine/event-manager (1.1.0): Downloading (100%)         
  - Installing doctrine/cache (1.10.0): Downloading (100%)         
  - Installing doctrine/dbal (v2.9.3): Downloading (100%)         
  - Installing giorgiosironi/eris (0.10.0): Downloading (100%)         
  - Installing jakub-onderka/php-parallel-lint (v0.9.2): Downloading (100%)         
  - Installing squizlabs/php_codesniffer (3.5.3): Downloading (100%)         
  - Installing composer/spdx-licenses (1.5.2): Downloading (100%)         
  - Installing composer/semver (1.5.1): Downloading (100%)         
  - Installing mediawiki/mediawiki-codesniffer (v30.0.0): Downloading (100%)         
  - Installing symfony/service-contracts (v2.0.1): Downloading (100%)         
  - Installing symfony/polyfill-php73 (v1.15.0): Downloading (100%)         
  - Installing symfony/console (v5.0.7): Downloading (100%)         
  - Installing sabre/event (5.1.0): Downloading (100%)         
  - Installing netresearch/jsonmapper (v1.6.0): Downloading (100%)         
  - Installing microsoft/tolerant-php-parser (v0.0.18): Downloading (100%)         
  - Installing phpdocumentor/reflection-common (2.0.0): Downloading (100%)         
  - Installing webmozart/assert (1.7.0): Downloading (100%)         
  - Installing phpdocumentor/type-resolver (1.1.0): Downloading (100%)         
  - Installing phpdocumentor/reflection-docblock (5.1.0): Downloading (100%)         
  - Installing felixfbecker/advanced-json-rpc (v3.1.1): Downloading (100%)         
  - Installing composer/xdebug-handler (1.4.1): Downloading (100%)         
  - Installing phan/phan (2.4.9): Downloading (100%)         
  - Installing mediawiki/mediawiki-phan-config (0.9.2): Downloading (100%)         
  - Installing monolog/monolog (1.25.3): Downloading (100%)         
  - Installing nmred/kafka-php (v0.1.5): Downloading (100%)         
  - Installing jakub-onderka/php-console-color (v0.2): Downloading (100%)         
  - Installing jakub-onderka/php-console-highlighter (v0.4): Downloading (100%)         
  - Installing dnoegel/php-xdg-base-dir (v0.1.1): Downloading (100%)         
  - Installing nikic/php-parser (v4.3.0): Downloading (100%)         
  - Installing symfony/var-dumper (v5.0.7): Downloading (100%)         
  - Installing psy/psysh (v0.10.2): Downloading (100%)         
  - Installing seld/jsonlint (1.7.1): Downloading (100%)         
  - Installing symfony/yaml (v5.0.5): Downloading (100%)         
  - Installing wikimedia/avro (v1.9.0): Downloading (100%)         
  - Installing wikimedia/testing-access-wrapper (1.0.0): Downloading (100%)         
  - Installing wikimedia/zest-css (1.1.2): Downloading (100%)         
  - Installing wikimedia/wikipeg (2.0.4): Downloading (100%)         
  - Installing wikimedia/remex-html (2.1.0): Downloading (100%)         
  - Installing wikimedia/assert (v0.5.0): Downloading (100%)         
  - Installing wikimedia/langconv (0.3.5): Downloading (connecting...)
Downloading (100%)         
    Failed to execute unzip -qq  '/var/www/html/vendor/wikimedia/langconv/f29813e6c1649fdac9519a64108343a0' -d '/var/www/html/vendor/composer/5b23fa7d'

[/var/www/html/vendor/wikimedia/langconv/f29813e6c1649fdac9519a64108343a0]
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
unzip:  cannot find zipfile directory in one of /var/www/html/vendor/wikimedia/langconv/f29813e6c1649fdac9519a64108343a0 or
        /var/www/html/vendor/wikimedia/langconv/f29813e6c1649fdac9519a64108343a0.zip, and cannot find /var/www/html/vendor/wikimedia/langconv/f29813e6c1649fdac9519a64108343a0.ZIP, period.

    The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems)
    Unzip with unzip command failed, falling back to ZipArchive class

    Invalid zip file, retrying...
  - Installing wikimedia/langconv (0.3.5): Downloading (100%)         
  - Installing wikimedia/ip-utils (1.0.0): Downloading (100%)         
  - Installing liuggio/statsd-php-client (v1.0.18): Downloading (100%)         
  - Installing wikimedia/parsoid (v0.12.0-a9): Downloading (100%)         
  - Installing sebastian/version (2.0.1): Downloading (100%)         
  - Installing sebastian/type (1.1.3): Downloading (100%)         
  - Installing sebastian/resource-operations (2.0.1): Downloading (100%)         
  - Installing sebastian/recursion-context (3.0.0): Downloading (100%)         
  - Installing sebastian/object-reflector (1.1.1): Downloading (100%)         
  - Installing sebastian/object-enumerator (3.0.3): Downloading (100%)         
  - Installing sebastian/global-state (3.0.0): Downloading (100%)         
  - Installing sebastian/exporter (3.1.2): Downloading (100%)         
  - Installing sebastian/environment (4.2.3): Downloading (100%)         
  - Installing sebastian/diff (3.0.2): Downloading (100%)         
  - Installing sebastian/comparator (3.0.2): Downloading (100%)         
  - Installing phpunit/php-timer (2.1.2): Downloading (100%)         
  - Installing phpunit/php-text-template (1.2.1): Downloading (100%)         
  - Installing phpunit/php-file-iterator (2.0.2): Downloading (100%)         
  - Installing theseer/tokenizer (1.1.3): Downloading (100%)         
  - Installing sebastian/code-unit-reverse-lookup (1.0.1): Downloading (100%)         
  - Installing phpunit/php-token-stream (3.1.1): Downloading (100%)         
  - Installing phpunit/php-code-coverage (7.0.10): Downloading (100%)         
  - Installing doctrine/instantiator (1.3.0): Downloading (100%)         
  - Installing phpspec/prophecy (v1.10.3): Downloading (100%)         
  - Installing phar-io/version (2.0.1): Downloading (100%)         
  - Installing phar-io/manifest (1.0.3): Downloading (100%)         
  - Installing myclabs/deep-copy (1.9.5): Downloading (100%)         
  - Installing phpunit/phpunit (8.5.3): Downloading (100%)         
  - Installing johnkary/phpunit-speedtrap (v3.2.0): Downloading (100%)         
  - Installing justinrainbow/json-schema (5.2.9): Downloading (100%)         
  - Installing hamcrest/hamcrest-php (v2.0.0): Downloading (100%)         
  - Installing wmde/hamcrest-html-matchers (v0.1.1): Downloading (100%)         
guzzlehttp/psr7 suggests installing zendframework/zend-httphandlerrunner (Emit PSR-7 responses)
pear/net_smtp suggests installing pear/auth_sasl (Install optionally via your project's composer.json)
doctrine/cache suggests installing alcaeus/mongo-php-adapter (Required to use legacy MongoDB driver)
giorgiosironi/eris suggests installing icomefromthenet/reverse-regex (v0.0.6.3 for the regex() Generator)
symfony/service-contracts suggests installing symfony/service-implementation ()
symfony/console suggests installing symfony/event-dispatcher ()
symfony/console suggests installing symfony/lock ()
symfony/console suggests installing symfony/process ()
phan/phan suggests installing ext-ast (Needed for parsing ASTs (unless --use-fallback-parser is used). 1.0.1+ is needed.)
monolog/monolog suggests installing graylog2/gelf-php (Allow sending log messages to a GrayLog2 server)
monolog/monolog suggests installing sentry/sentry (Allow sending log messages to a Sentry server)
monolog/monolog suggests installing doctrine/couchdb (Allow sending log messages to a CouchDB server)
monolog/monolog suggests installing ruflin/elastica (Allow sending log messages to an Elastic Search server)
monolog/monolog suggests installing php-amqplib/php-amqplib (Allow sending log messages to an AMQP server using php-amqplib)
monolog/monolog suggests installing ext-amqp (Allow sending log messages to an AMQP server (1.0+ required))
monolog/monolog suggests installing ext-mongo (Allow sending log messages to a MongoDB server)
monolog/monolog suggests installing mongodb/mongodb (Allow sending log messages to a MongoDB server via PHP Driver)
monolog/monolog suggests installing aws/aws-sdk-php (Allow sending log messages to AWS services like DynamoDB)
monolog/monolog suggests installing rollbar/rollbar (Allow sending log messages to Rollbar)
monolog/monolog suggests installing php-console/php-console (Allow sending log messages to Google Chrome)
psy/psysh suggests installing ext-pdo-sqlite (The doc command requires SQLite to work.)
psy/psysh suggests installing hoa/console (A pure PHP readline implementation. You'll want this if your PHP install doesn't already support readline or libedit.)
sebastian/global-state suggests installing ext-uopz (*)
phpunit/phpunit suggests installing phpunit/php-invoker (^2.0.0)
phpunit/phpunit suggests installing ext-soap (*)
Package jakub-onderka/php-parallel-lint is abandoned, you should avoid using it. Use php-parallel-lint/php-parallel-lint instead.
Package jakub-onderka/php-console-color is abandoned, you should avoid using it. Use php-parallel-lint/php-console-color instead.
Package jakub-onderka/php-console-highlighter is abandoned, you should avoid using it. Use php-parallel-lint/php-console-highlighter instead.
Writing lock file
Generating optimized autoload files
> ComposerHookHandler::onPreUpdate
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
  - Updating wikimedia/parsoid (v0.12.0-a9 => v0.12.0-a10): Downloading (100%)         
Package jakub-onderka/php-console-color is abandoned, you should avoid using it. Use php-parallel-lint/php-console-color instead.
Package jakub-onderka/php-console-highlighter is abandoned, you should avoid using it. Use php-parallel-lint/php-console-highlighter instead.
Package jakub-onderka/php-parallel-lint is abandoned, you should avoid using it. Use php-parallel-lint/php-parallel-lint instead.
Writing lock file
Generating optimized autoload files
> ComposerVendorHtaccessCreator::onEvent
> ComposerVendorHtaccessCreator::onEvent

and then

$ docker-compose exec mediawiki /bin/bash /docker/install.sh
+ php maintenance/install.php --server http://localhost:8080 --scriptpath= --dbtype sqlite --dbpath /var/www/html/cache/sqlite --lang en --pass dockerpass MediaWiki admin
PHP 7.2.26-1+0~20191218.33+debian9~1.gbpb5a340+wmf1 is installed.
Found GD graphics library built-in. Image thumbnailing will be enabled if you enable uploads.
Found the Git version control software: /usr/bin/git.
Using server name "http://localhost".
Using server URL "http://localhost:8080".
Warning: Your default directory for uploads (/var/www/html/images/) is not checked for vulnerability to arbitrary script execution during the CLI install.
Using the PHP intl extension for Unicode normalization.
The environment has been checked. You can install MediaWiki.
Setting up database
done
Creating tables
done
Populating default interwiki table
done
Initializing statistics
done
Generating secret keys
done
Prevent running unneeded updates
done
Creating administrator user account
done
Creating main page with default content
done
Database was successfully set up
MediaWiki has been successfully installed. You can now visit <http://localhost:8080> to view your wiki. If you have questions, check out our frequently asked questions list: <https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ> or use one of the support forums linked on that page.

However, when I open http://localhost:8080/, it shows:

Sorry! This site is experiencing technical difficulties.
Try waiting a few minutes and reloading.

(Cannot access the database: Unknown error (localhost))

Backtrace:

#0 /var/www/html/includes/libs/rdbms/loadbalancer/LoadBalancer.php(934): Wikimedia\Rdbms\LoadBalancer->reportConnectionError()
#1 /var/www/html/includes/libs/rdbms/loadbalancer/LoadBalancer.php(901): Wikimedia\Rdbms\LoadBalancer->getServerConnection(0, 'my_wiki', 0)
#2 /var/www/html/includes/libs/rdbms/loadbalancer/LoadBalancer.php(1046): Wikimedia\Rdbms\LoadBalancer->getConnection(-1, Array, 'my_wiki', 0)
#3 /var/www/html/includes/GlobalFunctions.php(2499): Wikimedia\Rdbms\LoadBalancer->getMaintenanceConnectionRef(-1, 'api', 'my_wiki')
#4 /var/www/html/includes/cache/MessageCache.php(488): wfGetDB(-1, 'api')
#5 /var/www/html/includes/cache/MessageCache.php(443): MessageCache->loadFromDB('en', NULL)
#6 /var/www/html/includes/cache/MessageCache.php(366): MessageCache->loadFromDBWithLock('en', Array, NULL)
#7 /var/www/html/includes/cache/MessageCache.php(1086): MessageCache->load('en')
#8 /var/www/html/includes/cache/MessageCache.php(1013): MessageCache->getMsgFromNamespace('Mainpage', 'en')
#9 /var/www/html/includes/cache/MessageCache.php(983): MessageCache->getMessageForLang(Object(LanguageEn), 'mainpage', true, Array)
#10 /var/www/html/includes/cache/MessageCache.php(925): MessageCache->getMessageFromFallbackChain(Object(LanguageEn), 'mainpage', true)
#11 /var/www/html/includes/language/Message.php(1305): MessageCache->get('mainpage', true, Object(LanguageEn))
#12 /var/www/html/includes/language/Message.php(860): Message->fetchMessage()
#13 /var/www/html/includes/language/Message.php(952): Message->toString('text')
#14 /var/www/html/includes/Title.php(664): Message->text()
#15 /var/www/html/includes/MediaWiki.php(122): Title::newMainPage()
#16 /var/www/html/includes/MediaWiki.php(142): MediaWiki->parseTitle()
#17 /var/www/html/includes/MediaWiki.php(889): MediaWiki->getTitle()
#18 /var/www/html/includes/MediaWiki.php(535): MediaWiki->main()
#19 /var/www/html/index.php(47): MediaWiki->run()
#20 {main}

@He7d3r I would recommend not running Docker in the experimental mode. If you do want to continue with the experimental mode, then the UID/GID mappings probably need to be set with the values from grep ^$(whoami): /etc/subuid and grep ^$(whoami): /etc/subgid rather than id -u and id -g, at least that is what I surmise from looking at https://docs.docker.com/engine/security/rootless/#prerequisites

@He7d3r I would recommend not running Docker in the experimental mode.

I did that for now, and I was able to finish the installation, without the error I mentioned in T250072#6052324 (but I don't know what caused the error).

Krinkle renamed this task from [RuntimeException] /var/www/html/vendor does not exist and could not be created to Composer unable to create /var/www/html/vendor when installing mediawiki-dockerr.May 27 2020, 9:35 PM
Krinkle renamed this task from Composer unable to create /var/www/html/vendor when installing mediawiki-dockerr to Composer unable to create /var/www/html/vendor when installing mediawiki-docker.
Krinkle renamed this task from Composer unable to create /var/www/html/vendor when installing mediawiki-docker to Composer unable to create /var/www/html/vendor when installing mediawiki-docker on Rootless Docker.