Installed Rails but it says I did not :)

不羁的心 提交于 2020-01-13 10:56:07

问题


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

回答1:


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.




回答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. :)



来源:https://stackoverflow.com/questions/5760290/installed-rails-but-it-says-i-did-not

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!