directory icon indicating copy to clipboard operation
directory copied to clipboard

The XdgDirectory datatype doesn't provide a way to query $XDG_RUNTIME_DIR

Open merijn opened this issue 5 years ago • 6 comments

I'm not entirely sure how we'd properly integrate this in the existing API, as (unlike the other Xdg directories) XDG_RUNTIME_DIR doesn't have a default value. On the other hand, it's quite a hassle to reimplement getXdgDirectory myself just for RUNTIME_DIR

merijn avatar Apr 11 '19 12:04 merijn

Would calling lookupEnv "XDG_RUNTIME_DIR" suffice?

Is there any benefit from having this in directory?

Rufflewind avatar Apr 12 '19 08:04 Rufflewind

Feel free to comment if there's still a concern. Thanks!

Rufflewind avatar May 30 '19 19:05 Rufflewind

I guess this could be interesting to have a portable function returning $XDG_RUNTIME_DIR on unixes and something else on windows.

legrostdg avatar Apr 20 '20 17:04 legrostdg

I'm not happy with the wontfix resolution of this issue. The XDG spec has quite a bit of stuff around XDG_RUNTIME_DIR. It would be great if directory had code to do all of this checks.

$XDG_RUNTIME_DIR defines the base directory relative to which user-specific non-essential runtime files and other file objects (such as sockets, named pipes, ...) should be stored. The directory MUST be owned by the user, and he MUST be the only one having read and write access to it. Its Unix access mode MUST be 0700.

If $XDG_RUNTIME_DIR is not set applications should fall back to a replacement directory with similar capabilities and print a warning message. Applications should use this directory for communication and synchronization purposes and should not place larger files in it, since it might reside in runtime memory and cannot necessarily be swapped out to disk.

phadej avatar May 09 '21 09:05 phadej

code to do all of this checks.

The program is not required to verify those.

My read of the spec is that those are requirements that the program can assume about the system configuration. In other words, it is the user / admin / distro who has the onus of ensuring that the directory has the correct permissions etc. The program isn't obliged to verify any of them, and for the average program there isn't necessarily anything actionable if these requirements aren't met, other than maybe printing a warning.

There is no canonical replacement directory for XDG_RUNTIME_DIR that I'm aware of either, so the fallback will probably vary depending on the program at hand.


More generally, I am wondering whether directory is the right place to handle all the features of XDG (vs delegating to a non-boot package). Bear in mind that main reason XDG was introduced to directory was to offer a more compliant replacement for getAppUserDataDirectory. Would supporting the full XDG spec be stretching the scope too much? How would one extend the semantics of XDG to Windows platforms?

Rufflewind avatar Jun 06 '21 23:06 Rufflewind

I guess this could be interesting to have a portable function returning $XDG_RUNTIME_DIR on unixes and something else on windows.

The closest I can think of is Win32.getTemporaryDirectory. If that works for your use case maybe that could be used as a substitute, although it hardly meets any of the requirements in the XDG specification.

Rufflewind avatar Sep 08 '22 01:09 Rufflewind

Closing for reasons discussed in https://github.com/haskell/directory/issues/93#issuecomment-855482568.

Rufflewind avatar Jul 12 '24 08:07 Rufflewind