Using RVM with GVim (Cream): rvm command not found

I am trying to switch to GVim (cream) as the main editor on Ubuntu. I use the wonderful rails.vim, however I also use RVM.

Rvm works great when doing actions in the shell, and the ruby ​​version that I would like to use in rails.vim is the default version (but not the system version).

When I try to run things like

:Rgenerate migration migration_name 

I get:

 ... Missing Rails 2.3.8 gem. ... 

If I try:

 :!rvm use default 

I get:

 /bin/bash: rvm: command not found 

Obviously, cream / gvim does not use my .bashrc. What can I do to fix this and make it work? Thanks.

+6
bash vim ruby-on-rails ubuntu rvm
source share
8 answers

Try using cream from the command line, if this solves the problem, you can point your menu item to a script that opens the cream in the context of the bash prompt.

+4
source share

This is because you use rvm scripts in your .zshrc file. MacVim does not send a .zshrc file, but will generate a .zshenv file.

Add the following line to the .vimrc file.

 set shell=/bin/sh 
+3
source share

You probably used .bash_profile to add RVM stuff to the bash environment. Alas, ~ / .bash_profile is usually not read by X startup scripts, as described in Ubuntu Help

Use .profile or .bashrc. The .profile file is only called bash if the .bash_profile does not exist. I would use .bashrc.

+1
source share

rvm is a bash function that modifies the bash environment. It looks like it should not run from within vim. You cannot change the environment of an already running program.

0
source share

Try rvm gem list make sure that the harness is actually installed. rails (2.3.8) . If it does not start rvm gem install rails .

I am a vim user and rvm + rails.vim works fine for me. Including an example :Rgenerate .

0
source share

rvm is installed based on the shell, so if you launch a new window or new tab and you use something other than the default interpreter and gemset, you need to first

rvm gemset use my_rails238_gemset

and then

vim myshiz

0
source share

Add this line to your ~ / .bashrc:

 [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" 

And make sure it appears before [ -z "$PS1" ] && return , which stops searching for the rest of the file if bash is not interactive.

And then add this to your ~ / .profile file:

 export BASH_ENV=$HOME/.bashrc 

With this line, bash will now be the source of $ HOME / .bashrc if it is not interactive. Both GVim scripts and shells that you double-click should now use RVM.

Note. Only teams :! (ex:: :!ruby , :!echo ) will use RVM because commands such as :ruby and :echo do not start bash and therefore do not use the source ~ / .bashrc.

0
source share

Running gvim from the command line does not work for me (in the sense that this is unacceptable). When I use a GUI application, I want to use it as a graphical interface, without using a useless shell in the background.

The ' set shell= ' trick that works for Mac users doesn't work for me. Like you, I use Ubuntu. Even installing the shell on /bin/bash does not.

The only thing I got is this. First of all, install rvm.vim in addition to rails.vim .

Then, when you open gvim / cream, go to the project root folder and type

 :Rvm 

This will force rvm.vim to read your .ruby-version (or .rvmrc ) .rvmrc and properly initialize it.

In this moment

 :Rake :Rgenerate 

... and other rails.vim commands should work fine.

Note that you can also pass arguments to :Rvm in the same way as when starting rvm from the shell.

0
source share

All Articles