Skip to content

Get the config directory from $XDG_CONFIG_HOME if it is set - #1769

Merged
debarshiray merged 1 commit into
containers:mainfrom
ymcx:respect-xdg-config-home
Jun 4, 2026
Merged

debarshiray merged 1 commit into
containers:mainfrom
ymcx:respect-xdg-config-home

Conversation

@ymcx

@ymcx ymcx commented Mar 13, 2026

Copy link
Copy Markdown

Closes #1766

If the $XDG_CONFIG_HOME environment variable is set, we should use it instead of always falling back to $HOME/.config

@ymcx
ymcx requested a review from debarshiray as a code owner March 13, 2026 19:58
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the toolbox configuration handling by adopting the XDG Base Directory Specification. It ensures that the toolbox configuration directory is determined by the $XDG_CONFIG_HOME environment variable when present, providing better adherence to Linux desktop standards and improved user customization for configuration file locations.

Highlights

  • XDG Base Directory Specification Compliance: The toolbox configuration directory now respects the $XDG_CONFIG_HOME environment variable, falling back to $HOME/.config/toolbox if it is not set.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • profile.d/toolbox.sh
    • Updated the logic to determine the toolbox_config path.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly implements support for the $XDG_CONFIG_HOME environment variable for locating the toolbox configuration directory. My review includes a suggestion to refactor the shell command for setting the configuration path to be more idiomatic and robust by using parameter expansion. This improves code clarity and maintainability.

Comment thread profile.d/toolbox.sh Resolved

@debarshiray debarshiray left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this, @ymcx and my apologies for the delay! The overall code changes look good to me.

Could you please use your real name and email address in the Git commit message, and squash both the commits together (because they are one single logical change)?

@ymcx

ymcx commented Jun 3, 2026

Copy link
Copy Markdown
Author

my apologies for the delay!

No worries.

Could you please use your real name and email address in the Git commit message

Which email address do you want me to use? Do I need to use the real address that is linked to this account, or will any address work that can be used to contact me?

@debarshiray

debarshiray commented Jun 3, 2026 •

Copy link
Copy Markdown
Member

Could you please use your real name and email address in the Git commit message

Which email address do you want me to use? Do I need to use the real address that is linked to this account, or will any address work that can be used to contact me?

The real name and email address requirement is for tracking copyright holders in case a licensing issue crops up. So, any email address that can be used to contact you is enough. :)

Also, note, for the sake of completeness:

The Signed-off-by trailer, if it's used, has no meaning without a real full name and email address.

Projects as diverse as GCC, GnuPG, Linux, Moby and Podman don't allow anonymous or pseudonymous contributions.

@ymcx
ymcx force-pushed the respect-xdg-config-home branch from 0f5e62a to f999655 Compare June 4, 2026 16:53
@ymcx

ymcx commented Jun 4, 2026

Copy link
Copy Markdown
Author

Will this work? I don't think I can sign the commit with this email address.

... don't allow anonymous or pseudonymous contributions

Thanks for the explanation! I tried looking for the related guidelines but didn't find them elsewhere.

@ymcx
ymcx requested a review from debarshiray June 4, 2026 16:57
@debarshiray
debarshiray force-pushed the respect-xdg-config-home branch from f999655 to b324146 Compare June 4, 2026 19:38

@debarshiray debarshiray left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates, @ymcx ! If it's a valid email address that can be used to contact you, then it's fine. :)

I took the liberty to rebase against main and added a link to the XDG Base Directory specification for future reference.

The changes seem to work well in my testing. Let's merge once the CI finishes.

@debarshiray

debarshiray commented Jun 4, 2026 •

Copy link
Copy Markdown
Member

Unrelated to the main goal of this pull request, but somewhat related, two things came to my notice.

First, there are some instances of "$HOME/.config" in test/system/libs/helpers.bash. I am wondering if those should be replaced by XDG_CONFIG_HOME.

It would be a cosmetic change because XDG_CONFIG_HOME is set to "$HOME/.config" at the top of the file (see commit 4251a0409ffcb913). Maybe it has some consistency benefits?

Second, we need to migrate away from ~/.config/toolbox to ~/.config/toolbx.

@ymcx does any of those interest you? :)

@debarshiray

Copy link
Copy Markdown
Member

Build failed. https://gateway-cloud-softwarefactory.apps.ocp.cloud.ci.centos.org/zuul/t/local/buildset/b8d5ff1dc15f4175b0f2d152978c7c62

