Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perl-Support: Improved setup to work with Perlbrew #11

Open
glasswalk3r opened this issue Mar 31, 2014 · 9 comments
Open

Perl-Support: Improved setup to work with Perlbrew #11

glasswalk3r opened this issue Mar 31, 2014 · 9 comments
Assignees

Comments

@glasswalk3r
Copy link

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.

@WolfgangMehner WolfgangMehner changed the title Improvement for Perl support to work with Perlbrew setup Perl-Support: Improved setup to work with Perlbrew Jun 13, 2014
@glasswalk3r
Copy link
Author

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,

@WolfgangMehner
Copy link
Owner

You can actually set the Perl executable in your .vimrc using "g:Perl_Perl", see:

:help perlsupport-perl6

@glasswalk3r
Copy link
Author

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.

@WolfgangMehner
Copy link
Owner

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.

@g-i-o-r-g-i-o
Copy link

This still works:
let g:Perl_Executable = 'perl'

ubuntu 17.10
vim 8
perlbrew
perl 5.26

@WolfgangMehner
Copy link
Owner

WolfgangMehner commented Jun 15, 2019

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.

@glasswalk3r
Copy link
Author

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.

@WolfgangMehner
Copy link
Owner

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)?

@glasswalk3r
Copy link
Author

glasswalk3r commented Feb 25, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants