How can I get rid of something running on every ne

2019-03-20 13:31发布

I am using Lion. I have an error that outputs on every new terminal session:

-bash: __rvm_add_to_path: command not found

It's an almost brand new user account.. RVM is installed on the other account on the machine.. ~/.bashrc & ~/.bash_profile are both blank.. the out put of env is:

TERM_PROGRAM=Apple_Terminal
SHELL=/bin/bash
TERM=xterm-256color
TMPDIR=/var/folders/ry/8zsyknmx7dj4_2zzvn1n71500000gn/T/
Apple_PubSub_Socket_Render=/tmp/launch-jsfKPw/Render
TERM_PROGRAM_VERSION=303
TERM_SESSION_ID=3EBC0F1A-9867-41E5-8873-75E84B9F712F
USER=incorvia
COMMAND_MODE=unix2003
SSH_AUTH_SOCK=/tmp/launch-ZQqgPj/Listeners
Apple_Ubiquity_Message=/tmp/launch-u3d1lp/Apple_Ubiquity_Message
__CF_USER_TEXT_ENCODING=0x1F5:0:0
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin
PWD=/bin
LANG=en_US.UTF-8
HOME=/Users/incorvia
SHLVL=1
LOGNAME=incorvia
DISPLAY=/tmp/launch-0B0I8s/org.x:0
_=/usr/bin/env

I see nothing related to RVM here.. where else can I look?

=====

/etc/bashrc

# System-wide .bashrc file for interactive bash(1) shells.
if [ -z "$PS1" ]; then
   return
fi

PS1='\h:\W \u\$ '
# Make bash check its window size after a process completes
shopt -s checkwinsize
# Tell the terminal about the working directory at each prompt.
if [ "$TERM_PROGRAM" == "Apple_Terminal" ] && [ -z "$INSIDE_EMACS" ]; then
    update_terminal_cwd() {
        # Identify the directory using a "file:" scheme URL,
        # including the host name to disambiguate local vs.
        # remote connections. Percent-escape spaces.
        local SEARCH=' '
        local REPLACE='%20'
        local PWD_URL="file://$HOSTNAME${PWD//$SEARCH/$REPLACE}"
        printf '\e]7;%s\a' "$PWD_URL"
    }
    PROMPT_COMMAND="update_terminal_cwd; $PROMPT_COMMAND"
fi

=========

Fixed...

In the bottom of my /etc/profile it was sourcing /etc/profile.d/rvm.sh

Don't know how that got there...

标签: bash rvm
7条回答
我只想做你的唯一
2楼-- · 2019-03-20 13:52

In your /etc/profile change the line:

source /etc/profile.d/rvm.sh

into:

if [ "${SHELL}" != "/bin/sh" ]; then
  source /etc/profile.d/rvm.sh
fi

Why?

In Mac OS X the default shell of superuser (root) is a POSIX shell, not a pure Bash. Adding such condition will disable rvm for (possibly) emerygency shell /bin/sh, used by system administrator. That is good. If you would like to install something using root's account, you can always type bash and then rvm … in a command line.

查看更多
何必那么认真
3楼-- · 2019-03-20 13:53

if you have ZSH or OH-MY-ZSH, then you need to remove source /etc/profile.d/rvm.sh from /etc/zprofile

查看更多
虎瘦雄心在
4楼-- · 2019-03-20 13:54

Bash loads a series of files during startup. A good overview of the bash startup process can be found here.

Generally, the global settings, /etc/profile, /etc/bashrc, and the associated personalized settings, ~/.profile and ~/.bashrc are loaded, although that is slightly distribution-dependant (and on Mac OS X, for example, by default /etc/profile doesn't exist).

From the RVM Installation page:

Multi-User:

The rvm function will be automatically configured for every user on the system if you install as root. This is accomplished by loading /etc/profile.d/rvm.sh on login. Most Linux distributions default to parsing /etc/profile which contains the logic to load all files residing in the /etc/profile.d/ directory. Once you have added the users you want to be able to use RVM to the rvm group, those users MUST log out and back in to gain rvm group membership because group memberships are only evaluated by the operating system at initial login time.

I'd guess that the other use has installed in Multi-User mode; /etc/profile probably loads /etc/profile.d/rvm.sh.

To stop it being loaded, you could remove the source RVM line from /etc/profile - this will stop it being loaded for all users, though.

查看更多
beautiful°
5楼-- · 2019-03-20 13:55

I had the same file (/etc/profile.d/rvm.sh) from a previous rvm installation. Deleting that file worked for me as well.

For the sake of being thorough, logging out of the shell seems to be required.

查看更多
我只想做你的唯一
6楼-- · 2019-03-20 14:01

Debian 6.1 scans the /etc/profile.d/ file for all .sh files and includes them, so there's no listing for rvm in any of the profiles or .bashrc files anywhere. Deleting rvm.sh from /etc/profile.d/ solves this.

查看更多
劫难
7楼-- · 2019-03-20 14:03

For the account that had a working profile, I had the following .rvmrc:

root@sc-27617:~# cat .rvmrc 
export rvm_prefix="/usr/local/lib/sc"
export rvm_path="/usr/local/lib/sc/rvm"

To get the error to go away for my other accounts, I simply copied this file to the other accounts and fixed the permissions (chown johndoe:johndoe /home/johndoe/.rvmrc)...

查看更多
登录 后发表回答