Ubuntu RVM Rails bash command not found

大憨熊 提交于 2019-12-03 03:28:06

You need to

Add rvm to your .bashrc by adding a line like

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

This will allow you to load rvm when you start a new bash session

create a new Gemset when you want a new rails.

The work flow should work like this

$ mkdir new_rails_app
$ cd new_rails_app
$ vim .rvmrc

# edit the .rvmrc to use the correct Gemset Something like 
rvm use ruby-1.9.2-p180@new_rails_app --create

#save and exit vim

$ rvm rvmrc load
# you should see a prompt that your Gemset was loaded

$ gem install rails
$ rails new .

You now have a working rails directory for a new app using rvm. There are other little tricks like auto loading your rvmrc's but I left that out just for the sake of the "easiest" route.

I meet the issue "command not found: rails" too, but I'm using oh-my-zsh for the shell prompt, and I fix the issue by copy the line

PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.

from file ~/.bashrc to ~/.zshrc, and it works well. Hope it can give you some help.

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