Alter $Path in Vim/Macvim So as to Find the Right Ruby Binary

Alter $PATH in vim/macvim so as to find the right ruby binary

I don't know if it applies to zsh but depending on how it's started, bash reads some files and not others. Having this line in my ~/.vimrc ensures that $PATH is the same in Vim and in my shell.

set shell=bash\ -i

But it depends on how you start/customize your shell.

See :help 'shell' and zsh's manual.

$PATH in vim is different from which in shell? (Mac OSX)

Unfortunately, MacVim won't be affected by paths you set in .profile or .bashrc.

You can set paths affecting all programs on Mac OS X by using the /etc/paths and /etc/paths.d/ mechanisms. More detailed explanation here:

https://serverfault.com/questions/16355/how-to-set-global-path-on-os-x

brew installed Vim in Terminal with RVM (Ruby 1.9.3), MacVim and Command-T

I'm guessing that you installed the macvim package before you installed installed all the rest of that, and then installed the vim package afterwards. That'd explain why it works in terminal mode. These are two different packages, and they have their own build options.

Run:

vim --version

And compare the output to:

mvim --version

In particular, check out the last line (starts with Linking:). You'll probably see ruby-1.8 linked in for mvim, and ruby-1.9.1 linked in for vim (note that 1.9.3 reports 1.9.1; it's the C API version, not the Ruby version).

If all this is true, fix it by doing:

brew uninstall macvim
brew install macvim

It should build against your 1.9.3 config. Make sure rvm current reports 1.9.3 before you do that.

Changing the global “path” from within a function?

You could call functions as with usual command executions like this (without ()):

prepend_to_path_if_exists "$HOME/bin"

It seems that zsh try to expand the glob prepend_to_path_if_exists(…) rather than to call the function.


TL;DR: Prepending emelemnts to $path would be accomplished by a little cryptic way:

(I'm not quite sure that the below form is preferable for anyone though.)

# `typeset -U` uniqify the elements of array.
# It could be good for $path.
typeset -U path

# prepending some paths unconditionally,
path[1,0]=(\
$HOME/bin \
$HOME/sbin \
)

# then filtering out unnecessary entries afterward.
path=(${^path}(-/N))

The $path[x,0]=… is prepending(splicing) element(s) to array taken from the below:

So that's the same as VAR[1,0]=(...) ? It doesn't really "look" very
much like prepend to me.

-- Greg Klanderman (http://www.zsh.org/mla/workers/2013/msg00031.html)

The ${^path}(-/N) expands the glob qualifires -/N on the each $path elements.
(Without ^ in the parameter expansion, the last elements of array will be evaluated, so it is mandatory in this case.)

The glob qualifires -/N means that "symbolic links and the files they point to"(-) the "directory"(/). And when it does not match anything do not raise errors (N).

In short, it would keep exsisting directories only for $path.

Update built-in vim on Mac OS X

If I understand things correctly, you want to install over your existing Vim, for better or worse :-) This is a bad idea and it is not the "clean" way to do it. Why? Well, OS X expects that nothing will ever change in /usr/bin unbeknownst to it, so any time you overwrite stuff in there you risk breaking some intricate interdependency. And, Let's say you do break something -- there's no way to "undo" that damage. You will be sad and alone. You may have to reinstall OS X.

Part 1: A better idea

The "clean" way is to install in a separate place, and make the new binary higher priority in the $PATH. Here is how I recommend doing that:

$ # Create the directories you need
$ sudo mkdir -p /opt/local/bin
$ # Download, compile, and install the latest Vim
$ cd ~
$ hg clone https://bitbucket.org/vim-mirror/vim or git clone https://github.com/vim/vim.git
$
$ cd vim
$ ./configure --prefix=/opt/local
$ make
$ sudo make install
$ # Add the binary to your path, ahead of /usr/bin
$ echo 'PATH=/opt/local/bin:$PATH' >> ~/.bash_profile
$ # Reload bash_profile so the changes take effect in this window
$ source ~/.bash_profile

Voila! Now when we use vim we will be using the new one. But, to get back to our old configuration in the event of huge f*ckups, we can just delete the /opt directory.

$ which vim
/opt/local/bin/vim
$ vim --version | head -n 2
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Aug 27 2011 20:55:46)
MacOS X (unix) version

See how clean this is.

I recommend not to install in /usr/local/bin when you want to override binaries in /usr/bin, because by default OS X puts /usr/bin higher priority in $PATH than /usr/local/bin, and screwing with that opens its own can of worms.... So, that's what you SHOULD do.

Part 2: The "correct" answer (but a bad idea)

Assuming you're set on doing that, you are definitely on track. To install on top of your current installation, you need to set the "prefix" directory. That's done like this:

hg clone https://bitbucket.org/vim-mirror/vim or git clone https://github.com/vim/vim.git
cd vim
./configure --prefix=/usr
make
sudo make install

You can pass "configure" a few other options too, if you want. Do "./configure --help" to see them. I hope you've got a backup before you do it, though, in case something goes wrong....

Compile Vim 7.3 with +clientserver feature on Mac OS X

I got it to work by adding --enable-gui=gtk2

./configure --enable-rubyinterp --enable-pythoninterp --with-features=huge --enable-gui=gtk2

Then run from the console:

$ vim --servername FOOBAR_SERVER

From another console:

$ vim --serverlist
FOOBAR_SERVER

Or from within any Vim instance:

:echo serverlist()
FOOBAR_SERVER

Note that X11.app will also boot up as it is necessary for the Vim server to function.

RVM / ZSH - Always shows Upgraded http://rubygems.org/ to HTTPS when gem installing

check this files:

  • ~/.gemrc
  • /etc/gemrc

it has nothing to do with rvm



Related Topics



Leave a reply



Submit