RVM: Unable to use shorthand expression after setting default - rvm

I've been using RVM for quite some time now and have been very happy with it. But just today when I tried to be a little adventurous and set a particular gemset of my default ruby as the default gemset, the shorthand way of switching gemsets has stopped working.
My default ruby is set to ruby-1.8.7-p330.
rvm default gemset list
gives the following gemsets
projA
projB
projC
I've bee able to use shorthand formats
rvm use default#projA
rvm use default#projB
rvm use default#projC
till now without issues. However, ever since I set one of the gemsets as default,
rvm use default#projA --default
all of the above shorthands set the projA gemset.
Is there any way I can unset the default tag on a gemset?
Though I can still use other shorthands like
rvm use #projB
I don't want to do that since a lot of other stuff depend on the way these shorthand expressions are used. Any suggestions?

In RVM the default gemset points to the global gemset of your RVM ruby version. When I set a particular gemset as the default using
rvm use default#projA --default
This set the projA gemset as the default gemset of my default ruby version.
Seems like the only way to undo this is to dig into .rvm in the home directory and remove the defaults line from the ruby's environment file.

Related

How to identify ruby and gemset combination for rvm wrapper

I am trying to install seeing_is_believing in order to display results of every line of Ruby code for ST2.
I am supposed to create a rvm wrapper to generate a ruby binary that can be used by ST2.
I need to decide which ruby and gemset combination I wish to use.
I am currently using ruby version 1.9.3-p429.
In my .rvm directory I have a "gems" and "gemsets" folder
gems/ruby-1.9.3-p429/gems/INDIVIDUAL GEMS
gemsets/jruby/global.gems
gemsets/ruby/1.8.5/global.gems
gemsets/CONTAINS default.gems, global.gems
I am not sure how to select a gemset, if I do not have a gemsets folder within gems/ruby-1.9.3-p429 directory.
I have tried the following.
Mikes-MacBook-Pro:Packages mwsage$ rvm wrapper 1.9.3-p429#global.gemset
Gemset 'global.gemset' does not exist, 'rvm ruby-1.9.3-p429 do rvm gemset create global.gemset' first, or append '--create'.
Could not load ruby 1.9.3-p429#global.gemset.
Mikes-MacBook-Pro:Packages mwsage$ rvm wrapper 1.9.3-p429#1.8.5 Sublime Text 2
Gemset '1.8.5' does not exist, 'rvm ruby-1.9.3-p429 do rvm gemset create 1.8.5' first, or append '--create'.
Could not load ruby 1.9.3-p429#1.8.5.
The example I have looked at uses rbx#rails3 as their ruby/gemset combo and enter
rvm wrapper rbx#rails3 textmate
as the instruction is a wrapper for textmate and not ST2.
I couldn't figure out how to identify my interpreter, as he is using rbx, I'd guess mine to be MRI?
The general instructions for install also suggest RBENV. Is this a substitute for rvm?
Also - What is a ruby binary?
You can select an existing gemset with rvm gemset use gemset_name_here or you can create a new gemset with rvm gemset create gemset_name_here.
You might find the following blog post useful for RVM basics. http://strandcode.com/2013/07/11/ruby-version-manager-rvm-overview-for-rails-newbs/
RBENV is an alternative to RVM. They both perform similar functions.
So in your case, I think you'll want rvm wrapper ruby-1.9.3-p429#gemset_name_here sublime
In the context of the instructions at https://rvm.io/integration/textmate, I think "binary" is effectively a simple script providing instructions on which ruby version and gemset to use.

RVM setting incorrect environment path

I was having trouble installing rvm on WebFaction, so I tried just copying over the .rvm directory with my rubies and gems. This has mostly worked. rvm works, it’s referencing the correct ruby, and the correct gem. The problem it seems, is rvm is looking for an environment file in the wrong place. It’s trying to use:
/Users/jezen/.rvm/environments/ruby-2.0.0-p247
Whereas it should be using:
/home/rekyl/.rvm/environments/ruby-2.0.0-p247
Where can I set the correct path?
check /Users/jezen/.rvm/wrappers/ruby-2.0.0-p247/ruby but also /home/rekyl/.rvm/environments/ruby-2.0.0-p247 is relevant, make sure all environment variables point to proper path:
env | grep rvm

How to make rvmrc file in project root folder?

