Page MenuHomePhabricator

DEVELOPERS.md advice to assign $UID makes no sense in Bash
Closed, ResolvedPublic

Description

DEVELOPERS.md currently advises Linux users to “ensure that $UID and $GID are set” by placing the following commands in “your .bashrc or other shell configuration”:

export UID=$(id -u)
export GID=$(id -g)

But in Bash, $UID is a read-only variable; attempting to set it results in an error:

$ export UID=$(id -u)
-bash: UID: readonly variable

Setting $UID may be necessary in some other shells (e. g. dash), but .bashrc is not the right place to configure those.

(None of this applies to $GID, by the way, which is not special in Bash.)

Event Timeline

Hmm, I don't see that in my bash shell, I don't know why. But yes, I think we could use variable names like DOCKER_UID and DOCKER_GID instead.

Change 574723 had a related patch set uploaded (by Kosta Harlan; owner: Kosta Harlan):
[mediawiki/core@master] [docker] Adjust UID/GID variable names

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

kostajh moved this task from To Do to In Progress on the MediaWiki-Docker board.

Change 574723 merged by jenkins-bot:
[mediawiki/core@master] [docker] Adjust UID/GID variable names

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

kostajh claimed this task.
kostajh moved this task from In Progress to Done on the MediaWiki-Docker board.

Good catch.

I should have explicitly tested the .bashrc instructions. This arises from me originally having worked on the problem under zsh, a trap I should by now know better than to fall into.