cli icon indicating copy to clipboard operation
cli copied to clipboard

[FEATURE] Support for XDG Base Directory Specification in Doppler

Open HuaDeity opened this issue 9 months ago • 8 comments

Is your feature request related to a problem? Please describe. I'm often frustrated when applications like Doppler store configuration, data, or cache files in non-standard locations within my home directory, cluttering it with hidden files and folders. This makes it harder to manage my user-specific data and configurations, especially on Linux systems where the XDG Base Directory Specification provides a standardized way to organize such files. Currently, Doppler does not respect the XDG Base Directory Specification, which leads to inconsistency with other modern applications that follow this standard.

Describe the solution you'd like I would like Doppler to support the XDG Base Directory Specification by storing its files in the appropriate directories as defined by the relevant environment variables.If these environment variables are not set or are empty, Doppler should fall back to the default paths as outlined in the XDG Base Directory Specification. This would ensure consistency with other applications and reduce clutter in the user's home directory.

Describe alternatives you've considered One alternative is to provide a configuration option for users to manually specify storage paths, but this places the burden on the user to maintain consistency and does not inherently solve the problem of standardization. Supporting XDG by default, with an optional override for custom paths, would be the most user-friendly and standards-compliant approach.

Additional context The XDG Base Directory Specification is a widely accepted standard on Linux and other Unix-like systems for organizing user-specific files. It helps maintain a clean home directory by defining standard locations for configuration, data, cache, state, and runtime files through environment variables like $XDG_CONFIG_HOME, $XDG_DATA_HOME, and others. Many modern applications and tools adhere to this specification, and supporting it in Doppler would improve interoperability and user experience on these platforms.

HuaDeity avatar Apr 26 '25 13:04 HuaDeity

Thanks for writing in about this, @HuaDeity! The DOPPLER_CONFIG_DIR environment variable can be used to specify the config directory where the Doppler CLI reads and writes config/state files. However, you're absolutely right that this pushes the burden on the user.

I'll share this feedback with the product team.

nmanoogian avatar Apr 28 '25 17:04 nmanoogian

@nmanoogian

Thanks for the information! I wasn't aware of the DOPPLER_CONFIG_DIR environment variable, but it's a great starting point. I'll use it for my configuration.

Also, it's a good strategy to check if XDG_CONFIG_HOME is set and use that directory directly. That's a great implementation.

HuaDeity avatar Apr 29 '25 07:04 HuaDeity

@nmanoogian

Seems that DOPPLER_CONFIG_DIR still have some issues, and it cannot be used for now.

If I am using doppler secrets download --no-file --format=json, and it will shows the error

Doppler Error: mkdir /Users/username/.doppler/fallback: no such file or directory

Seems that there still have some hardcode directory that doppler using.

HuaDeity avatar Apr 29 '25 13:04 HuaDeity

@HuaDeity Hmm, I'm not reproducing that behavior. Can you share the exact vars and commands that you're running? This is what I'm running in an ubuntu container:

root@1bf3b2800020:/# mkdir -p /home/user/.local/state/doppler
root@1bf3b2800020:/# export DOPPLER_CONFIG_DIR="/home/user/.local/state/doppler"
root@1bf3b2800020:/# doppler login
Using DOPPLER_CONFIG_DIR from the environment. To disable this, use --no-read-env.
? Open the authorization page in your browser? Yes
[REDACTED AUTH CODE]
Waiting...
Welcome, Nic
root@1bf3b2800020:/# doppler setup
Using DOPPLER_CONFIG_DIR from the environment. To disable this, use --no-read-env.
? Select a project: backend
? Select a config: dev
┌─────────┬─────────┬───────┐
│ NAME    │ VALUE   │ SCOPE │
├─────────┼─────────┼───────┤
│ config  │ dev     │ /     │
│ project │ backend │ /     │
└─────────┴─────────┴───────┘
root@1bf3b2800020:/# doppler secrets download --no-file --format=json
Using DOPPLER_CONFIG_DIR from the environment. To disable this, use --no-read-env.
{[REDACTED SECRETS]}

nmanoogian avatar Apr 29 '25 13:04 nmanoogian

@nmanoogian

Test on my own macOS, remote Linux server and Linux virtual machine. All have the same problem.

You must still have the .doppler directory in your home. Delete it, and you can see the error.

HuaDeity avatar Apr 29 '25 15:04 HuaDeity

Ah, I see! The configuration is correctly being saved in the DOPPLER_CONFIG_DIR but the metadata and encrypted fallback files are still being saved in the default ~/.doppler dir. This should be a fairly simple fix 👍

nmanoogian avatar Apr 29 '25 20:04 nmanoogian

@HuaDeity, https://github.com/DopplerHQ/cli/pull/487 fixes the issue with the metadata and encrypted fallback files not respecting the DOPPLER_CONFIG_DIR environment variable. I'll leave this issue open though to track the request that we use XDG base dirs by default -- I still need to think through some of the backward compatibility considerations

nmanoogian avatar May 29 '25 14:05 nmanoogian

Hi @nmanoogian,

Thank you for the quick fix. The fix is much appreciated, and I understand the need to consider backward compatibility when implementing the XDG base directory specification by default.

Let me know if there’s anything I can do to assist with testing or providing additional feedback during this process.

Thanks for your support!

HuaDeity avatar Jun 06 '25 07:06 HuaDeity