Perl-Support: Improved setup to work with Perlbrew
glasswalk3r opened this issue · 9 comments
This is actually a suggestion for improvement.
While using Perlbrew, it would be much better to have the following code in the .vimrc:
" Enable perlbrew path
if has("gui_running") && filereadable($HOME . "/perl5/perlbrew/etc/bashrc")
let $PATH=system("source " . $HOME . "/perl5/perlbrew/etc/bashrc; echo -n PATH")
endif
This will allow the plugin to identify the correct version of perl as defined by the Perlbrew configuration and, of course, correct identify issues and a syntax check is carried, since different Perlbrew instances may have different Perl modules installed.
Although this configuration solves the issue regarding the Perl interpreter and @INC
configuration, when I used the \rs (check syntax) command I always got something that is missing in the current @INC
, for example:
ListEvtLogLvl.pm|3| Can't locate Moose.pm in @INC (@INC contains: /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 .)
ListEvtLogLvl.pm|3| BEGIN failed--compilation aborted
Since I'm using Perl 5.16, this configuration is wrong. I doubled checked the @INC
configuration with this in the .vimrc:
if has("gui_running") && filereadable($HOME . "/perl5/perlbrew/etc/bashrc")
let $PATH=system("source " . $HOME . "/perl5/perlbrew/etc/bashrc; echo -n $PATH")
let $test=system("perl -E 'foreach(@INC) { say $_ }'")
echo $test
endif
And the dialog box showed the correct configuration.
Reviewing the perl-support.vim plugin, I found that the Perl interpreter path being used in hard coded to "/usr/bin/perl" but that does not help with Perlbrew. I added the following (line number included):
162 let s:Perl_Perl = system("/usr/bin/which perl")
163 let s:Perl_Perl = substitute(s:Perl_Perl, '\n$', '', '')
And it seems to be working correctly now when checking syntax,
You can actually set the Perl executable in your .vimrc using "g:Perl_Perl", see:
:help perlsupport-perl6
For some reason that help is not available:
E149: Sorry, no help for perlsupport-perl6
I tried on a CentOS 7, with Vim 7.4.160.
The help topic should still be there. But I renamed the setting to g:Perl_Executable
.
Try using the map \hp
or the menu entry Perl -> Help -> help (Perl-Support)
, it will generate the helptags for Perl-Support if they are not available.
This still works:
let g:Perl_Executable = 'perl'
ubuntu 17.10
vim 8
perlbrew
perl 5.26
This is the default as of version 5.4.1, 132828c : let g:Perl_Executable = 'perl'
Hopefully this will resolve the perlbrew problems and always use the version you use in the shell, by actually choosing the correct executable from $PATH
.
Tried that on Ubuntu 18.04, latest release of perl-support.
Setting let g:Perl_Executable = 'perl'
on ~/.vimrc
works as expected, including for properly locating modules on custom @INC
, but not for Gvim: even after repeating the configuration on ~/.gvimrc, the "selected" perl with Perlbrew doesn't work.
Double checked by running !perl -v
on [G]Vim command mode, and on Gvim the standard perl that comes with Ubuntu is used.
OK, good debugging there. Unfortunatly it seems like the problem is not with Perl-Support itself, so it's harder for me to help you. Perl-Support depends on being able to run !perl -v
correctly.
Could you compare the output of Vim vs. gVim when you run this on the Vim command line: :echo $PATH
Does it make a difference if you start gVim from a terminal or the desktop (using the Unity-App-Search-And-Starter-Thingy, whatever that's called)?
Sorry for taking so long to answer.
Yes, it does make a difference. I tested calling from the Desktop, it doesn't work but if I open gVim from the terminal, it does work as expected.
Tested on CentOS 7.