❌ system-test-fedora-rawhide-commands-options TIMED_OUT in 2h 00m 33s
❌ system-test-fedora-44-commands-options TIMED_OUT in 1h 45m 33s

These are odd:

fedora-rawhide | 1..239
fedora-rawhide | # test suite: Set up
RUN END RESULT_TIMED_OUT: [untrusted : github.com/containers/toolbox/playbooks/system-test-commands-options.yaml@main]
POST-RUN START: [trusted : softwarefactory-project.io/config/playbooks/base/post.yaml@master]

... and we started seeing them recently in #1798

I am going to take a leap of faith and ignore this failure on the assumption that it's something to do with the Software Factory infrastructure, because everything was fine a week ago and nothing relevant to these tests changed since then.

@debarshiray
debarshiray merged commit b324146 into containers:main Jun 4, 2026
2 of 3 checks passed
@debarshiray

Copy link
Copy Markdown
Member

Thank you for your contribution!

First, there are some instances of "$HOME/.config" in test/system/libs/helpers.bash. I am wondering if those should be replaced by XDG_CONFIG_HOME.

It would be a cosmetic change because XDG_CONFIG_HOME is set to "$HOME/.config" at the top of the file (see commit 4251a0409ffcb913). Maybe it has some consistency benefits?

Second, we need to migrate away from ~/.config/toolbox to ~/.config/toolbx.

@ymcx does any of those interest you? :)

Let me know. :)

@debarshiray debarshiray mentioned this pull request Jun 8, 2026
@ymcx

ymcx commented Jun 11, 2026

Copy link
Copy Markdown
Author

Unrelated to the main goal of this pull request, but somewhat related, two things came to my notice.

First, there are some instances of "$HOME/.config" in test/system/libs/helpers.bash. I am wondering if those should be replaced by XDG_CONFIG_HOME.

It would be a cosmetic change because XDG_CONFIG_HOME is set to "$HOME/.config" at the top of the file (see commit 4251a0409ffcb913). Maybe it has some consistency benefits?

Second, we need to migrate away from ~/.config/toolbox to ~/.config/toolbx.

@ymcx does any of those interest you? :)

Sorry, I've been quite busy lately. I'll look at both perhaps during the weekend or before if I have the time.

@ymcx

ymcx commented Jun 14, 2026

Copy link
Copy Markdown
Author

Alright so I tried implementing both of your suggestions. The first one was easy, but I didn't feel like submitting a PR for a change so small. Here's the patch anyway:

