Skip to content

Conversation

jgarber623
Copy link
Contributor

Description

Addresses #1031 by implementing support for XDG directories in accordance with the rules discussed in the issue and summarized in my comment here.

This change should be non-breaking in that the code continues to prefer existing default configuration files at ~/.rdbgrc and ~/.rdbg_history.

If those files do not exist and XDG environment variables are configured, then configuration and history files in the relevant XDG directories are used.

  • $XDG_CONFIG_HOME/rdbg/config (if file is present)
  • $XDG_DATA_HOME/rdbg/history

Note that $XDG_CONFIG_HOME is typically $HOME/.config and that $XDG_DATA_HOME is typically $HOME/.local/share. These are customizable by users, but I believe those are the customary/default paths.

This commit implements XDG directory support for this gem's history file
in accordance with the rules outlined in #1031:

> For the history file:
>
> 1. prefer `~/.rdbg_history` if present,
> 2. else, `$XDG_DATA_HOME/rdbg/history` if `$XDG_DATA_HOME` is set¹
>
> ¹ There'd need to be a check for this file path. If it exists, great!
> If not, create the path `$XDG_DATA_HOME/rdbg` and touch
> `$XDG_DATA_HOME/rdbg/history`.

See: #1031 (comment)
This commit implements XDG directory support for this gem's `.rdbgrc`
configuration file in accordance with the rules outlined in #1031:

> 1. prefer `~/.rdbgrc` if present,
> 2. else, `$XDG_CONFIG_HOME/rdbg/config` if `$XDG_CONFIG_HOME` is set
> and `$XDG_CONFIG_HOME/rdbg/config` is present,
> 3. else, no customized user configuration

See: #1031 (comment)
@jgarber623 jgarber623 marked this pull request as ready for review January 30, 2024 21:19
]

if (xdg_home = ENV["XDG_CONFIG_HOME"])
rc_file_paths << [File.expand_path(File.join(xdg_home, "rdbg", "config")), true]
Copy link
Collaborator

Choose a reason for hiding this comment

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

don't you need config.rb here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. This change should support both ${XDG_CONFIG_HOME}/rdbg/config and ${XDG_CONFIG_HOME}/rdbg/config.rb. I'll make that update.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ko1 Thank you again for the feedback. I've added support for config.rb in this path in 55f6624.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you!

Copy link

launchable-app bot commented Mar 29, 2024

Tests Failed

✖️no tests failed ✔️534 tests passed(146 flakes)

@jgarber623
Copy link
Contributor Author

Hello! I don't have the ability to re-run the failed checks and it's not immediately clear to me why those failed (and why Ruby 3.2 and 3.3 passed).

For someone more knowledgeable, do those failures look to be caused by changes in this pull request? Should I update this branch with a merge commit and have someone re-run the test suite?

@jgarber623 jgarber623 requested a review from ko1 June 6, 2025 01:36
@ko1
Copy link
Collaborator

ko1 commented Jun 6, 2025

Sorry for keeping you waiting for a year. I'll merge it now.

One concern is existing user doesn't have chance to know ignoring the ~/.rdbg_history, so show warning is one idea.
Moving (copying?) it when XDG directory doesn't have a history file yet, is one idea.
But it should be separate PR.

@ko1 ko1 merged commit f0579e4 into ruby:master Jun 6, 2025
25 of 32 checks passed
@ko1
Copy link
Collaborator

ko1 commented Jun 6, 2025

I recheck https://specifications.freedesktop.org/basedir-spec/latest/ and it says:

The $XDG_STATE_HOME contains state data that should persist between (application) restarts, but that is not important or portable enough to the user that it should be stored in $XDG_DATA_HOME. It may contain:

  • actions history (logs, history, recently used files, …)
  • current state of the application that can be reused on a restart (view, layout, open files, undo history, …)

Should we use $XDG_STATE_HOME/rdbg/history ?

@jgarber623

@ko1
Copy link
Collaborator

ko1 commented Jun 6, 2025

ah, mentioned here. I have no strong opinion, but not sure which is the best.
do you have reasons to choose DATA?

@jgarber623
Copy link
Contributor Author

do you have reasons to choose DATA?

@ko1 The conversation on #1031 documents how we got to using XDG_DATA_HOME for the history file. See: #1031 (comment).

I think $XDG_DATA_HOME (e.g. ~/.local/share) is the more appropriate place for history files. Similar to my note above, the XDG page on the Arch wiki cites a number of examples using $XDG_DATA_HOME for history files.

It doesn't look like there were any concerns or objections to that approach which is likely why I implemented the change that way.

@ko1
Copy link
Collaborator

ko1 commented Jun 7, 2025

okay, I'll move discussion to #1031

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.

2 participants