4

I just did this command to install Rails:

gem install rails

And it seems to have run fine and installed things.

Then as I followed this tutorial: http://guides.rubyonrails.org/getting_started.html it said to do this command:

rails new blog

Which I did and it gave me this error:

The program 'rails' is currently not installed.  You can install it by typing:
sudo apt-get install rails

Any idea why this might be the case? I thought rails was supposed to begin working automagically :)

I did this command:

rvm gemdir

And it gave me this result:

RubyGems Environment:
  - RUBYGEMS VERSION: 1.6.2
  - RUBY VERSION: 1.9.2 (2011-02-18 patchlevel 180) [i686-linux]
  - INSTALLATION DIRECTORY: /home/agenadinik/.rvm/gems/ruby-1.9.2-p180
  - RUBY EXECUTABLE: /home/agenadinik/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
  - EXECUTABLE DIRECTORY: /home/agenadinik/.rvm/gems/ruby-1.9.2-p180/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-linux
  - GEM PATHS:
     - /home/agenadinik/.rvm/gems/ruby-1.9.2-p180
     - /home/agenadinik/.rvm/gems/ruby-1.9.2-p180@global

Should there be something like this:

EXECUTABLE DIRECTORY: /usr/bin
Genadinik
  • 18,153
  • 63
  • 185
  • 284
  • 1
    duplicate : http://stackoverflow.com/questions/3065839/sudo-gem-install-rails-this-doesnt-give-me-a-rails-command-for-bash – Spyros Apr 22 '11 at 21:42
  • I had a similar problem some days ago. Have you tried `sudo apt-get install rails`? – whirlwin Apr 22 '11 at 22:10
  • @Whirlwin you do not want to do sudo with this stuff I think. That will use root's paths and not your user's paths. It might create a mess :) – Genadinik Apr 22 '11 at 23:33
  • That's true. Might explain why I sat so many hours with just the installation. :P But eventually I found a tutorial how to set it up (Rails 3.0.6). Too bad I don't remember which one it was. – whirlwin Apr 23 '11 at 00:25
  • What files are listed in `~/.rvm/gems/ruby-1.9.2-p180/bin`? Furthermore, what is the output of `rvm info`? – Michelle Tilley Apr 23 '11 at 01:07

2 Answers2

6

RVM and apt-get are not compatible; They attempt to solve the same problem of software installation, but in very different ways.

apt-get always installs the software it manages into the system's directories, and you have to be running as root to do so. RVM is designed to install as a user's sandbox, installing into ~/.rvm, isolating everything it installs from the system, but still making it available for the user's code.

Should there be something like this:

EXECUTABLE DIRECTORY: /usr/bin

No, not for a RVM managed Ruby. All RVM managed Rubies and gems should reside in ~/.rvm somewhere.

Use which ruby to see what the system thinks your path to Ruby should be. If RVM is configured correctly, and you've installed Ruby using RVM, the path returned should be:

/home/agenadinik/.rvm/rubies/ruby-1.9.2-p180/bin/ruby

If it isn't there's something wrong with the RVM installation and you should check your configuration using the "Troubleshooting your Install" checks on RVM's installation page.

If the working Ruby is correct, type in which rails and you should see a response showing it is in the ~/.rvm sandbox somewhere. If so, try gem list rails. Rubygems should respond with:

rails (3.0.7)

for a current Rails installation. If not, use gem install rails and it should be installed after a couple minutes of churning. Following that, do the gem list rails command again, and you should see it followed by which rails, showing its visible to the system.

A separate issue is it looks like your RVM is out of date, or you didn't use rvm gemdir for the gems output, because rvm gemdir doesn't return that information in the current revision. To update it, use rvm get head, then either use rvm reload or close and reopen your terminal. A subsequent rvm -v should return version 1.6.3, which is current as of today. RVM updates quickly, so be sure to periodically update it for bug fixes. I check several times a week, but weekly should be fine and monthly should be adequate.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
  • That was a really great and helpful write-up. Thank you! – Genadinik Apr 25 '11 at 17:05
  • You're quite welcome. RVM is a great tool, and really is simple to use, but dealing with the OS and all the conflicting instructions on the internet makes it really confusing. As you go you'll get it more sorted out. – the Tin Man Apr 25 '11 at 17:46
-2

My guess is that 'rails' was installed to somewhere which is not in your user path.

You might try to locate rails, but I do not think sudo apt-get install rails will cause the problems you think it will and instead will solve your problem assuming you're okay with using aptitude to install things. It's pretty smarty. :)

Cthos
  • 985
  • 6
  • 10
  • 1
    apt-get will install only as root into the system-owned directories, and will not be part of RVM's managed Rubies. It will make things worse, not better. – the Tin Man Apr 23 '11 at 01:01
  • That depends on what you are attempting to do, does it not? For example on Ubuntu: https://help.ubuntu.com/10.04/serverguide/C/ruby-on-rails.html. Edit: But sure, I'll give you Ubuntu's repos are generally way behind. – Cthos Apr 23 '11 at 01:07
  • @Cthos, "That depends on what you are attempting to do, does it not?", not really. I only install Ruby using apt-get to have a minimal version available for scripts that are prewired to use `/usr/bin/ruby`. For a server I set up my own Ruby from source in `/usr/local/bin` or `/opt`, and manage all my gems. I've installed Ruby many times on many systems and have not seen any of them keep up, or work well for development or production server use. I feel the same way about Perl and Python installs handled by yum or apt. – the Tin Man Apr 23 '11 at 01:19
  • @Tin Man: Though, then this becomes a matter of personal preference I'd think. I'm kinda curious how often you in practice update your Ruby install from source. I Python 2.x hasn't had a new release since 2.7.1 back in November, and you can get that from various apt repos (probably not the official Ubuntu ones, granted). As for "installing as root" what do you mean? Aside from putting your binary in /usr/bin, you can still set up environment variables to alter your path when running applications...etc. I'm rambling now aren't I? :) – Cthos Apr 23 '11 at 01:29
  • We're not talking about Python, we're talking about Ruby. Ruby 1.9.2 in apt-get is confusing because it is renamed to avoid conflicts, which catches developers unawares. RVM has a lot of features targeting development that apt-get doesn't, plus RVM makes it very easy to stay on the bleeding, the leading or at any rev you want, plus easily switch in/out sets of gems. And, in RVM, everything is named using its standard conventions, they're just in a bit different path so we use `/usr/bin/env ruby` to get to them. I'm guessing you haven't much experience with RVM. – the Tin Man Apr 25 '11 at 17:54
  • @Tin Man: None at all, but then again the OP doesn't actually mention RVM until the point where it says "I tried this command", which makes the whole thing a little ambiguous. In any case, using RVM is a choice, as would using ruby from apt. Just because your preference to use RVM because of all of it's wizbang features does not mean that one cannot use Ruby from apt. That's all I'm getting at. – Cthos Apr 25 '11 at 17:59
  • @Tin Man: Also, mentioned Python simply because you brought it up. – Cthos Apr 25 '11 at 18:13