需要在我的 bashrc 文件中为 RVM 修复 PATH [英] Need to Fix PATH in my bashrc File for RVM

查看:96
本文介绍了需要在我的 bashrc 文件中为 RVM 修复 PATH的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近对操作系统进行了全新安装,并从备份中复制了旧的 .bashrc 文件.我安装了 rvm 版本 1.26.10(最新的稳定版本).我安装了 ruby​​ 2.2.0.当我获取 .bashrc 文件时,出现以下错误:

I did a clean install of my operating system recently and copied my old .bashrc file from a backup. I installed rvm version 1.26.10 (latest stable version). I installed ruby 2.2.0. When I source the .bashrc file I get the following error:

Warning! PATH is not properly set up, '/Users/myusername/.rvm/gems/ruby-2.2.0@mygemset/bin' is not at first place,
         usually this is caused by shell initialization files - check them for 'PATH=...' entries,
         it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
         to fix temporarily in this shell session run: 'rvm use ruby-2.2.0@mygemset'.

这是我的 PATH 语句.我在这里包含的第一行是 .bash_profile 文件中新安装的 RVM 中的一行.我将它们复制到 .bashrc 中.我还在运行 postgres.app,它需要最后一条语句才能将其设置为当前的 PostgreSQL 实例.

Here are my PATH statements. The first line I included here is one that was in the new install of RVM in the .bash_profile file. I copied them into .bashrc. I'm also running postgres.app which requires the last statement in order to set it as the current PostgreSQL instance.

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
PATH="$PATH:$HOME:/.rvm/rubies/ruby-2.2.0/bin/ruby:/usr/bin/psql:/usr/local:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
export PATH="$PATH:$HOME/.rvm/bin"
export PATH=/Applications/Postgres.app/Contents/Versions/9.4/bin:$PATH

我从 Michael Hartl 的 Ruby on Rails 教程推荐的 .bashrc 文件(2011 年或 2012 年的当前版本)和当时 RVM 使用的设置开始.我知道从那以后事情发生了一些变化.

I started with the .bashrc file recommended by the Ruby on Rails Tutorial by Michael Hartl (the version current in 2011 or 2012) and the settings used by RVM back then. I know things have changed a bit since then.

我的 bash 知识有限,因此不胜感激.

My bash knowledge is limited so any help would be appreciated.

更新:2015 年 2 月 2 日下午 2:40 CST

UPDATE: 2/2/2015 2:40 pm CST

我将我的 bash 语句更改为以下内容并消除了警告:

I changed my bash statements to the following and got rid of the warning:

export PATH="$PATH:$HOME/.rvm/bin"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
PATH="$PATH:$HOME:/.rvm/rubies/ruby-2.2.0/bin/ruby:/Applications/Postgres.app/Contents/Versions/9.4/bin:/usr/bin/psql:/usr/local:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"

更新:2015 年 2 月 2 日下午 5:14 CST

UPDATE: 2/2/2015 5:14 pm CST

这是我的 Bash 语句:

Here are my Bash statements:

PATH="$PATH:$HOME:/.rvm/rubies/ruby-2.2.0/bin/ruby:/Applications/Postgres.app/Contents/Versions/9.4/bin:/usr/bin/psql"
export PATH="$PATH:$HOME/.rvm/bin"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

这是 echo $PATH 的输出:

Here is the output for echo $PATH:

/Users/username/.rvm/gems/ruby-2.2.0@gemsetname/bin:/Users/username/.rvm/gems/ruby-2.2.0@global/bin:/Users/username/.rvm/rubies/ruby-2.2.0/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Applications/Server.app/Contents/ServerRoot/usr/bin:/Applications/Server.app/Contents/ServerRoot/usr/sbin:/Users/username/.rvm/bin:/Users/username:/.rvm/rubies/ruby-2.2.0/bin/ruby:/Applications/Postgres.app/Contents/Versions/9.4/bin:/usr/bin/psql:/Users/username/.rvm/bin

推荐答案

rvm 期望 $PATH 的内容在 $PATH 中排在第一位.您应该将项目添加到 $PATH 之前 采购 rvm,而不是之后.

rvm expects its $PATH stuff to come first in $PATH. You should add items to the $PATH before sourcing rvm, not after.

这篇关于需要在我的 bashrc 文件中为 RVM 修复 PATH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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