3

I have created a rails3 app using rvm a few month ago. Everything works fine.

Now, I want to create another rails3 app. So I done :

$> rails new my_app

Everything works fine. Next, I wanted to link my app with rvm, so I tryed this:

$> ruby -v
   ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-linux]
$> rvm install 1.9.3
$> rvm get head
$> rvm --rvmrc --create 1.9.3-p448@my_app (http://stackoverflow.com/questions/11138376/how-to-make-rvmrc-file-in-project-root-folder)

But I have got this error :

mkdir: cannot create directory `/usr/local/rvm/gems/ruby-1.9.3-p448@bcayi': Permission denied

Ok, permission denied, so I tryed:

$> rvmsudo --rvmrc --create 1.9.3-p448@my_app

And I have got this error:

sudo: invalid option -- '-'

So my question is : How to link rvm to my rails app ?

Jérémy Pouyet
  • 1,989
  • 6
  • 28
  • 55
  • Getting the sudo invalid option error as well with Scientific Linux 6.4 (x86_64) and latest stable RVM as of this writing. In my case it turned out that - provided I was in the `rvm` group - I didn't even have to use `rvmsudo` in the first place. – 0xC0000022L May 19 '16 at 09:42

3 Answers3

1

because your RVM is installed in system (/usr/local/rvm vs. $HOME/.rvm) you need to be in rvm group (check with id) to be able to do things with rvm (like creating gemsets in this case).

To add yourself to rvm group run:

rvm group add rvm $USER

then you might need to restart your console / computer to make it work properly - sometimes OSX after freshly adding you to group will report it in id but it will be not effective till restart of computer (or relogin, but on OSX it's the same time).

mpapis
  • 52,729
  • 14
  • 121
  • 158
  • I'm already in rvm group: `$> rvmsudo rvm group add rvm $USER ` tells me : `User 'jeremy' already in the group 'rvm'` – Jérémy Pouyet Sep 16 '13 at 12:06
  • what does running `id` tell you? if it's not in `rvm` group - did you restart computer? – mpapis Sep 16 '13 at 15:24
  • @mpapis: Thanks, although my user was already in the `rvm` group, your answer provided the context to understand that I needn't use `rvmsudo` at all to manipulate a system RVM instance, as long as I'm in that group. Also thanks for RVM! – 0xC0000022L May 19 '16 at 09:46
0

Problem solved !

Because the rvmsudo --rvmrc --create 1.9.3-p448@my_app failed, I have created the 1.9.3-p448@my_app directory manually :

$> sudo mkdir /usr/local/rvm/gems/ruby-1.9.3-p448@my_app

Then, I passed the ruby-1.9.3-p448@my_app directory in the rvm group :

$> sudo chown jeremy:rvm /usr/local/rvm/gems/ruby-1.9.3-p448@my_app
$> sudo chmod 755 /usr/local/rvm/gems/ruby-1.9.3-p448@my_app

Finally, I could create my gemset without rvmsudo :

$> cd my_app/
$> rvm gemset create my_app
$> rvm --rvmrc --create ruby-1.9.3-p448@my_app
$> cd .. ; cd my_app/
   You are using '.rvmrc' ...
Jérémy Pouyet
  • 1,989
  • 6
  • 28
  • 55
-1

try

sudo rvm --rvmrc --create 1.9.3-p448@my_app
dax
  • 10,779
  • 8
  • 51
  • 86
  • 2
    downvoted, you have clearly no idea how rvm works - it's a shell function that changes current process environment, prefixing it with `sudo` changes the process and runs it as binary. – mpapis Sep 15 '13 at 23:34
  • fair enough. that's a good description of rvm and worth the downvote – dax Sep 16 '13 at 04:20