Skip to content

Conversation

@Rahix
Copy link

@Rahix Rahix commented Jan 14, 2022

Hi,

I got curious how difficult it would be to move the neovim temporary files beneath $XDG_RUNTIME_DIR and it turned out to be quite simple. At least that's what it looks like - please let me know if I missed anything.

The XDG Base Directory Specification suggests to store "runtime files" below $XDG_RUNTIME_DIR when this environment variable is set. Currently, neovim defaults to using a directory below $TMPDIR or /tmp. This change makes the XDG_RUNTIME_DIR the preferred place for the temporary directory, but keeps fallback to the other locations when this environment variable is not set.

I see this topic was brought up before in #3517. I think this PR would resolve that issue, but I have not dug through the entire history of it to be certain...

The XDG Base Directory Specification [1] suggests to store runtime files
below $XDG_RUNTIME_DIR when this environment variable is set. Currently,
neovim defaults to using a directory below $TMPDIR or /tmp. Make the
XDG_RUNTIME_DIR the preferred place for the temporary directory, but
fall back to the other locations when this environment variable is not
set.

[1]: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
Ref: neovim#3517
@jamessan
Copy link
Member

One concern I'd have about this is the following part of the spec:

Files in this directory MAY be subjected to periodic clean-up. To ensure that your files are not removed, they should have their access time timestamp modified at least once every 6 hours of monotonic time or the 'sticky' bit should be set on the file.

@jamessan
Copy link
Member

It might also be a good idea to add support for stdpath('runtime').

@Rahix
Copy link
Author

Rahix commented Jan 18, 2022

One concern I'd have about this is the following part of the spec:

Files in this directory MAY be subjected to periodic clean-up. To ensure that your files are not removed, they should have their access time timestamp modified at least once every 6 hours of monotonic time or the 'sticky' bit should be set on the file.

I was also reading this, but it seems nobody else cares about this at all: systemd, gnome, wayland, pulseaudio/pipewire all do not update the atime appropriately nor is the sticky bit set. I also did not find any indication of such a cleanup procedure to be implemented on my system. So I think it is safe to ignore this for now.

It might also be a good idea to add support for stdpath('runtime').

I agree, but I think this should be a separate change.

justinmk added a commit to justinmk/neovim that referenced this pull request Jun 17, 2022
Problem:
Not easy to inspect Nvim-created temp files (for debugging etc).

Solution:
Try to create /tmp/nvim/ first, then create the random dir in there.

Related: neovim#3517
Related: neovim#17093
@justinmk
Copy link
Member

I've merged #8519 which changes Nvim to store sockets in XDG_STATE_DIR, but I like the idea in this PR too.

Can we manage our own /tmp/nvim/... dir without security risks? #18993

justinmk added a commit to justinmk/neovim that referenced this pull request Jun 19, 2022
Problem:
- Sockets are created in ~/.local/… but this is questionable because...
- Not easy to inspect Nvim-created temp files (for debugging etc).

Solution:
- Introduce stdpath('runtime'), and store sockets there.
- Establish "/tmp/nvim.user/" as the root of all Nvim temp dirs.

closes neovim#3517
related neovim#17093
justinmk added a commit to justinmk/neovim that referenced this pull request Jun 19, 2022
Problem:
- Sockets are created in ~/.local/… but this is questionable because...
- Not easy to inspect Nvim-created temp files (for debugging etc).

Solution:
- Introduce stdpath('runtime'), and store sockets there.
- Establish "/tmp/nvim.user/" as the root of all Nvim temp dirs.

closes neovim#3517
related neovim#17093
justinmk added a commit to justinmk/neovim that referenced this pull request Jun 19, 2022
Problem:
- Sockets are created in ~/.local/… but this is questionable because...
- Not easy to inspect Nvim-created temp files (for debugging etc).

Solution:
- Introduce stdpath('runtime'), and store sockets there.
- Establish "/tmp/nvim.user/" as the root of all Nvim temp dirs.