diff --git a/test/system/libs/helpers.bash b/test/system/libs/helpers.bash
index 4b48c70..7d0ca25 100644
--- a/test/system/libs/helpers.bash
+++ b/test/system/libs/helpers.bash
@@ -166,9 +166,9 @@ function _setup_docker_registry() {
   assert_success
 
   # Add certificate to Podman's trusted certificates (rootless)
-  run mkdir -p "$HOME"/.config/containers/certs.d/"${DOCKER_REG_URI}"
+  run mkdir -p "$XDG_CONFIG_HOME"/containers/certs.d/"${DOCKER_REG_URI}"
   assert_success
-  run cp "${DOCKER_REG_CERTS_DIR}"/domain.crt "$HOME"/.config/containers/certs.d/"${DOCKER_REG_URI}"/domain.crt
+  run cp "${DOCKER_REG_CERTS_DIR}"/domain.crt "$XDG_CONFIG_HOME"/containers/certs.d/"${DOCKER_REG_URI}"/domain.crt
   assert_success
 
   # Create a registry user
@@ -234,7 +234,7 @@ function _clean_docker_registry() {
   # Remove Docker registry dir
   rm --force --recursive "${DOCKER_REG_ROOT}"
   # Remove dir with created registry certificates
-  rm --force --recursive "$HOME"/.config/containers/certs.d/"${DOCKER_REG_URI}"
+  rm --force --recursive "$XDG_CONFIG_HOME"/containers/certs.d/"${DOCKER_REG_URI}"
 }

As for the second suggestion, I tried changing the config directory from $XDG_CONFIG_HOME/toolbox to $XDG_CONFIG_HOME/toolbx, but I was unable to make the migration work correctly.

After having created a container using the distro's version of Toolbx and then switching to the one with these patches applied, it wouldn't let me start the container and it would instead create the old directory along with migrating to the new directory. I'm not totally sure why that is. Here's the related patch:

diff --git a/profile.d/toolbox.sh b/profile.d/toolbox.sh
index 020d6e8..eca7dd1 100644
--- a/profile.d/toolbox.sh
+++ b/profile.d/toolbox.sh
@@ -4,7 +4,14 @@
 [ "${BASH_VERSION:-}" != "" ] || [ "${ZSH_VERSION:-}" != "" ] || return 0
 [ "$PS1" != "" ] || return 0
 
-toolbox_config="${XDG_CONFIG_HOME:-$HOME/.config}/toolbox"
+root_config="${XDG_CONFIG_HOME:-$HOME/.config}"
+toolbox_config="$root_config/toolbx"
+toolbox_config_old="$root_config/toolbox"
+
+if [[ -d "$toolbox_config_old" && ! -e "$toolbox_config" ]]; then
+    mv "$toolbox_config_old" "$toolbox_config"
+fi
+
 host_welcome_stub="$toolbox_config/host-welcome-shown"
 toolbox_welcome_stub="$toolbox_config/toolbox-welcome-shown"

We already have a commit that lists some of the changes needed in order to finish the rename of the project (c3403dae8cb0544e), but I couldn't find any issue opened for tracking the progress. Should I open an issue for this?

So all in all, I'm not sure I'm willing to continue working on either of the highlighted suggestions. This is unless I'm able to fix the aforementioned issue such that the migration would be seamless for existing Toolbx users.

@debarshiray

Copy link
Copy Markdown
Member

Sorry, I've been quite busy lately. I'll look at both perhaps during the weekend or before if I have the time.

No need to apologize. I was pre-occupied myself because of two conferences - DevConf.cz and Flock.

Alright so I tried implementing both of your suggestions. The first one was easy, but I didn't feel like submitting a PR for a change so small. Here's the patch anyway:

diff --git a/test/system/libs/helpers.bash b/test/system/libs/helpers.bash
index 4b48c70..7d0ca25 100644
--- a/test/system/libs/helpers.bash
+++ b/test/system/libs/helpers.bash
@@ -166,9 +166,9 @@ function _setup_docker_registry() {
   assert_success
 
   # Add certificate to Podman's trusted certificates (rootless)
-  run mkdir -p "$HOME"/.config/containers/certs.d/"${DOCKER_REG_URI}"
+  run mkdir -p "$XDG_CONFIG_HOME"/containers/certs.d/"${DOCKER_REG_URI}"
   assert_success
-  run cp "${DOCKER_REG_CERTS_DIR}"/domain.crt "$HOME"/.config/containers/certs.d/"${DOCKER_REG_URI}"/domain.crt
+  run cp "${DOCKER_REG_CERTS_DIR}"/domain.crt "$XDG_CONFIG_HOME"/containers/certs.d/"${DOCKER_REG_URI}"/domain.crt
   assert_success
 
   # Create a registry user
@@ -234,7 +234,7 @@ function _clean_docker_registry() {
   # Remove Docker registry dir
   rm --force --recursive "${DOCKER_REG_ROOT}"
   # Remove dir with created registry certificates
-  rm --force --recursive "$HOME"/.config/containers/certs.d/"${DOCKER_REG_URI}"
+  rm --force --recursive "$XDG_CONFIG_HOME"/containers/certs.d/"${DOCKER_REG_URI}"
 }

It looks good to me at a quick glance!

No change is too small for a pull request. If nothing else, we get to have the tests run on it. So, please feel free to submit a PR. :)

If you are too busy and don't have time for it, then I will commit it myself and attribute it to Tino Saarenpää <[email protected]>. Is that alright?

debarshiray pushed a commit to debarshiray/toolbox that referenced this pull request Jul 3, 2026
For some reason, calls to 'skopeo copy' to populate the local temporary
Docker registry are sometimes hanging indefinitely.  Everything was fine
on the 28th of May [1].  The problem started with Fedora Rawhide on the
30th of May [2], and spread to Fedora 44 on the 4th of June [3].

Avoid the indefinite hangs and make skopeo(1) fail sooner by using
reasonable timeouts - longer for remote network I/O and shorter for
local.

[1] containers#1799

[2] containers#1798

[3] containers#1769

containers#1811
containers#1815

Signed-off-by: Rolv Apneseth <[email protected]>
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.

Use XDG_CONFIG_HOME when creating welcome stubs in profile.d/toolbox.sh

2 participants