rvm gemset list
==> (default)
proj1
proj2
...
I can switch the gemsets to proj1 by rvm gemset use proj1 but once I open a new bash tab/window, the rvm switches back to default. How do I make it persist until I decided to switch to a different gemset?
Every terminal window / tab is a new subprocess with its own copy of environment and it can not influence parent process. It is not possible to set current loaded gemset that will be persisted between tabs without setting default.
The default is set for ruby and can include gemset:
rvm use 1.9.3#project --default
the --default flag sets default which is loaded with rvm when there was no other ruby loaded before.
Related
I have no idea why but RVM can't seem to change the default Ruby. I'm using Oh My Zsh and tried everything I've found but nothing seems to work.
➜ Sites rvm use 2.0.0 --default
Using /Users/anahkiasen/.rvm/gems/ruby-2.0.0-p247
➜ Sites rvm list
rvm rubies
=* ruby-2.0.0-p247 [ x86_64 ]
# => - current
# =* - current && default
# * - default
➜ Sites rvm reload && rvm list
RVM reloaded!
rvm rubies
* ruby-2.0.0-p247 [ x86_64 ]
# => - current
# =* - current && default
# * - default
Now the Ruby is set as default but RVM doesn't load it as "current", which means it does not load the gemsets that are affiliated to it.
➜ Sites rvm use 2.0.0
Using /Users/anahkiasen/.rvm/gems/ruby-2.0.0-p247
➜ Sites gem list
*** LOCAL GEMS ***
backports (3.3.3)
bson (1.9.1)
bson_ext (1.9.1)
bundler (1.3.5)
bundler-unload (1.0.1)
eventmachine (1.0.3)
genghisapp (2.3.7)
json (1.8.0)
mongo (1.9.0)
mustache (0.99.4)
rack (1.5.2)
rack-protection (1.5.0)
rack-test (0.6.2)
rake (10.1.0)
rubygems-bundler (1.2.2)
rvm (1.11.3.8)
sass (3.2.10)
sass-globbing (1.1.0)
sinatra (1.4.3)
sinatra-contrib (1.4.0)
sinatra-mustache (0.1.0)
tilt (1.4.1)
vegas (0.1.11)
➜ Sites rvm reload && gem list
RVM reloaded!
*** LOCAL GEMS ***
Nothing.
I have no .bashrc nor .bash_profile. There is no RVM reference in my .zprofile and here is my .zshrc :
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
ZSH_THEME="robbyrussell"
DEFAULT_USER="anahkiasen"
# Uncomment following line if you want red dots to be displayed while waiting for completion
COMPLETION_WAITING_DOTS="true"
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
plugins=(git bower brew composer gem laravel sublime)
## RVM and Rubygems
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
source $ZSH/oh-my-zsh.sh
I've tried swapping the above two lines, tried moving the RVM loading into .zprofile, nothing. Everytime I open a new instance of the terminal, the default is gone.
It loads the correct ruby, meaning if I do ruby -v I get the version I want, but for RVM it's not loaded and thus I have none of the gemsets.
I've also tried rvm --default use 2.0.0, rvm use 2.0.0#develop --default but same result.
I've reinstalled RVM, I've set recursively the permissions of the .rvm folder to the current user, nothing.
I'm kind of desperate at that point.
As you are using OH-MY-ZSH you might be hitting issue similar to this: https://github.com/robbyrussell/oh-my-zsh/pull/1359
RVM has a "fix" function, run:
rvm get head --auto-dotfiles
It will reorganize your dot files - it is important to read the output and follow instructions.
Make sure to use login shell for best effect.
Ah ha !! I just faced the same problem and resolved it eventually.
Let me reiterate my issue: Everytime i start my terminal, i had to first do a bundle install each time. Then i figured, Its not correct. So i tried sourcing my zshrc.
So everytime i had to do source ~/.zshrc or simply zsh also did the same and my gemset would get identified. Ofcourse assuming RVM and all other dependencies are installed correctly
Finally i figured i needed to do the following:
$ vim ~/.zlogin
The contents of the .zlogin should be
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
zsh #to initiate zsh (you could also replace this with 'source ~/.zshrc')
This resolved my problem. Now everytime i start my terminal, my defaults are all set.
Let me know if this works for you.
I installed ruby 2.0.0 for the first time (probably with clang? on accident). Now RVM behaves like ruby 2.0.0 is the default ruby.
I have a .ruby-version with ruby 2.0.0 in a project directory. When I cd from that directory to my home directory, where there is no .ruby-version or .rvmrc, RVM did not switch my ruby back to the default 1.8.7-p370. Even more weird, when I switched from a different project using 1.9.3 to my home directory, rvm switched the ruby from 1.9.3 to 2.0.0.
Yet when I use rvm list, the ruby marked as the default (with an asterisk) is still 1.8.7-p370.
How can I make 1.8.7 the default again?
Alternate titles:
RVM does not switch to the default ruby
RVM not switching to the default ruby
RVM makes the first installed ruby the default one, if this is not desired behavior just remove the default alias:
rvm alias delete default
and there will be no default ruby, alternatively set other ruby as default:
rvm use 1.9.3 --default #OR:
rvm alias create default 1.9.3
The same way you set the default when RVM is behaving normally:
rvm --default use 1.8.7
How do I view a list of all the gems in a given gemset? And is it possible to use multiple gemsets at a time or only one?
You can call gem list and it will display all the gems in your current gemset. You can only use one gemset at a time, but there is a hierarchy of gemsets. You can create a global gemset with (for example) rake and pry in it, and then any gemset you create (using the same version of ruby, of course) will inherit those gems into it.
Usually the current Ruby's #global gemset is included in other gemsets.
To see the contents of a gemset, excluding the #global gemset, first do rvm use 2.0.0#some-gemset --ignore-gemsets (or similar) then gem list.
For the default gemset, do rvm use 2.0.0 --ignore-gemsets then gem list.
Perhaps the simplest way is to query the filesystem. As an example, I had a gemset named yard using Ruby 3.0.3. All the gems installed in that gemset could be found with:
> ls ~/.rvm/gems/ruby-3.0.3#yard/gems
yard-0.9.26
(There was just that one gem.)
So the gemset directory name is:
~/.rvm/gems/#{ruby_version}##{gemset_name}/gems
...where ruby_version is the version rvm uses (i.e. the string output by rvm list).
My project has an .rvmrc file with the following: rvm 1.9.2-p180#project_name. However, I just updated my ruby 1.9.2 to the latest patch level (1.9.2-p290). Is there any way to migrate the gems in the project_name gemset to 1.9.2-p290?
You can copy gemsets with the following command:
rvm gemset copy 1.9.2-p180#project_name 1.9.2-p290#project_name
Reference: http://ruby.about.com/od/rubyversionmanager/ss/Upgrading-To-1-9-2-Using-Rvm_6.htm
Alternatively, your gemsets can be migrated (or moved) from one version of Ruby to another. Remember that migrate moves gemsets, not leaving a copy behind. But if you wish to do it this way, you can run the following command.
rvm migrate 1.9.2-p180#project_name 1.9.2-p290#project_name
Using rvm I installed and am using Ruby 1.9.2p180.
I created a gemset called rails3tutorial and, using it, installed Rails 3.0.7, created "sample_app", then used bundle to install. Very nice.
Then I created a new gemset called rails310b1, installed Rails 3.1.0 Beta 1, created an app, and bundle install'd...but it turned out I was not actually switched to the rails310b1 gemset, and so I ended up installing to ruby-1.9.2p180's default gemset (is that #global?...). I then manually deleted all the gems that had been installed!
Then I switched to rails310b1, and bundle install'd, created an app, fired up the app -- golden.
Now I switch back to the rails3tutorial gemset, and cd to the app created using it, and I get errors when running rails commands like...
$ rails generate integration_test layout_links
/Users/paul/.rvm/gems/ruby-1.9.2-p180#rails3tutorial/bin/rails:19:in `load': no such file to load -- /Users/paul/.rvm/gems/ruby-1.9.2-p180#rails3tutorial/gems/rails-3.1.0.beta1/bin/rails (LoadError)
from /Users/paul/.rvm/gems/ruby-1.9.2-p180#rails3tutorial/bin/rails:19:in `<main>'
It's looking for /Users/paul/.rvm/gems/ruby-1.9.2-p180#rails3tutorial/gems/rails-3.1.0.beta1/bin/rails but why?! $PATH looks fine.
Any suggestions as to what is messed up and how to clean this up, or is it best if I wipe out all my gems/gemsets and start over?...
Thanks!
There is nice screencast with basics of RVM http://screencasts.org/episodes/how-to-use-rvm but it mostly comes to using rubies:
rvm install 1.9.3
cd ~/projects/my-app
touch Gemfile
rvm use --create --rvmrc 1.9.3#rails32
gem install bundler rails
bundle exec rails new .
bundle install
bundle exec rails generate integration_test layout_links
please note you need to prefix most of the commands with bundle exec there is my gem that should save you from this problem rubygems-bundler.
also make sure you use .rvmrc files for every project so when you switch dir in console the proper ruby environment is set, the --rvmrc switch used above will generate one for you.