:checkhealth : validate 'runtimepath' (#7526)

This commit is contained in:
Justin M. Keyes 2017-11-10 22:37:54 +01:00 committed by GitHub
parent 314ff440f7
commit f5d4da0144
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 8 deletions

View File

@ -23,11 +23,11 @@ Commands *health-commands*
*:checkhealth* *:CheckHealth*
:checkhealth Run all healthchecks.
*E5009*
Nvim depends on the |$VIMRUNTIME| environment variable
to find the standard "runtime files" for syntax
highlighting, filetype-specific behavior, and standard
plugins such as :checkhealth. If $VIMRUNTIME is invalid
then those features will not work.
Nvim depends on |$VIMRUNTIME| and 'runtimepath' to find
the standard "runtime files" for syntax highlighting,
filetype-specific behavior, and standard plugins
(including :checkhealth). If the runtime files cannot
be found then those features will not work.
:checkhealth {plugins}
Run healthcheck(s) for one or more plugins. E.g. to run

View File

@ -22883,11 +22883,15 @@ void ex_checkhealth(exarg_T *eap)
const char *vimruntime_env = os_getenv("VIMRUNTIME");
if (vimruntime_env == NULL) {
EMSG(_("E5009: $VIMRUNTIME is empty or unset"));
return;
} else {
EMSG2(_("E5009: Invalid $VIMRUNTIME: %s"), os_getenv("VIMRUNTIME"));
return;
bool rtp_ok = NULL != strstr((char *)p_rtp, vimruntime_env);
if (rtp_ok) {
EMSG2(_("E5009: Invalid $VIMRUNTIME: %s"), vimruntime_env);
} else {
EMSG(_("E5009: Invalid 'runtimepath'"));
}
}
return;
}
size_t bufsize = STRLEN(eap->arg) + sizeof("call health#check('')");

View File

@ -16,6 +16,13 @@ describe(':checkhealth', function()
eq(false, status)
eq('Invalid $VIMRUNTIME: bogus', string.match(err, 'Invalid.*'))
end)
it("detects invalid 'runtimepath'", function()
clear()
command('set runtimepath=bogus')
local status, err = pcall(command, 'checkhealth')
eq(false, status)
eq("Invalid 'runtimepath'", string.match(err, 'Invalid.*'))
end)
it("detects invalid $VIM", function()
clear()
-- Do this after startup, otherwise it just breaks $VIMRUNTIME.