Wednesday, October 19, 2011

Re: Vim using wrong $PATH to find gcc?

On Wed, Oct 19, 2011 at 10:34 AM, Taylor Hedberg <tmhedberg@gmail.com> wrote:
> Are you sure that Vim's `system` function is using the same shell that
> you use interactively? That is, does `:set shell?` print "/bin/tcsh" (or
> wherever it's located on your system)? It could be that it's using
> /bin/sh instead, which I believe is the default if your SHELL
> environment variable is unset.
>

Yes, :set shell? prints the path to tcsh.

> Or perhaps `system('which gcc')` is executing the command in a different
> environment than the one used by your interactive shell. For instance,
> maybe the PATH variable is somehow being modified by the shell invoked
> by `system`. Probably unlikely, but not hard to check.
>

/facepalm

Yes, this was the problem.

The shell Vim invokes again sources my .cshrc file, where I had:

# $PATH ^= /opt/sfw/bin (more recent Vim versions)
# $PATH += /usr/atria/bin (clearcase paths)
setenv PATH '/opt/sfw/bin:'$PATH':/usr/atria/bin'

I've changed this to:

# $PATH ^= /opt/sfw/bin (more recent Vim versions)
if ( $PATH !~ */opt/sfw/bin* ) then
setenv PATH '/opt/sfw/bin:'$PATH
endif

# $PATH += /usr/atria/bin (clearcase paths)
if ( $PATH !~ */usr/atria/bin* ) then
setenv PATH $PATH':/usr/atria/bin'
endif

And now it works! Or at least,

:echo system('which gcc')

gives the expected result.

Thanks for the hint!

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: