未找到 Ubuntu RVM Rails bash 命令 [英] Ubuntu RVM Rails bash command not found

查看:60
本文介绍了未找到 Ubuntu RVM Rails bash 命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚安装了 ubuntu,之后我想安装带有 ruby​​ 和 rails 3.1 的 RVM.

安装进行得很顺利,但是当我想创建一个 rails 应用程序时,它找不到 rails 命令.

我知道我可以创建别名,但是当 rvm 更改其 gemset 时,别名路径会出错,对吗?

这是我的 .bashrc 文件 (/home/user/.bashrc):

# ~/.bashrc: 由 bash(1) 为非登录 shell 执行.# 查看/usr/share/doc/bash/examples/startup-files(在bash-doc包中)# 举些例子# 如果不是交互式运行,什么都不做[ -z "$PS1" ] &&返回# 不要在历史记录中放置重复的行.有关更多选项,请参阅 bash(1)# ... 或强制忽略向上和忽略空间HISTCONTROL=ignoredups:ignorespace# 追加到历史文件中,不要覆盖它shopt -s histappend# 设置历史长度见 bash(1) 中的 HISTSIZE 和 HISTFILESIZEHISTSIZE=1000HISTFILESIZE=2000# 检查每个命令后的窗口大小,如有必要,# 更新 LINES 和 COLUMNS 的值.shopt -s checkwinsize# 使非文本输入文件更不友好,参见 lesspipe(1)[ -x/usr/bin/lesspipe ] &&eval "$(SHELL=/bin/sh lesspipe)"# 设置标识您工作的 chroot 的变量(用于下面的提示)if [ -z "$debian_chroot" ] &&[ -r/etc/debian_chroot ];然后debian_chroot=$(cat/etc/debian_chroot)菲# 设置一个花哨的提示(非颜色,除非我们知道我们想要"颜色)案例$TERM"在xterm-color) color_prompt=yes;;esac[[ -s "$HOME/.rvm/scripts/rvm" ]] &&源$HOME/.rvm/scripts/rvm"# 取消注释彩色提示,如果终端有能力;转身# 默认关闭以不分散用户注意力:终端窗口中的焦点# 应该在命令的输出上,而不是在提示上#force_color_prompt=是如果 [ -n "$force_color_prompt" ];然后if [ -x/usr/bin/tput ] &&tput setaf 1 >&/dev/null;然后# 我们有颜色支持;假设它符合 Ecma-48# (ISO/IEC-6429).(缺乏这种支持是极其罕见的,而且这种# 一个案例倾向于支持 setf 而不是 setaf.)color_prompt=是别的颜色提示=菲菲如果 [ "$color_prompt" = yes ];然后PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$'别的PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '菲取消设置 color_prompt force_color_prompt# 如果这是一个 xterm 将标题设置为 user@host:dir案例$TERM"在xterm*|rxvt*)PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1";;*);;esac# 启用 ls 的颜色支持并添加方便的别名if [ -x/usr/bin/dircolors ];然后test -r ~/.dircolors &&eval "$(dircolors -b ~/.dircolors)" ||eval "$(dircolors -b)"别名 ls='ls --color=auto'#alias dir='dir --color=auto'#alias vdir='vdir --color=auto'别名 grep='grep --color=auto'别名 fgrep='fgrep --color=auto'别名 egrep='egrep --color=auto'菲# 还有一些 ls 别名别名 ll='ls -alF'别名 la='ls -A'别名 l='ls -CF'# 为长时间运行的命令添加警报"别名.像这样使用:# 睡眠 10;警报alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'# 别名定义.# 您可能希望将所有添加的内容放入一个单独的文件中,例如# ~/.bash_aliases,而不是直接在这里添加.# 查看bash-doc包中的/usr/share/doc/bash-doc/examples.如果 [ -f ~/.bash_aliases ];然后.~/.bash_aliases菲# 启用可编程完成功能(您不需要启用# 这个,如果它已经在/etc/bash.bashrc 和/etc/profile 中启用# 来源/etc/bash.bashrc).如果 [ -f/etc/bash_completion ] &&!shopt -oq posix;然后./etc/bash_completion菲

所以,我真的不知道如何让它工作......

感谢帮助!

谢谢

解决方案

您需要

通过添加类似的行将 rvm 添加到您的 .bashrc

[[ -s "$HOME/.rvm/scripts/rvm";]] &&源$HOME/.rvm/scripts/rvm";# 将 RVM 加载到 shell 会话中*作为函数*

<块引用>

这将允许您在开始新的 bash 会话时加载 rvm

当你想要一个新的导轨时创建一个新的 Gemset.

工作流程应该是这样的

$ mkdir new_rails_app$ cd new_rails_app$ vim .rvmrc# 编辑 .rvmrc 以使用正确的 Gemset 类似rvm 使用 ruby​​-1.9.2-p180@new_rails_app --create#保存并退出vim$ rvm rvmrc 加载# 您应该会看到 Gemset 已加载的提示$ gem 安装导轨$ 导轨新.

您现在有一个使用 rvm 的新应用程序的工作 rails 目录.还有其他一些小技巧,比如自动加载你的 rvmrc,但我只是为了最简单"的缘故而忽略了它.路线.

I just installed ubuntu, and after that I wanted to install RVM with ruby and rails 3.1.

Installations went fine but when I want to create a rails app it can't find the rails command.

I know I can create an alias, but when rvm changes its gemset, the alias-path would be wrong right?

This is my .bashrc file (/home/user/.bashrc):

# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

# don't put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoredups:ignorespace

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
    xterm-color) color_prompt=yes;;
esac


[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"


# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
    # We have color support; assume it's compliant with Ecma-48
    # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
    # a case would tend to support setf rather than setaf.)
    color_prompt=yes
    else
    color_prompt=
    fi
fi

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
fi

# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

# Add an "alert" alias for long running commands.  Use like so:
#   sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
    . /etc/bash_completion
fi

So, I don't really know how to get this to work...

Help is appreciated!

Thanks

解决方案

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.

这篇关于未找到 Ubuntu RVM Rails bash 命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