Page MenuHomePhabricator

npm warns about unwritable $HOME/.config
Closed, ResolvedPublic

Description

When testing CI Dockerfiles locally, most npm command start or ends with:

┌──────────────────────────────────────────────────────────┐
│                 npm update check failed                  │
│           Try running with sudo or get access            │
│           to the local update config store via           │
│ sudo chown -R $USER:$(id -gn $USER) /nonexistent/.config │
└──────────────────────────────────────────────────────────┘

This comes from a package called update-notifier (source) which npm-cli uses to check once a day (at most) whether a new npm version is available.

This check is automatically skipped by npm if it detects that it is in a CI environment (source, issue), which is triggered by an environment variable like CI=true, or one of several popular CI runners (including Jenkins, and Travis; docs).

However, our CI envs aren't part of the Dockerfile, and so the update check is tried, and then fails.

Now, the npm cache logic (which uses $HOME/.npm by default, which we had to override in our images via NPM_CONFIG_cache) does not support XDG base dirs.

But.. the update notification system does support it. It checks XDG_CONFIG_HOME home before falling back to $HOME/.config. Unfortunately, while we set XDG_CACHE_HOME, we do not set XDG_CONFIG_HOME.

This is a request to set that missing XDG environment in our images, so that things like this don't break anymore.

And for npm specifically, we should also set NPM_CONFIG_update_notifier=false.

Event Timeline

Change 482527 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[integration/config@master] Fix nyc and npm-update bugs due to unwritable HOME

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

Change 482527 merged by jenkins-bot:
[integration/config@master] Fix nyc and npm-update bugs due to unwritable HOME

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

Krinkle triaged this task as Medium priority.
Krinkle added a project: Performance-Team.

Change 485336 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[integration/config@master] Update node10 jobs to latest dockerfile version

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

Change 485336 merged by jenkins-bot:
[integration/config@master] Update node10 jobs to latest dockerfile version

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