Reputation: 199
I'm using fish shell 2.10 on Mac OS X 10.9.1. I would like to use a Ruby that I have installed using RVM as the default in my terminals, however I can't seem to make this work.
I've tried rvm use 2.1.0 --default
but upon opening a new terminal I still get the following:
> which ruby
/usr/bin/ruby
Running the rvm
command causes the ruby to be loaded:
> which ruby
/usr/bin/ruby
> rvm
[...]
> which ruby
/Users/alex/.rvm/rubies/ruby-2.1.0/bin/ruby
But it's annoying to have to do this every time I open a new terminal.
Upvotes: 11
Views: 7515
Reputation: 107
I think to make it easier, you can add a [rvm] 2 plugin to fish shell via [fisher] 1.
For install fisher:
curl -Lo ~/.config/fish/functions/fisher.fish --create-dirs git.io/fisher
After, install rvm plugin for Fish Shell:
fisher add jorgebucaran/fish-nvm
or
fisher install oh-my-fish/plugin-rvm
After that, rvm runs perfect.
(was fisher rvm
previously)
Upvotes: 7
Reputation: 8098
Firstly install rvm fish functions from rvm.io
curl -L --create-dirs -o ~/.config/fish/functions/rvm.fish https://raw.github.com/lunks/fish-nuggets/master/functions/rvm.fish
You should now be able to use rvm command in fish after reopening terminal.
Run the following to add the line rvm default
to your fish config file.
echo 'rvm default' >> ~/.config/fish/config.fish
You should now be able to use ruby related binaries and gems after reopening terminal.
Upvotes: 26
Reputation: 44370
Install oh-my-fish very useful tools, have rvm plugin and many cool another.
Framework for managing your fish shell configuration
Upvotes: 5
Reputation: 81
In your config.fish load rvm plugin and call it silently:
. ~/oh-my-fish/plugins/rvm/rvm
rvm >/dev/null
If you're using bob-the-fish theme you'll have a ruby version in your prompt like this:
ruby-2.1.2 > ~/d/web > master >
Which can be suppressed, if you'd like, by removing the line below in bobthefish/fish_prompt.fish:
__bobthefish_prompt_rubies
Upvotes: 0
Reputation: 4333
This occurs because, out of the box, the Rubies installed through RVM aren't added to your path. When you run any RVM command, it adds the paths relative to the ruby version you're using to $PATH. RVM seems to take care of bash and zsh but doesn't have built-in support for correcting the paths for your dot files.
Here's an example of my path before an RVM command:
/Users/grant/pear/bin /usr/local/sbin/ /Users/grant/.rvm/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin /usr/local/git/bin /usr/local/go/bin
Here's an example of my path after running 'rvm':
/Users/grant/.rvm/gems/ruby-2.2.0/bin /Users/grant/.rvm/gems/ruby-2.2.0@global/bin /Users/grant/.rvm/rubies/ruby-2.2.0/bin /Users/grant/pear/bin /usr/local/sbin/ /Users/grant/.rvm/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin /usr/local/git/bin /usr/local/go/bin
The bottom line is that you'll want to add the .rvm files to your path depending on the version you default to. This post helped me figure out how to do that. You can append the paths that RVM adds to your fish profile with:
set -g -x PATH $PATH <paths_to_add>
Example from above:
set -g -x PATH $PATH /Users/grant/.rvm/gems/ruby-2.2.0/bin /Users/grant/.rvm/gems/ruby-2.2.0@global/bin /Users/grant/.rvm/rubies/ruby-2.2.0/bin
To have this run every time you load fish, add the above command to ~/.config/fish/config.fish. Alternatively, you can add the rvm command to your fish config and have it load it for you.
Hope this helps! -Grant
Upvotes: 1
Reputation: 11
This below worked for me from the fish google group forum. credit eggegg for this solution below:
The original support for fish shell requires converting bash script to a fish script. As it mentioned here: https://rvm.io/integration/fish.
I found there's a simpler solution: let bash do the bash scripts, we only need the result of the environment variables.
Code: https://gist.github.com/eggegg/6077153
Just insert the first one into your own config.fish, then copy rvm.fish to ~/.config/fish/functions/ will do the tricks.
Upvotes: 0