Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

b2 should respect the spec's default fallback for XDG_CONFIG_HOME #958

Closed
salim-b opened this issue Nov 21, 2023 · 4 comments
Closed

b2 should respect the spec's default fallback for XDG_CONFIG_HOME #958

salim-b opened this issue Nov 21, 2023 · 4 comments

Comments

@salim-b
Copy link
Contributor

salim-b commented Nov 21, 2023

Intro

Current docs of the b2 CLI state1:

This program caches authentication-related and other data in a local SQLite database. The location of this database is determined in the following way:

If --profile arg is provided:

  • XDG_CONFIG_HOME/b2/db-<profile>.sqlite, if XDG_CONFIG_HOME env var is set
  • ~/.b2db-{profile}.sqlite

Otherwise:

  • B2_ACCOUNT_INFO env var’s value, if set
  • ~/.b2_account_info, if it exists
  • XDG_CONFIG_HOME/b2/account_info, if XDG_CONFIG_HOME env var is set
  • ~/.b2_account_info, as default

If the directory XDG_CONFIG_HOME/b2 does not exist (and is needed), it is created.

Current source of that documentation states:

This program caches authentication-related and other data in a local SQLite database.
The location of this database is determined in the following way:
If ``--profile`` arg is provided:
* ``{XDG_CONFIG_HOME_ENV_VAR}/b2/db-<profile>.sqlite``, if ``{XDG_CONFIG_HOME_ENV_VAR}`` env var is set
* ``{B2_ACCOUNT_INFO_PROFILE_FILE}``
Otherwise:
* ``{B2_ACCOUNT_INFO_ENV_VAR}`` env var's value, if set
* ``{B2_ACCOUNT_INFO_DEFAULT_FILE}``, if it exists
* ``{XDG_CONFIG_HOME_ENV_VAR}/b2/account_info``, if ``{XDG_CONFIG_HOME_ENV_VAR}`` env var is set
* ``{B2_ACCOUNT_INFO_DEFAULT_FILE}``, as default
If the directory ``{XDG_CONFIG_HOME_ENV_VAR}/b2`` does not exist (and is needed), it is created.

Problem

The problem with the above is the fallback to ~/.b2*.

The XDG Base Directory specification demands (emphasis by me):

XDG_CONFIG_HOME defines the base directory relative to which user-specific configuration files should be stored. If $XDG_CONFIG_HOME is either not set or empty, a default equal to $HOME/.config should be used.

I think most popular Linux distributions like Ubuntu or Arch do not set the XDG_CACHE_HOME, XDG_CONFIG_HOME, XDG_DATA_HOME and XDG_STATE_HOME environment variables and expect programs to fall back to the spec's default paths.

Solution

I'd like to propose that b2 properly adheres to the XDG Base Directory specification, meaning to fall back to $HOME/.config/b2/ if XDG_CONFIG_HOME is unset.

Related: #699

Footnotes

  1. Note that the doc's Markdown formatting is partially broken, see fix Markdown formatting #957

@jsuchan-reef
Copy link
Collaborator

Hi,
thanks for the report, we'll look into it.

@mjurbanski-reef
Copy link
Contributor

resolved in b2sdk 1.28.0 and thus, b2 CLI 3.14.0

@salim-b
Copy link
Contributor Author

salim-b commented Dec 7, 2023

Thanks. I just tested b2 CLI v3.15.0 and can confirm this to be resolved.

@ppolewicz
Copy link
Collaborator

@salim-b we appreciate the test and your confirmation. Thank you.

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

No branches or pull requests

4 participants