I have just installed RVM in my machine and facing problem with rvmrc file, can anyone help me out, how to create rvmrc?
I just did:
rvmrc --create ruby-1.8.7-p352#gemset
but didn't get the result...
It seems that there is a small mistake. Inside your .rvmrc file add:
rvm use ruby-1.8.7-p352#gemset --create
Also you might want to change the name of your gemset to something that is a bit more intuitive to read :)
UPDATE
Using the rvmrc file has now been deemed deprecated. Instead a .ruby-version file with the ruby version e.g. '2.0.0' and a .ruby-gemset file with the gemset name e.g. 'monkeys_of_doom'
This way developers using other version managers such as rbenv can pick up the ruby version in an automated fashion.
rvm --rvmrc --create ruby-1.8.7-p352#gemset
Read this article. http://net.tutsplus.com/tutorials/why-you-should-use-rvm/
If the gemset already exists, it is sufficent to add rvm ruby-1.8.7-p352#gemset to the .rvmrc file, which can be achieve for instance by
echo "rvm ruby-1.8.7-p352#gemset" > .rvmrc
UPDATE: it looks like the .rvmrc file format is deprecated, and the usage of .ruby-gemset and .ruby-version files is encouraged instead. If "rails2.3.5" is your gemset name, then one would require the following two commands
echo "ruby-1.8.7-p352" > .ruby-version
echo "rails2.3.5" > .ruby-gemset
I found working solution (http://sirupsen.com/get-started-right-with-rvm/)
rvm --create --rvmrc 1.8.7#project
you can also do this
rvm --rvmrc --create use ruby-1.9.3-p194#myproject
Instead of rvmc use:
rvm --create --ruby-version ruby-2.1.04#my-project
will generates the .ruby-gemset and .ruby-version files
The definitive documentation is at https://rvm.io/workflow/rvmrc/ for how to create rvmrc files, and the global .rvmrc parameters that affect them.
The --rvmrc parameter is what actually creates the rvmrc files, then you have to run
rvm rvmrc trust .
in the project directory to generate, and record, the security md5 hash to use that rvmrc file. The command 'trusts' the file so you're not prompted to trust it every time you enter the directory.
here is another much simpler approach
rvm use 1.8.7#gemset --create
first you need to create a rvmrc like -
rvm --rvmrc --create use ruby-2.2.1#gemset_name
Then run
rvm rvmrc trust .
That will resolve the issue for selecting rvm for differnt application.
Hope you enjoy. :)
For creating rvmrc file with specific ruby and gemset then use below command -
rvm --rvmrc --create ruby-with-version#gemset_name
like:
rvm --rvmrc --create ruby-2.3.3#rails5
Now we should need to select project location for change reflection so type cd .. and hit enter in terminal
Again type cd project_name/ for selecting our project but now you get * Notices something like below image so here you just type y and hit enter.
Now you have successfully created rvmrc file so from now no need to select gemset each time on selecting different projects.

Revert to system installed version ruby 1.8.7

I installed ruby 1.9.3 using RVM. I want to use 1.8.7 interpreter whenever I open a new terminal session. Currently I have to type rvm system every time I open the terminal.
To quote RVM's documentation:
If you wish to switch back to your system ruby as default, remember
that RVM does not "manage" the system ruby and is "hands off".
This means to set the "system" ruby as default, you reset RVM's
defaults as follows:
rvm reset
I not sure about reverting back.. But you can use .rvmrc file to avoid keep on typing rvm system command. Create a file in the name of .rvmrc and store the command rvm system in it. Move the file to specific path.. In your case in home/root folder. Now by default. It will use system ruby. check the below link for more details
rvmrc

How can I use two different ruby installations for same project with rvm and rvmrc files?

I have a an app that runs and is installed on JRuby in production. The same app can run in Ruby 1.8.7 as well in development. How can I use RVM to switch between these rubie?
I am looking for a .rvmrc-like solution so that I can say
rvm use .rvmrc_ruby
or
rvm use .rvmrc_jruby
to switch between Ruby versions. I usually need to do this to test the same app on both Ruby and JRuby.
I would like a solution where I can check-in such settings to Git and run these things without having to type the Ruby versions or gemset names everytime I need to switch.
generate those two files and in .rvmrc write:
source ./.rvmrc_${TEST_WITH:-jruby}
then you can write in your shell:
export TEST_WITH=ruby
cd .
and restore with:
unset TEST_WITH
cd .
This seems silly.
First, why are you even bothering to run a different Ruby in development? If this is for the occasional test run to ensure compatibility across different Rubies, then okay, but then…
Second, all you probably have in your .rvmrc is rvm use 1.8.7 or rvm use jruby—that is all that happens when your .rvmrc file runs. What's so bad about just actually typing that out into the terminal? It's actually less characters than the example commands you gave, and you get tab-completion too. If you need consistency across shells and actually have to have the .rvmrc reflect the current Ruby you want, then just change the file. Or, if you really must, write a simple script to do it for you (say it's called changervmrc.sh):
#!/bin/bash
echo "rvm use $1" > .rvmrc
and invoke with ./changervmrc.sh jruby. You could adapt this to include switching to a specific gemset if needed.