Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't use Rails

I've installed new Rails 3.1.3 using gem

# gem install rails

Then type:

wbednarski@mbp13:~$ rails
Rails is not currently installed on this system.
To get the latest version, simply type:

$ sudo gem install rails

You can then rerun your "rails" command.

More WTF:

wbednarski@mbp13:~$ which rails
/usr/bin/rails

How is it possible that command rails exist but Rails is not installed and how to fix it?

EDIT:

wbednarski@mbp13:~$ sudo gem install rails
Password:
Successfully installed rails-3.1.3
1 gem installed
Installing ri documentation for rails-3.1.3...
Installing RDoc documentation for rails-3.1.3...

then

wbednarski@mbp13:~$ rails -v
Rails is not currently installed on this system. To get the latest version, simply type:

    $ sudo gem install rails

You can then rerun your "rails" command.
like image 290
Wojciech Bednarski Avatar asked Dec 02 '11 02:12

Wojciech Bednarski


2 Answers

I would recommend not using the system installed ruby or install gems in the system directories. There are a couple projects out there for handling installations of different ruby versions and gems. The first and most well known is rvm. The other one I know about is rbenv. RVM might be a good choice to start with and you can decide later on if you want to try rbenv.

RVM is beneficial since it installs to your local home directory whichever ruby version you want and the gems too. This alleviates the issue of needing the correct permissions and $PATH issues.

like image 130
Vincent Agnello Avatar answered Sep 30 '22 16:09

Vincent Agnello


I had similar problem on my Mac OS X (Lion)

According which rails I got path /usr/bin/rails So I made simple workaround:

  1. Find a proper rails bin file by $ find / -name rails or similar ("/usr/local/Cellar/ruby/1.9.3-p194/bin/rails" in my case )
  2. Make a backup for old file $ sudo mv -v /usr/bin/rails /usr/bin/rails_old
  3. Create symlink to proper rails bin file $ sudo ln -s /usr/local/Cellar/ruby/1.9.3-p194/bin/rails /usr/bin/rails

Should help.

Be aware! This is temporary solution and I don't think that is proper one. It's can be cause by ruby upgrading to version 1.9.3 using brew or something similar.

like image 40
y4roslav Avatar answered Sep 30 '22 18:09

y4roslav