Vimr: `$PATH` sometimes not set correctly

Created on 26 Aug 2016  ยท  34Comments  ยท  Source: qvacua/vimr

YouCompleteMe doesn't work in VimR, it works when I run nvim in iTerm2. I think it's because I built YCM using python3 installed using pyenv and vimr use system's python.
I've found a similar closed issue before: #96, but I don't want to touch system's python. Is there a way to make VimR works with python configured in my terminal's PATH, at least when starting from vimr command line?

  • Launch NeoVimServer using the user's login shell.
bug

All 34 comments

Hmm.. I'm not sure what I did but it works when running vimr command line. Maybe my env had some problems before. I'll close this.

Unfortunately I don't know pyenv... I described in the wiki how VimR sets $PATH, maybe you can spot what's missing?

@qvacua :
:echo $PATH inVimR gives this:

  • When run VimR app directly: /usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin
  • When run VimR app via vimr command: /usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/phuna/.jenv/shims:/Users/phuna/.pyenv/shims:/Users/phuna/.rbenv/shims
    So it's just the difference of the environment I launch VimR.
    BTW, thanks a lot for adding vimr command line and fixing cursor render problem. Now I can fully replace neovim with VimR. Great works. ๐Ÿ‘

Thanks! ๐Ÿ˜€. But this issue seems to be a bug... $PATH should be set correctly, ie to the second one, also for double clicking the VimR app. The first $PATH is the default path when something went wrong executing the env ... command described in the wiki. What shell are you using?

@phuna in which file you add the "phuna" folder? ~/.bash_profile, ~/.bashrc or something else?

(see also: http://stackoverflow.com/questions/415403/whats-the-difference-between-bashrc-bash-profile-and-environment)

I'm using zsh. "phuna" folder is added by pyenv, rbenv & jenv for management of python, ruby & java installations.
Below is .zshrc content:


# Source Prezto.
if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
  source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
fi

export JAVA_HOME=$(/usr/libexec/java_home)

export PATH=/usr/local/bin:$PATH

# rbenv
eval "$(rbenv init -)"

# pyenv
eval "$(pyenv init -)"

export EDITOR=vim
export VISUAL=vim

eval "$(jenv init -)"

@qvacua : I've just tried but still the same problem, YouCompleteMe only available when launching via vimr in terminal.

Could you download http://taewon.de/TextBox.app.zip, run it and post the result?

I got 404 not found for http://taewon.de/TextBox.app.zip

Ups, a typo: http://taewon.de/TestBox.app.zip

BTW: it just prints out some of the steps VimR is doing to launch neovim.

I ran it and got this:

Got shell '/usr/local/bin/zsh'
Got url for shell path: file:///usr/local/bin/zsh
Using args '["-l", "-c", "env | grep \'^PATH=\' | sed \'s/^PATH=//\'"]'
/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin

@qvacua Can you share source code of TestBox? I can do some investigation myself.

I'll upload the source code tomorrow (it's on my other machine). In case you cannot wait: It's basically ShellUtils.pathForUserShell() with some print()s. ๐Ÿ˜€

@qvacua I think we should use login + interactive shell for launching neovim. I'm not sure for others but for me environment settings are mainly in interactive session (for zsh they're defined in .zshrc file). I've tried to changed:

[shellArgs addObject:@"-l"];

to

[shellArgs addObject:@"-il"];

and $PATH is set correctly when launching like starting vimr from command line.

Thanks! I'll try it with some other shells and add the option. ๐Ÿ˜€

@phuna Could you please try the issue/262-path branch? I tried something else...

@qvacua I tried your new version and got /usr/local/bin/zsh: bad option: -z when trying to open VimR's window and the app hang.
I tried to remove this:

[shellArgs addObject:[@"-" stringByAppendingString:shellPath.lastPathComponent]];

then VimR can start but the $PATH is still not correct.

@qvacua I've tried the latest version and it works, starting VimR from both Finder or command line can see my $PATH. Thank you for your effort to fix this :)

You're welcome and thanks for -i! :)

Since build 69 when opening VimR no window opens and the app hangs using 100 % of the cpu :(
I use zsh as my shell.
Not sure if it's useful but this is the output of the program above:

Got shell '/usr/local/bin/zsh'
Got url for shell path: file:///usr/local/bin/zsh
Using args '["-l", "-c", "env | grep \'^PATH=\' | sed \'s/^PATH=//\'"]'
/usr/local/bin:/usr/local/sbin:/Users/cHoco/Library/Haskell/bin:/usr/local/opt/go/libexec/bin:/Users/cHoco/Projects/Go/bin:/Users/cHoco/Projects/dotFiles/bin:/Users/cHoco/Projects/kwm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin

Does the newest snapshot also do this?

Yes, since snapshot 69. I think the issue is that I by launching the shell as interactive (-i option) zsh also loads the content of .zshrc which for me includes additional processing stuff dedicated to an interactive shell, like tmux integration etc... VimR shouldn't launch the shell in interactive mode, and users with path issues should move their path customisation in the .zprofile file.

I'll add an option to Preferences -> Advanced -> Checkbox: Use -i flag for zsh.

Try the build 77. The -i flag is turned off by default. You can turn it on in "Preferences -> Advanced" though, @phuna .

Working good here! thank you @qvacua :D

Work great here too @qvacua , thank you :)

Is it possible that the option for the -i flag is broken in the current build? When I activate it and restart VimR, the option is unchecked again.

@pitkling I cannot reproduce your issue with the latest snapshot. Which version are you using?

I'm on 0.26.9 (312). I played around a bit and I got the following behavior:

  • open VimR, got to Preferences (CMD + ,), go to the "Advanced" tab, change the zsh option, quit VimR (CMD + q) โ†’ change in the zsh option is not saved
  • open VimR, got to Preferences (CMD + ,), go to the "Advanced" tab, change the zsh option, close the preferences window (CMD + w), quit VimR (CMD + q) โ†’ change in the zsh option is not saved
  • open VimR, got to Preferences (CMD + ,), go to the "Advanced" tab, change the zsh option, close the preferences window (CMD + w), close the automatically opened editor window (CMD + w), quit VimR (CMD + q) โ†’ change in the zsh option is saved

I did a similar test with the "Use Ligatures" option under "Appearance", which is saved correctly in all three cases above.

This appears to still be an issue in a very specific set of cases: only when launching the application using Mac OS's Spotlight launcher and Alfred. If I open the app directly from the Applications folder or from the command line it picks up $PATH perfectly fine.

I'm setting $PATH in .zshenv, and I do not have the use interactive mode for zsh option enabled in vimr.

Experiencing the same behavior described by @willdavidow

Screen Shot 2020-01-29 at 1 15 36 PM

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tjdoc picture tjdoc  ยท  6Comments

selaselah picture selaselah  ยท  7Comments

0ax1 picture 0ax1  ยท  8Comments

laur1s picture laur1s  ยท  5Comments

orip picture orip  ยท  5Comments