ruby -bash: /Users/myname/.bash_profile: 权限被拒绝
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23503817/
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
-bash: /Users/myname/.bash_profile: Permission denied
提问by Zel
I installed rvm (ruby version manager) and it was success, but I got
我安装了 rvm(ruby 版本管理器)并且成功了,但是我得到了
WARNING: You have '~/.profile' file, you might want to load it, to do
that add the following line to '/Users/myname/.bash_profile': source
~/.profile
警告:您有“~/.profile”文件,您可能想要加载它,为此
将以下行添加到“/Users/myname/.bash_profile”: source
~/.profile
I am new to developing, terminals and all that jazz! But better late than never?!
我是开发、终端和所有爵士乐的新手!但迟到总比不到好?!
I entered into terminal:
我进入终端:
'/Users/myname/.bash_profile'
and got back the following line
并返回以下行
-bash: /Users/myname/.bash_profile: Permission denied
myname-MacBook-Pro:~ myname$
And that is where I am stuck! I need vrm for Drupal (Omega development) and want to make sure that everything is working fine. Thanks for your help.
这就是我被卡住的地方!我需要用于 Drupal(Omega 开发)的 vrm,并希望确保一切正常。谢谢你的帮助。
回答by Bobby Matson
Enter the .bash_profilefile by running this in your terminal:
.bash_profile通过在终端中运行来输入文件:
vim ~/.bash_profile
vim ~/.bash_profile
If you still get permission denied, run sudobefore the vimcommand
如果您仍然获得权限被拒绝,请sudo在vim命令之前运行
sudo vim ~/.bash_profile
sudo vim ~/.bash_profile
From there, add the text source ~/.profileto .bash_profile, then hit :wqon your keyboard to save and close the file. Opening a new terminal window should remove the error.
从那里,将文本添加source ~/.profile到.bash_profile,然后敲击:wq键盘以保存并关闭文件。打开一个新的终端窗口应该可以消除错误。
回答by that other guy
Entering a filename will try to execute it. Instead, you want to edit it.
输入文件名将尝试执行它。相反,您想要编辑它。
Open TextEdit (or your favorite editor) and open the file /Users/myname/.bash_profilein it.
打开 TextEdit(或您最喜欢的编辑器)并/Users/myname/.bash_profile在其中打开文件。
You can do this entirely through the UI, but if you want, you can start an editor from the terminal:
您可以完全通过 UI 执行此操作,但如果您愿意,也可以从终端启动编辑器:
open -a TextEdit /Users/myname/.bash_profile
You can then add the line source ~/.profileto the file and save it.
然后,您可以将该行添加source ~/.profile到文件中并保存。
Close the terminal and open it again to apply the changes.
关闭终端并再次打开它以应用更改。
回答by Anatoly
you must relogin next. If you add .profile
下次必须重新登录。如果添加 .profile
export PATH+=:$HOME/bin
without .bash_profile as I do all time you'll insert ~/bin search dir not the end of PATH and in middle. So .profile call before local profile formed and some others system dirs will be added after. It's bad so priority for you home binaries will higher then some system one. And may change undesired behavior with same names. So you need to add PATH in .bash_profile, not to .profile It's guarantee to add your home bin dir at the end of PATH. But don't delete ~/.profile at all. It's need to add some other data. This file call once at first login and .bash_profile call every time when second login with su without -l and then return back. If don't bother You will get two home bin dirs in PATH, next tree and so on. It's not well. So you must correct like that:
没有 .bash_profile 就像我一直做的那样,您将插入 ~/bin search dir 而不是 PATH 的末尾和中间。因此,在形成本地配置文件之前调用 .profile 并在之后添加其他一些系统目录。这很糟糕,因此您的家庭二进制文件的优先级将高于某些系统一。并且可能会改变具有相同名称的不良行为。所以你需要在 .bash_profile 中添加 PATH,而不是 .profile 保证在 PATH 的末尾添加你的 home bin 目录。但是根本不要删除 ~/.profile 。需要添加一些其他数据。此文件在第一次登录时调用一次,而 .bash_profile 每次在使用 su 不带 -l 的情况下第二次登录时调用一次,然后返回。如果不打扰,您将在 PATH、下一棵树等中获得两个 home bin 目录。这不好。所以你必须像这样更正:
p=:$HOME/bin && test `expr $PATH : '.*'"$p"` -gt 0 || export PATH+=$p || true
It's grantee that home bin dir will add only one independent how many times you login after change effective user with su and then return back. true at end better write so if on some unpredictable reasons error occurs in command export PATH+=$p(sometimes such occurs) your profile load stops and you can't login at all. It's grantee that this line will run with any error generate.
使用su更改有效用户后,home bin dir只会添加一个独立的登录次数,然后返回。最后最好写真,所以如果由于某些不可预测的原因在命令 export PATH+=$p 中发生错误(有时会发生这种情况),您的配置文件加载将停止并且您根本无法登录。这条线将运行时会产生任何错误,这是被授予的。