closes neovim#3517
related neovim#17093
justinmk added a commit to justinmk/neovim that referenced this pull request Jun 20, 2022
Problem:
- Sockets are created in ~/.local/… but this is questionable because...
- Not easy to inspect Nvim-created temp files (for debugging etc).

Solution:
- Introduce stdpath('runtime'), and store sockets there.
- Establish "/tmp/nvim.user/" as the root of all Nvim temp dirs.

closes neovim#3517
closes neovim#17093
justinmk added a commit to justinmk/neovim that referenced this pull request Jun 20, 2022
Problem:
- Sockets are created in ~/.local/… but this is questionable because...
- Not easy to inspect Nvim-created temp files (for debugging etc).

Solution:
- Introduce stdpath('runtime'), and store sockets there.
- Establish "/tmp/nvim.user/" as the root of all Nvim temp dirs.

closes neovim#3517
closes neovim#17093
justinmk added a commit to justinmk/neovim that referenced this pull request Jun 20, 2022
Problem:
- Sockets are created in ~/.local/… but this is questionable because...
- Not easy to inspect Nvim-created temp files (for debugging etc).

Solution:
- Introduce stdpath('runtime'), and store sockets there.
- Establish "/tmp/nvim.user/" as the root of all Nvim temp dirs.

closes neovim#3517
closes neovim#17093
justinmk added a commit to justinmk/neovim that referenced this pull request Jun 20, 2022
Problem:
- Sockets are created in ~/.local/… but this is questionable because...
- Not easy to inspect Nvim-created temp files (for debugging etc).

Solution:
- Introduce stdpath('runtime'), and store sockets there.
- Establish "/tmp/nvim.user/" as the root of all Nvim temp dirs.

closes neovim#3517
closes neovim#17093
justinmk added a commit to justinmk/neovim that referenced this pull request Jun 20, 2022
Problem:
- Sockets are created in ~/.local/… but this is questionable because...
- Not easy to inspect Nvim-created temp files (for debugging etc).

Solution:
- Introduce stdpath('runtime'), and store sockets there.
- Establish "/tmp/nvim.user/" as the root of all Nvim temp dirs.

closes neovim#3517
closes neovim#17093
justinmk added a commit to justinmk/neovim that referenced this pull request Jun 20, 2022
Problem:
- Sockets are created in ~/.local/… but this is questionable because...
- Not easy to inspect Nvim-created temp files (for debugging etc).

Solution:
- Introduce stdpath('runtime'), and store sockets there.
- Establish "/tmp/nvim.user/" as the root of all Nvim temp dirs.

closes neovim#3517
closes neovim#17093
justinmk added a commit to justinmk/neovim that referenced this pull request Jun 20, 2022
Problem:
- Sockets are created in ~/.local/… but this is questionable because...
- Not easy to inspect Nvim-created temp files (for debugging etc).

Solution:
- Introduce stdpath('runtime'), and store sockets there.
- Establish "/tmp/nvim.user/" as the root of all Nvim temp dirs.

closes neovim#3517
closes neovim#17093
justinmk added a commit to justinmk/neovim that referenced this pull request Jun 20, 2022
Problem:
- Sockets are created in ~/.local/… but this is questionable because...
- Not easy to inspect Nvim-created temp files (for debugging etc).

Solution:
- Introduce stdpath('runtime'), and store sockets there.
- Establish "/tmp/nvim.user/" as the root of all Nvim temp dirs.

closes neovim#3517
closes neovim#17093
justinmk added a commit to justinmk/neovim that referenced this pull request Jun 20, 2022
Problem:
- Since c57f6b2 neovim#8519, sockets are created in ~/.local/… but XDG
  spec says: "XDG_RUNTIME_DIR: Must be on the local filesystem", which
  implies that XDG_STATE_DIR is potentially non-local.
- Not easy to inspect Nvim-created temp files (for debugging etc).

Solution:
- Introduce stdpath('runtime'), and store sockets there.
- Establish "/tmp/nvim.user/" as the root of all Nvim temp dirs.

