Page MenuHomePhabricator

MediaWiki-Vagrant does not install bluebird package
Closed, ResolvedPublic

Description

Bluebird is mwbot dependency, introduced in 417848.

Reproducible in MediaWiki-Vagrant:

user@machine:/mediawiki/vagrant$ vagrant ssh

vagrant@vagrant:~$ node -v
v6.13.1

vagrant@vagrant:~$ npm -v
2.15.12

vagrant@vagrant:~$ cd /vagrant/mediawiki

vagrant@vagrant:/vagrant/mediawiki$ rm -rf node_modules/

vagrant@vagrant:/vagrant/mediawiki$ npm install
...

vagrant@vagrant:/vagrant/mediawiki$ xvfb-run npm run selenium
...
[chrome #0-0] Spec: /vagrant/mediawiki/tests/selenium/specs/page.js
[chrome #0-0] Running: chrome
[chrome #0-0]
[chrome #0-0]   Page
[chrome #0-0]
[chrome #0-0]   Page
[chrome #0-0]       ✓ should be creatable
[chrome #0-0]       1) should be re-creatable
[chrome #0-0]       2) should have history
[chrome #0-0]
[chrome #0-0]
[chrome #0-0] 1 passing (12s)
[chrome #0-0] 5 failing
[chrome #0-0]
[chrome #0-0] 1) Page should be re-creatable:
[chrome #0-0] Cannot find module 'bluebird'
...
Warning: Task "webdriver:test" failed. Use --force to continue.
Aborted due to warnings.

Not reproducible on my desktop machine, probably because it has a newer npm version:

$ node -v
v9.9.0

$ npm -v
5.8.0

$ rm -rf node_modules/

$ npm install
...

$ npm run selenium
...
(no errors)

Event Timeline

zeljkofilipin renamed this task from Cannot find module 'bluebird' to Cannot find module 'bluebird'.Mar 28 2018, 10:16 AM
zeljkofilipin renamed this task from Cannot find module 'bluebird' to MediaWiki-Vagrant does not install bluebird package.
zeljkofilipin updated the task description. (Show Details)

Change 422385 had a related patch set uploaded (by Zfilipin; owner: Zfilipin):
[mediawiki/core@master] Selenium: install bluebird, mwbot dependency

https://gerrit.wikimedia.org/r/422385

Change 422385 merged by jenkins-bot:
[mediawiki/core@master] Selenium: install bluebird, mwbot dependency

https://gerrit.wikimedia.org/r/422385

zeljkofilipin awarded a token.
zeljkofilipin rescinded a token.
zeljkofilipin awarded a token.

@zeljkofilipin For future reference, mwbot's dependency was not missing. Bluebird was installed. If it wasn't, npm would be very badly broken and the test would've failed much earlier.

The problem was that our own code was using it directly, and we didn't specify a dependency.

Node sometimes exposes a module's dependencies wider than strictly needed as a way to optimise and reduce depth of the dependency tree. But this is purely an optimisation and not something to rely on.

Upstream could trivially switch out Bluebird for another Promise library, or for a newer or older version that isn't compatible with what we do in our own code. If and when that happens, package.json will make sure that our code still has the dependencies and versions we need.

And yes, that means sometimes we run with the same library installed multiple times (different versions). This may feel strange a first, but is a feature enabled by Node.js resolving node_modules to the first match, starting in the current directory, moving upwards. This is stable and documented behaviour, used and relied on by many packages :)