checkhealth: allow 'sudo install' of 'Neovim::Ext' #11874

cpanm cannot look for Perl modules from root directories
without sudo so it creates '~/perl5/' and look for Perl modules in there.
Whether this directory existed before running cpanm or not,
cpanm returns a warning to advice the user to setup local::lib
in order to use modules in '~/perl5/' and exits with error code 0.
Each line in the warning always starts with '!'.

Display this warning to the user.
Continue parsing the version number if the warning can be ignored
because lines that are not prefixed with '!' are valid output.

Fix #11858
This commit is contained in:
Jan Edmund Lazo 2020-02-15 19:02:52 -05:00 committed by GitHub
parent dc0e534a91
commit a1d6c2f5c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 1 deletions

View File

@ -710,13 +710,27 @@ function! s:check_perl() abort
let latest_cpan_cmd = 'cpanm --info -q Neovim::Ext'
let latest_cpan = s:system(latest_cpan_cmd)
if s:shell_error || empty(latest_cpan) || latest_cpan[0] ==# '!'
if s:shell_error || empty(latest_cpan)
call health#report_error('Failed to run: '. latest_cpan_cmd,
\ ["Make sure you're connected to the internet.",
\ 'Are you behind a firewall or proxy?'])
return
elseif latest_cpan[0] ==# '!'
let cpanm_errs = split(latest_cpan, '!')
if cpanm_errs[0] =~# "Can't write to "
call health#report_warn(cpanm_errs[0], cpanm_errs[1:-2])
" Last line is the package info
let latest_cpan = cpanm_errs[-1]
else
call health#report_error('Unknown warning from command: ' . latest_cpan_cmd, cpanm_errs)
return
endif
endif
let latest_cpan = matchstr(latest_cpan, '\(\.\?\d\)\+')
if empty(latest_cpan)
call health#report_error('Cannot parse version number from cpanm output: ' . latest_cpan)
return
endif
let current_cpan_cmd = [host, '-W', '-MNeovim::Ext', '-e', 'print $Neovim::Ext::VERSION']
let current_cpan = s:system(current_cpan_cmd)