platformio-core icon indicating copy to clipboard operation
platformio-core copied to clipboard

Use XDG_CONFIG_HOME for .platformio directory

Open microbug opened this issue 6 years ago • 6 comments

Temporary solution

You can override default location of .platformio folder using core_dir configuration option.

It is also possible to override the .platformio directory with the PLATFORMIO_CORE_DIR environment variable.


Configuration

Operating system: macOS 10.14

PlatformIO Version (platformio --version): 4.0.1b3

Description of problem

The ~/.platformio directory contains important config data including the user's custom boards. It's currently one of many hidden directories in my home folder. For most Unix-based systems these directories conventionally go in $XDG_CONFIG_HOME, which is usually ~/.local/share. This makes things neater for the user.

On Windows and macOS the variables XDG_CONFIG_HOME usually aren't defined, so you can use C:\Users\x\AppData\Roaming and ~/.local/share respectively (i.e., ~/.local/share does exist on macOS but isn't usually defined as XDG_CONFIG_HOME).

Steps to Reproduce

  1. Run pio init
  2. Observe new .platformio directory in $HOME

microbug avatar Aug 05 '19 16:08 microbug

$XDG_CONFIG_HOME is usually ~/.config while $XDG_DATA_HOME is ~/.local/share.

peterhoeg avatar Aug 08 '19 05:08 peterhoeg

Yes, we keep the same location through all systems. You can override it with http://docs.platformio.org/en/latest/envvars.html#envvar-PLATFORMIO_CORE_DIR

ivankravets avatar Aug 17 '19 20:08 ivankravets

I think that allowing the user to override PIO's defaults is besides the point; that's a whole lot of directories which a user is forced to remap. The goal of the XDG Base Directory Specification is to free the user from the burden of having to manually manage each piece of software as a unique snowflake directory tree dumped somewhere random in their $HOME directory.

For example, what subdirectories of ~/.platformio are configuration which needs to be backed up and can be synced between development machines? What directories possibly contain credentials which should never be backed up? Which are runtime data which is necessary to have on hand? Which are cache directories and can safely be discarded if disk space is low? The XDG spec is a way to avoid the user having to figure out the answers to those questions for each piece of software we install. If PIO respected the preferences I've already expressed (and shouldn't have to say differently for every program I install), I'd know that ~/.config/platformio/* is configuration that I should back up, ~/.cache/platformio is safe to delete and can be recreated as needed, etc.

Please reconsider opening this issue. Complying with the XDG spec brings a lot of benefits and loses nothing. It's trivial to remain backwards compatible to support existing installations.

lhanson avatar Oct 21 '19 20:10 lhanson

any update?

felixsanz avatar Jun 09 '20 00:06 felixsanz

See a temporary solution located in the top comment.

ivankravets avatar Mar 31 '22 20:03 ivankravets