简体   繁体   English

安装Rails无法启动

[英]Install Rails won't start

I have installed ruby on rails following the 310 railcasts on railcast.com. 我已经按照railcast.com上的310条Railcast在轨道上安装了ruby。 Now I was able to run and create a new rails and run it using rail s. 现在,我可以运行并创建一个新的rails并使用rails来运行它。 The issue comes as soon has I close the terminal and restarted it i get the following error 我关闭终端并重新启动后,问题就来了,我得到以下错误

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

Here ruby version 红宝石版

ruby -v
ruby 1.9.3p286 (2012-10-12 revision 37165) [i686-linux]

if i do rails -vi get following 如果我做rails -vi,请关注

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

whereis rails
rails:

gem environment gives me this 宝石环境给我这个

  - RUBYGEMS VERSION: 1.8.24
  - RUBY VERSION: 1.9.3 (2012-10-12 patchlevel 286) [i686-linux]
  - INSTALLATION DIRECTORY: /home/john/.rvm/gems/ruby-1.9.3-p286
  - RUBY EXECUTABLE: /home/john/.rvm/rubies/ruby-1.9.3-p286/bin/ruby
  - EXECUTABLE DIRECTORY: /home/john/.rvm/gems/ruby-1.9.3-p286/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-linux
  - GEM PATHS:
     - /home/john/.rvm/gems/ruby-1.9.3-p286
     - /home/john/.rvm/gems/ruby-1.9.3-p286@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

I also believe the answer his the path and seem to the same has this questions Installed Rails but the rails command says it's not installed . 我也相信他的答案是正确的,而且似乎也有这个问题。Installed Rails但rails命令说它没有安装 But i do not know how to place the path. 但我不知道如何放置路径。 Any help would be appreciated 任何帮助,将不胜感激

尝试键入rvm -v,如果发生错误,则说明您的rvm安装有问题,如果是这样,请尝试获取外壳程序配置文件的源,即如果您在Mac上使用bash:“ source〜/ .profile”

I am using Mac OSX, and in my .bashrc which is under my home directory. 我正在使用Mac OSX,并且在主目录下的.bashrc中。 There is a line : PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting 有一行: PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting

By the way, you should tell the rvm to use 1.9.3 of ruby by the command rvm use 1.9.3 顺便说一句,您应该通过rvm use 1.9.3命令告诉rvm使用1.9.3的ruby

Your problem could be the thing that rvm switches between your ruby versions and when you restart the terminal it is not the old ruby version that you were using before exiting. 您的问题可能是rvm在您的红宝石版本之间切换的问题,并且当您重新启动终端时,它不是退出之前使用的旧红宝石版本。 So one solution can be. 因此可以采取一种解决方案。 You create ".rvmrc" file in your rails application folder and inside you put just one line: 您在rails应用程序文件夹中创建“ .rvmrc”文件,并在其中仅放置一行:

rvm use 1.xx rvm使用1.xx

where 1.xx is the ruby version that you will use. 其中1.xx是将使用的红宝石版本。 Once you have gem rails in this version it will always work for you. 一旦有了此版本的宝石护栏,它将始终为您服务。 This file simply tells which ruby shell be used when you work in your aplication direcotry 该文件只是告诉您在应用复制过程中使用哪种红宝石外壳

@user1022209 your solution will also work if the problem is with the ruby version but the point is that you always have to set ruby when your enter your folder and this can somethimes be anoying. @ user1022209,如果红宝石版本存在问题,您的解决方案也可以使用,但要点是,输入文件夹时始终必须设置红宝石,这可能会使某些问题困扰。 I think that the best way to set default ruby version is using .rvmrc file. 我认为设置默认红宝石版本的最佳方法是使用.rvmrc文件。

3 lines of writing: 3行文字:

vim .rvmrc #creates new file, after which you have to press "i" for Insert mode vim .rvmrc#创建新文件,然后您必须按“ i”进入插入模式

rvm use 1.xx #contains only this line inside after which you press "ESC" and you type rvm use 1.xx#仅包含此行,然后按“ ESC”并键入

:wq or :wq! :wq或:wq!

Finally press Enter and you are done forever :) 最后按Enter键,您将永远完成:)

Hope it will solve your problem 希望它能解决您的问题

gem install rails

Do not sudo or apt-get when installing Rails with an installation of Ruby that was compiled from source. 使用从源代码编译的Ruby安装Rails时,请勿sudoapt-get You may need to remove the Rails package first since you have already attempted to install it using the apt-get package manager. 您可能需要先删除Rails软件包,因为您已经尝试使用apt-get软件包管理器进行安装。

apt-get remove --purge rails

apt-get clean

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM