bash .profile 无法在 mac 终端上工作
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19759272/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
.profile not working from terminal in mac
提问by user2950933
I had a .profile file that I was reading and using aliases from in my terminal, but at some point the aliases stopped working for no clear reason (other commands were still working).
我有一个 .profile 文件,我正在从我的终端读取和使用别名,但在某些时候别名没有明确的原因停止工作(其他命令仍在工作)。
Thinking to make a quick fix, I deleted (rm) and recreated my .profile file in my user directory. There are no bash_profiles or others in existence that I can see, at leasts in that directory.
为了快速修复,我删除了 (rm) 并在我的用户目录中重新创建了我的 .profile 文件。至少在该目录中,我看不到 bash_profiles 或其他文件。
The new .profile did not work. I tried restarting the terminal and the computer.
新的 .profile 不起作用。我尝试重新启动终端和计算机。
Now, the commands that worked in the original .profile are still run although I cannot find the file, and the new .profile gives:
现在,虽然我找不到文件,但在原始 .profile 中工作的命令仍在运行,而新的 .profile 给出:
No such file or directory(last half of a filename sourced here) and: command not found messages
没有这样的文件或目录(文件名的后半部分来自此处)和:命令未找到消息
The .profile file only contains path updates, aliases, and files to source. Trying to source the .profile file also gives the error messages above.
.profile 文件仅包含路径更新、别名和源文件。尝试获取 .profile 文件也会给出上面的错误消息。
However, typing in the path updates, aliases, and files to source directly into the terminal by copying them from the .profile file works fine.
但是,通过从 .profile 文件中复制路径更新、别名和文件直接输入到终端中,可以正常工作。
Help?
帮助?
回答by r3mainer
Perhaps you have a .bash_profile
or .bash-login
file in your home directory and it's being read in preference to your .profile
settings?
也许您的主目录中有一个.bash_profile
或.bash-login
文件,并且它优先于您的.profile
设置被读取?
Take a look here: How to make OS X to read .bash_profile not .profile file
回答by Gaurav Tyagi
Try this
尝试这个
echo "source ~/.profile" >> .bash_profile
回答by TacoEater
I installed Android studio and some development tools and it added an empty .bash_profile file in my home directory. rm ~/.bash_profile
solved the problem, just make sure that there is nothing you need in it.
我安装了 Android Studio 和一些开发工具,它在我的主目录中添加了一个空的 .bash_profile 文件。rm ~/.bash_profile
解决了问题,只需确保其中没有您需要的东西。
.bash_profile is a hidden file so try to run it and it would tell you if it exists or not.
.bash_profile 是一个隐藏文件,所以尝试运行它,它会告诉你它是否存在。
回答by Fish Yu
For me, there were no .bash_profile or .bash-login files either. The problem I found was OZH. OZH using .zshrc, adding "source ~/.profile" in that file solved my problem.
对我来说,也没有 .bash_profile 或 .bash-login 文件。我发现的问题是 OZH。OZH 使用 .zshrc,在该文件中添加“source ~/.profile”解决了我的问题。
回答by Cyclonecode
I encountered this problem today on a coworkers machine, I solved it by simply creating a symbolic link for my .profile
:
我今天在同事的机器上遇到了这个问题,我通过简单地为我的创建一个符号链接来解决它.profile
:
ln -s ~/.profile ~/.zprofile
回答by mvd
For me, there were no .bash_profile
or .bash-login
files, but the .profile
was still not being loaded. The issue turned out to be that the owner of the .profile
was root, instead of the current local user. Using chownfixed the issue.
对我来说,没有.bash_profile
或.bash-login
文件,但.profile
仍未加载。事实证明,问题的所有者.profile
是 root,而不是当前的本地用户。使用chown解决了这个问题。