How can I get rid of something running on every new terminal session?

…衆ロ難τιáo~ 提交于 2019-12-03 07:47:22

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.

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)...

zhihong

In Ubuntu 12.04, by default, the /etc/profile.d/rvm.sh will not be loaded when starting a new terminal. So every time, when starting a new termail, cmd as follows must be used to start rvm:

source /etc/profile.d/rvm.sh

And there are two ways to fix it:

  1. open a new terminal-> right click and select Profiles->Profile Preferences->Title and Command->select "Run command as a login shell".

  2. open a new terminal->run cmd as follows then the /etc/profile.d/rvm.sh will be auto loaded in a new terminal:

    echo '[[ -s "/etc/profile.d/rvm.sh" ]] && . "/etc/profile.d/rvm.sh" # Load RVM function' >> ~/.bashrc

As some explanation here to say the 1st solution is not a nice one but the 2nd is suggested.

So in other way round, if you do not want the terminal to run something in a new terminal, you need to check whether the auto load is coursed by the two ways:

  1. check whether the "Run command as a login shell" is selected and unselect it.

  2. open the ~/.bashrc file ,find the lines related loading the function and delete it.

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.

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.

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.

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

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