0

In chapter 1.2.2 of Michael Hartl's Ruby on Rails tutorial we are using rvm to install rails. Following the first few steps is no problem. But when I get to this command:

rvm use 1.9.3@rails3tutorial2ndEd --create --default

I get this response.

RVM is not a function, selecting rubies with 'rvm use ...' will not work.

I did a lot of research before posting this question. But could not find one that addresses my problem specifically. I'm using linux under Ubuntu (in a VM on Windows 7). Thank you.

Will
  • 337
  • 4
  • 15
  • I'd suggest using rbenv over rvm. What is your system ruby? `ruby -v` – Noah Clark Sep 12 '12 at 21:21
  • 1
    Also, have you worked through: http://stackoverflow.com/questions/9336596/rvm-installation-not-working-rvm-is-not-a-function – Noah Clark Sep 12 '12 at 21:23
  • Following the above link solved my question. There was a lot of material at that link. The simple step that was required was to "use a login shell" as described here: https://rvm.io/integration/gnome-terminal/ – Will Sep 12 '12 at 22:12
  • Problem NOT solved. Please see my comment below. Sorry for the false success notice. – Will Sep 13 '12 at 00:06
  • if you're just trying to get 1.9.3 to work on your machine, I'd suggest using rbenv, or compiling it from source instead of using rvm. Can you tell me what ruby -v returns on your machine? – Noah Clark Sep 13 '12 at 00:44
  • ruby -v returns: ruby 1.9.3p194 (2012-04-20 revision 35410) [i686-linux] – Will Sep 13 '12 at 17:16
  • I ended up using JohnnyFive's script (see below) and it resolved my problem. – Will Sep 13 '12 at 17:17
  • By the way, JohnnyFive's script does use rbenv. I'll have to learn more about this. – Will Sep 13 '12 at 17:18
  • the good news is that you got it working. The bad news is that you wasted all that time (but hey you learned something!), because you already had 1.9.3 installed. – Noah Clark Sep 13 '12 at 20:30

2 Answers2

1

The above is one way to fix it, although RVM says you should instead change your shell settings.

Press ctrl+alt+t to bring up the terminal, and then go to edit >> profile preferences >> title & command tab, then select "Run Command as Login Shell".

That should work as well.

Morgan
  • 196
  • 9
  • I have done all of the steps at the other StackOverflow question that is similar. And I have carefully done the suggestions here. Still, when I run "bundle install" in my rails app folder I get the – Will Sep 13 '12 at 00:08
  • My Ubuntu is: Ubuntu 12.04.1 LTS – Will Sep 13 '12 at 00:16
  • After changing the setting, you have to restart the terminal. Did you do that? Also, it might be useful for you to paste the cli up to that point, as well as the output of: `ls ~/.rvm`. I agree that using RBENV or just installing it yourself might be easier, RVM is not required for the tutorial at all. – Morgan Sep 13 '12 at 01:00
  • I just spent the last 3 hours writing a script to install ruby, rails, and rubygems.. because it was fun. If it happens to help you, that's great, if not keep trying! [RailsSetup](https://github.com/johnny5ive/Rails-Setup) – Morgan Sep 13 '12 at 04:33
  • Well JohnnyFive - your script did the trick. It was fun working with it and I learned a few things along the way. In the end when I know run 'bundle install' in my "FirstRails App" directory, it completes with no warning at all about rvm is not a function. I think I am out of the woods on this one and I can proceed with the Hartl tutorial. – Will Sep 13 '12 at 17:14
  • @Will Great, glad it worked. Feel free to upvote my answer. Also, I updated the script to install fix a few errors and install RubyGems into the installed Ruby directory. Feel free to look at the changes. It's a good idea to understand what's happening, and not just copy/paste. Feel free to message me if you want information and want to look deeper into the issue. – Morgan Sep 13 '12 at 18:13
0

You have probably not yet installed RVM correctly.

Make sure that you source RVM from your .bash_profile or .bashrc file.

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function

This is what I have in my .bash_profile for RVM to work. (After adding this restart your console or type source ~/.bash_profile

Tigraine
  • 23,358
  • 11
  • 65
  • 110
  • That line is in my .bash_profile file but it does not seem to be running because I also have my desired prompt set here (PS1= ..) and I am not getting that prompt. I'm learning linux and I'm not clear what profile files are being run when I open a terminal window besides the system one. – Will Sep 12 '12 at 21:46
  • The comment above linking me to another stack overflow question looks very helpful. I missed it on my earlier search. I will follow through with that posting and see if it resolves my question. – Will Sep 12 '12 at 22:03