closes neovim#3517
closes neovim#17093
justinmk added a commit to justinmk/neovim that referenced this pull request Jun 29, 2022
Problem:
- Since c57f6b2 neovim#8519, sockets are created in ~/.local/… but XDG
  spec says: "XDG_RUNTIME_DIR: Must be on the local filesystem", which
  implies that XDG_STATE_DIR is potentially non-local.
- Not easy to inspect Nvim-created temp files (for debugging etc).

Solution:
- Introduce stdpath('runtime'), and store sockets there.
- Establish "/tmp/nvim.user/" as the root of all Nvim temp dirs.
- Make ok() actually useful.
- Introduce assert_nolog().

closes neovim#3517
closes neovim#17093
justinmk added a commit to justinmk/neovim that referenced this pull request Jun 29, 2022
Problem:
- Since c57f6b2 neovim#8519, sockets are created in ~/.local/… but XDG
  spec says: "XDG_RUNTIME_DIR: Must be on the local filesystem", which
  implies that XDG_STATE_DIR is potentially non-local.
- Not easy to inspect Nvim-created temp files (for debugging etc).

Solution:
- Introduce stdpath('runtime'), and store sockets there.
- Establish "/tmp/nvim.user/" as the root of all Nvim temp dirs.
- Make ok() actually useful.
- Introduce assert_nolog().

closes neovim#3517
closes neovim#17093
justinmk added a commit to justinmk/neovim that referenced this pull request Jun 29, 2022
Problem:
- Since c57f6b2 neovim#8519, sockets are created in ~/.local/… but XDG
  spec says: "XDG_RUNTIME_DIR: Must be on the local filesystem", which
  implies that XDG_STATE_DIR is potentially non-local.
- Not easy to inspect Nvim-created temp files (for debugging etc).

Solution:
- Introduce stdpath('runtime'), and store sockets there.
- Establish "/tmp/nvim.user/" as the root of all Nvim temp dirs.
- Make ok() actually useful.
- Introduce assert_nolog().

closes neovim#3517
closes neovim#17093
justinmk added a commit to justinmk/neovim that referenced this pull request Jun 29, 2022
Problem:
- Since c57f6b2 neovim#8519, sockets are created in ~/.local/… but XDG
  spec says: "XDG_RUNTIME_DIR: Must be on the local filesystem", which
  implies that XDG_STATE_DIR is potentially non-local.
- Not easy to inspect Nvim-created temp files (for debugging etc).

Solution:
- Introduce stdpath('runtime'), and store sockets there.
- Establish "/tmp/nvim.user/" as the root of all Nvim temp dirs.
- Make ok() actually useful.
- Introduce assert_nolog().

closes neovim#3517
closes neovim#17093
justinmk added a commit to justinmk/neovim that referenced this pull request Jun 29, 2022
Problem:
- Since c57f6b2 neovim#8519, sockets are created in ~/.local/… but XDG
  spec says: "XDG_RUNTIME_DIR: Must be on the local filesystem", which
  implies that XDG_STATE_DIR is potentially non-local.
- Not easy to inspect Nvim-created temp files (for debugging etc).

Solution:
- Introduce stdpath('runtime'), and store sockets there.
- Establish "/tmp/nvim.user/" as the root of all Nvim temp dirs.
- Make ok() actually useful.
- Introduce assert_nolog().

closes neovim#3517
closes neovim#17093
justinmk added a commit to justinmk/neovim that referenced this pull request Jun 29, 2022
Problem:
- Since c57f6b2 neovim#8519, sockets are created in ~/.local/… but XDG
  spec says: "XDG_RUNTIME_DIR: Must be on the local filesystem", which
  implies that XDG_STATE_DIR is potentially non-local.
- Not easy to inspect Nvim-created temp files (for debugging etc).

Solution:
- Introduce stdpath('runtime'), and store sockets there.
- Establish "/tmp/nvim.user/" as the root of all Nvim temp dirs.
- Make ok() actually useful.
- Introduce assert_nolog().

