Skip to content

Conversation

@munishchouhan
Copy link
Member

closes #973

Problem

Python's getpass.getuser() was raising OSError: No username set in the environment when running in containers built with the pixi template, but worked fine with the
micromamba template.

Root Cause

The pixi template didn't set the USER environment variable in the final container stage, while Python's getpass.getuser() function requires one of these environment
variables to be present: LOGNAME, USER, LNAME, or USERNAME.

Solution

Updated the pixi Dockerfile template (src/main/resources/templates/conda-pixi-v1/dockerfile-conda-file.txt) to match the micromamba v2 template behavior by adding:

  • USER root directive
  • ENV USER=root environment variable

This ensures Python applications can successfully call getpass.getuser() without errors.

Changes

  • Modified conda-pixi-v1/dockerfile-conda-file.txt to add USER and ENV directives
  • Updated all pixi-related tests in TemplateUtilsTest and ContainerHelperTest to reflect the new template output

Signed-off-by: munishchouhan <[email protected]>
@munishchouhan munishchouhan self-assigned this Jan 28, 2026
@munishchouhan munishchouhan marked this pull request as draft January 28, 2026 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No user in docker container when using --build-template conda/pixi:v1

2 participants