rappdirs icon indicating copy to clipboard operation
rappdirs copied to clipboard

user_data_dir: Consistency of ~ vs expanded version

Open daattali opened this issue 3 years ago • 2 comments

When I run "user_data_dir("test")` on my Windows 10 machine:

C:\\User\\Dean\\AppData\\Local\\test\\test

On my MacOS 10.15 Catalina:

"/Users/dean/Library/Application Support/test"

Both of those use expanded paths for home dir.

But in the readme and in a report by a user of a package of mine, the path on Mac (which I assume was a different version) seems to be

"~/Library/Application Support/test"

There are two issues here:

  1. Consistency across OSes - it would be ideal if the function would always return the expanded version so that the end user knows what to expect
  2. More importantly, consistency within an OS - it seems not great that two different Macs produce different results

daattali avatar Mar 31 '21 15:03 daattali

On linux I get

rappdirs::user_cache_dir()
## "~/.cache"

rappdirs::user_data_dir()
##[1] "~/.local/share"

I've been caught out by the relative tilde thing, with downstream software not expanding it (in this particular case the software created the dir in the working directory, like "./~/.cache" .

Would a PR for the full, normalized path be welcome?

mdsumner avatar Apr 20 '23 15:04 mdsumner

Maybe. There is value in returning a user-independent path, e.g. you can use it in a system profile. OTOH, I don't expect many people to do that, so yeah, maybe.

gaborcsardi avatar Apr 20 '23 16:04 gaborcsardi