2

Is it possible to configure vi to use a different location, say my home directory, for the uncompressed help files (or maybe to open them in RO if that's the problem)?

When attempting to open a help document from within vi I get the following error:

"quickref.txt.gz" [readonly][noeol] 94L, 21071C
Error detected while processing function gzip#read:
line   41:
E484: Can't open file /tmp/vcl6GTZ/7
Press ENTER or type command to continue
Error detected while processing function gzip#read:
line   44:
Error: Could not read uncompressed file
Press ENTER or type command to continue
E434: Can't find tag pattern
Press ENTER or type command to continue

This happens when pressing CTRL+] over quickref from help.txt (:help):

enter image description here

Instead, the raw, uncompressed help.txt.gz file is opened and displayed:

enter image description here

I was told by the company hosting this server that I don't have access to tmp (though I can ls it's contents).


Update (11/15/2019)

After adding $TMPDIR to env with export TMPDIR=~/tmp I now get the following error (same error, different location). Maybe the underlying issue is with the "tag pattern" not being found, which occurs irrespective of the temp path's location:

"quickref.txt.gz" [readonly][noeol] 94L, 21071C
Error detected while processing function gzip#read:
line   41:
E484: Can't open file /home1/<username>/tmp/vNQn0ab/3
Press ENTER or type command to continue
Error detected while processing function gzip#read:
line   44:
Error: Could not read uncompressed file
Press ENTER or type command to continue
E434: Can't find tag pattern
Press ENTER or type command to continue
  • The tag pattern issue appears to occur because the file cant be opened. I dont believe thats the root issue – D. Ben Knoble Nov 16 at 14:35
  • 1
    Anything cleaning up your temp directory? – Christian Brabandt Nov 17 at 16:29
2

I've done some digging. (tpope's scriptease makes this really easy.)

plugin/gzip.vim reveals that most of the functionality is autoloaded.

autoload/gzip.vim reveals that the temporary paths are constructed using tempname().

tempname() reveals that *tempfile* has the appropriate help:

Vim uses temporary files for filtering, generating diffs and also for
tempname().  For Unix, the file will be in a private directory (only
accessible by the current user) to avoid security problems (e.g., a symlink
attack or other people reading your file).  When Vim exits the directory and
all files in it are deleted.  When Vim has the setuid bit set this may cause
problems, the temp file is owned by the setuid user but the filter command
probably runs as the original user.
On MS-DOS and OS/2 the first of these directories that works is used: $TMP,
$TEMP, c:\TMP, c:\TEMP.
For Unix the list of directories is: $TMPDIR, /tmp, current-dir, $HOME.
For MS-Windows the GetTempFileName() system function is used.
For other systems the tmpnam() library function is used.

So, at least on *nix systems, you should be able to set the TMPDIR environment variable.

Note that other programs may use this variable too, so you may want to only set it for vim:

" vimrc or other
let $TMPDIR = ...

But any :terms you start will inherit this (I'm not sure if it is exported, though, so I am not sure if other programs running from a shell could see it. printenv sees it, at least.)

  • Thanks for all the advice. I now get the same error from the new location (updated OP)? – samis Nov 15 at 20:44
  • @samis did you mkdir ~/tmp? It could also be an issue where the help files arent present (eg its the tiny version vim without help) – D. Ben Knoble Nov 15 at 21:01
  • ~/tmp exists, and the compressed help files do exits and are opened in the raw, uncompressed gz format as indicated above (quickref.txt.gz is opened in RO). – samis Nov 15 at 21:38
  • @samis im not sure then tbh – D. Ben Knoble Nov 15 at 21:47
1

Yes, it is possible to override the location where the temporary decompressed files are stored.

On Unix-like platforms (including Linux or Mac OS), you can do so by setting the $TMPDIR environment variable, which you can either do from your vimrc file, or from your .bashrc or similar.

Assuming you create a ~/tmp directory:

$ mkdir ~/tmp

Then you can use the following in your vimrc:

let $TMPDIR = expand('~/tmp')

Or define the environment variable in your .bashrc or similar:

export TMPDIR=~/tmp

(Exporting it in your shell is probably better, since there are other tools that depend on a writable temporary directory and that might the same variable setting, so they'd benefit from this configuration too.)

For more details, see :help tempfile on how Vim will look for a temporary directory and how it varies per platform.

You might also want to check :help tempname(), which is the Vimscript function used by the gzip.vim module to find a temporary directory. And :help expand() which was mentioned above.

  • Thanks for all the advice. I now get the same error from the new location (updated OP)? – samis Nov 15 at 20:44
  • That's odd... Did you create the ~/tmp directory using mkdir first? Is your home actually in /home1 like the message says? – filbranden Nov 15 at 20:57
  • ~/tmp exits, and according to pwd the path does start in /home1 – samis Nov 15 at 21:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.