为什么每次都需要输入bash_profile [英] Why do I need to source bash_profile every time

查看:722
本文介绍了为什么每次都需要输入bash_profile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了Hadoop,每次我想运行它时,首先我必须这样做:

  source〜/ .bash_profile 

或者它不会识别命令 hadoop

为什么会这样?



我在OSX 10.8上


现在我们已经缩小了问题的范围:


  1. 运行 在命令行中输入 ps -p $$ 来确定您实际上使用了bash shell。

  2. 意识到您在zsh中,这意味着您应该在 .zshrc 中编辑您的配置文件。

  3. 将违规行从 .bash_profile 复制到 .zsh ,或者

  4. 修改您的 .zshrc 以直接获取您的 .bash_profile

更新:执行@ TC1在注释中提到的内容,并在每个shell自己的配置文件中保留特定于shell的代码,并从这些配置文件中只保存源shell不可知的代码。


I have installed Hadoop and every time I want to run it, first I have to do this:

source ~/.bash_profile

or it won't recognize the command hadoop

Why is that?

I am on OSX 10.8

解决方案

Now that we've narrowed down the problem:

  1. Run ps -p $$ at the command line to determine that you are, in fact, using a bash shell.
  2. Realize that you are in zsh, which means you should be editing your profile in .zshrc.
  3. Copy the offending lines from .bash_profile to .zsh, OR
  4. Modify your .zshrc to directly source your .bash_profile.

UPDATE: Do what @TC1 mentions in the comments and keep the shell-specific code in each shell's own profile, and from those profiles, only source shell-agnostic code.

这篇关于为什么每次都需要输入bash_profile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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