containers / containers/toolbox
Handling Env for Headless Dev / with user session | Support inference of XDG_RUNTIME_DIR
- Dominant language
- Go
- Stars
- 3.5k
- Forks
- 262
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 1
Description
**Describe the bug**
**Steps how to reproduce the behaviour**
Env for Headless Dev / with user session
The **creation** of the container fails
```
[root@tbx ~]# useradd test
[root@tbx ~]# passwd test
[root@tbx ~]# loginctl enable-linger $(id -u test)
[root@tbx ~]# su - test
[test@tbx ~]$ toolbox create --distro fedora -r 39
Image required to create toolbox container.
Download registry.fedoraproject.org/fedora-toolbox:39 (500MB)? [y/N]: y
Error: failed to create container fedora-toolbox-39
[test@tbx ~]$ echo $?
1
```
**Expected behaviour**
A container in `$ podman ps -a`
**Actual behaviour**
Empty `$ podman ps -a` output.
**Output of `toolbox --version` (v0.0.90+)**
`toolbox version 0.0.99.4`
**Toolbx package info (`rpm -q toolbox`)**
`toolbox-0.0.99.4-6.el9_3.x86_64`
**Additional context**
The user manager (systemd session) is spawned for the user at boot but the XDG_RUNTIME_DIR is not set.
```
[test@tbx ~]$ printenv |grep ^XDG_R || echo "No env"
No env
```
albeit
```
[test@tbx ~]$ test -S /run/user/$(id -u)/bus && echo "Socket available"
Socket available
```
Should toolbx infer the environment var (via socket availability)?
The empty XDG_RUNTIME_DIR is the cause for the failed creation of the container. When setting it the process runs ...
```
[test@tbx ~]$ export XDG_RUNTIME_DIR=/run/user/$(id -u "${USER}")
[test@tbx ~]$ toolbox create --distro fedora -r 39
Created container: fedora-toolbox-39
Enter with: toolbox enter fedora-toolbox-39
[test@tbx ~]$ echo $?
0
```
Contributor guide
Research direction
Run `toolbox create --distro fedora -r 39` as a user whose systemd session has no XDG_RUNTIME_DIR, then inspect the container-creation path. The fix is complete when creation succeeds and a container appears in `podman ps -a` without manually exporting the variable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, linux
- Domain
- cli, operating-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100