closes neovim#3517
closes neovim#17093
justinmk added a commit to justinmk/neovim that referenced this pull request Jun 30, 2022
Problem:
- Since c57f6b2 neovim#8519, sockets are created in ~/.local/… but XDG
  spec says: "XDG_RUNTIME_DIR: Must be on the local filesystem", which
  implies that XDG_STATE_DIR is potentially non-local.
- Not easy to inspect Nvim-created temp files (for debugging etc).

Solution:
- Introduce stdpath('runtime'), and store sockets there.
- Establish "/tmp/nvim.user/" as the root of all Nvim temp dirs.
- Make ok() actually useful.
- Introduce assert_nolog().

closes neovim#3517
closes neovim#17093
justinmk added a commit to justinmk/neovim that referenced this pull request Jun 30, 2022
Problem:
- Since c57f6b2 neovim#8519, sockets are created in ~/.local/… but XDG
  spec says: "XDG_RUNTIME_DIR: Must be on the local filesystem", which
  implies that XDG_STATE_DIR is potentially non-local.
- Not easy to inspect Nvim-created temp files (for debugging etc).

Solution:
- Introduce stdpath('run') ($XDG_RUNTIME_DIR), store sockets there.
- Establish "/tmp/nvim.user/" as the tempdir root shared by all Nvims.
- Make ok() actually useful.
- Introduce assert_nolog().

closes neovim#3517
closes neovim#17093
justinmk added a commit to justinmk/neovim that referenced this pull request Jun 30, 2022
Problem:
- Since c57f6b2 neovim#8519, sockets are created in ~/.local/… but XDG
  spec says: "XDG_RUNTIME_DIR: Must be on the local filesystem", which
  implies that XDG_STATE_DIR is potentially non-local.
- Not easy to inspect Nvim-created temp files (for debugging etc).

Solution:
- Introduce stdpath('run') ($XDG_RUNTIME_DIR), store sockets there.
- Establish "/tmp/nvim.user/" as the tempdir root shared by all Nvims.
- Make ok() actually useful.
- Introduce assert_nolog().

closes neovim#3517
closes neovim#17093
justinmk added a commit that referenced this pull request Jun 30, 2022
Problem:
- Since c57f6b2 #8519, sockets are created in ~/.local/… but XDG
  spec says: "XDG_RUNTIME_DIR: Must be on the local filesystem", which
  implies that XDG_STATE_DIR is potentially non-local.
- Not easy to inspect Nvim-created temp files (for debugging etc).

Solution:
- Store sockets in stdpath('run') ($XDG_RUNTIME_DIR).
- Establish "/tmp/nvim.user/" as the tempdir root shared by all Nvims.
- Make ok() actually useful.
- Introduce assert_nolog().

closes #3517
closes #17093
kraftwerk28 pushed a commit to kraftwerk28/neovim that referenced this pull request Jul 6, 2022
Problem:
- Since c57f6b2 neovim#8519, sockets are created in ~/.local/… but XDG
  spec says: "XDG_RUNTIME_DIR: Must be on the local filesystem", which
  implies that XDG_STATE_DIR is potentially non-local.
- Not easy to inspect Nvim-created temp files (for debugging etc).

Solution:
- Store sockets in stdpath('run') ($XDG_RUNTIME_DIR).
- Establish "/tmp/nvim.user/" as the tempdir root shared by all Nvims.
- Make ok() actually useful.
- Introduce assert_nolog().

closes neovim#3517
closes neovim#17093
smjonas pushed a commit to smjonas/neovim that referenced this pull request Dec 31, 2022
Problem:
- Since c57f6b2 neovim#8519, sockets are created in ~/.local/… but XDG
  spec says: "XDG_RUNTIME_DIR: Must be on the local filesystem", which
  implies that XDG_STATE_DIR is potentially non-local.
- Not easy to inspect Nvim-created temp files (for debugging etc).

Solution:
- Store sockets in stdpath('run') ($XDG_RUNTIME_DIR).
- Establish "/tmp/nvim.user/" as the tempdir root shared by all Nvims.
- Make ok() actually useful.
- Introduce assert_nolog().

closes neovim#3517
closes neovim#17093
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

Successfully merging this pull request may close these issues.

3 participants