简体   繁体   English

-bash:篡改.bash_profile后找不到命令

[英]-bash: command not found after tampering with .bash_profile

I was screwing around with my .bash_profile, and did something wrong - a fair amount of commands don't work for me anymore. 我正在调整我的.bash_profile,并做错了 - 相当多的命令对我不起作用了。

-bash: jekyll: command not found

I've tried a bunch of the stuff on stackoverflow and other sites already, but can't seem to get it working. 我已经在stackoverflow和其他网站上尝试了很多东西,但似乎无法让它工作。

Most commands are still working (cd, mv, ls, vim, git, even s3cmd), but others (rails, jekyll) are not working for some reason. 大多数命令仍在工作(cd,mv,ls,vim,git,甚至s3cmd),但其他命令(rails,jekyll)由于某种原因不能正常工作。

How I get here was I started out trying to get the command 'subl' to work, so pasted in this to command line ( via this tutorial ) 我是如何到达这里的,我开始试图让命令'subl'工作,所以粘贴到命令行( 通过本教程

$ ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl

It didn't work for me (later I'm realized it's because the app is Sublime Text, and not Sublime Text 2), but eventually found my way to a different page, that told me to open my bash_profile and paste this in. 它对我不起作用(后来我意识到这是因为应用程序是Sublime Text,而不是Sublime Text 2),但最终找到了我的方式到另一个页面,告诉我打开我的bash_profile并粘贴它。

alias subl="/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl"

Upon opening my bash_profile (vim .bash_profile), it prompted with some sort of error (I think conflicting file), so I Recovered it. 打开我的bash_profile(vim .bash_profile)后,它出现了某种错误(我认为是冲突的文件),所以我恢复了它。 After that, pasted the above in, saved and exit. 之后,粘贴上面,保存并退出。

On reloading (opened a new tab), was running into a bunch of errors and my commands were no longer working. 在重新加载(打开一个新选项卡)时,遇到了一堆错误,我的命令不再有效。 Hours later, having tried many things, this is my current status 几小时后,尝试了很多东西,这是我目前的状态

$ echo $PATH $ echo $ PATH

 /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/Users/ChrisYin/usr/bin:/Users/ChrisYin/usr/bin:/Users/ChrisYin/usr/bin:/Users/ChrisYin/usr/bin

$ open .bash_profile $ open .bash_profile

export ARCHFLAGS="-arch x86_64"
export PATH=$PATH:~/usr/bin
alias subl="/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

Eventually what I did try was deleting my .bash_profile, and reinstalled rails. 最后我尝试删除我的.bash_profile,并重新安装了rails。 I got rails and jekyll working again, but then I opened up a new tab, and none of them were working again. 我让rails和jekyll再次工作,但后来我打开了一个新标签,但没有一个再次正常工作。

Any help appreciated, thanks. 任何帮助表示感谢,谢谢。

尝试将/opt/local/bin添加到.bash_profile的路径中:

export PATH=/opt/local/bin:$PATH

More of a comment than an answer, but long quotes/code looks terrible in comments. 更多的评论而不是答案,但长的引号/代码在评论中看起来很糟糕。

Very strange that you're getting an error here, but try just hard-coding all your paths in one place. 很奇怪你在这里遇到错误,但试着在一个地方硬编码你所有的路径。 eg Change your bash_profile to 例如,将bash_profile更改为

export ARCHFLAGS="-arch x86_64"
PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/Users/ChrisYin/usr/bin:/Users/ChrisYin/usr/bin:/Users/ChrisYin/usr/bin:/Users/ChrisYin/usr/bin"
PATH="$PATH:~/usr/bin"

# Assuming your jekyll is found here
PATH="$PATH:/opt/local/var/macports/sources/rsync.macports.org/release/tarballs/ports/lang" 

export PATH

alias subl="/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

Than make sure you source it by source bash_profile or re-initalize bash. 确保您通过source bash_profile或重新初始化bash来获取它。

I would also comment out any PATH statements from any other initialization files, namely .bashrc in case it accidentally override the .bashrc ones (can't remember which one gets sourced first offhand, but better to have them in one place anyway). 我还会注释掉任何其他初始化文件中的任何PATH语句,即.bashrc ,以防它意外地覆盖.bashrc (不记得哪一个是首先得到的,但最好还是将它们放在一个地方)。

For figuring out where things got installed, easiest way would be to read whatever README/manual it has. 为了弄清楚安装的地方,最简单的方法是阅读它所拥有的任何README /手册。 Otherwise, you can search for it with something like below (locate database would be faster if you have one set up) 否则,你可以用下面的东西搜索它(如果你有一个设置,找到数据库会更快)

find / -name "jekyll"
find / -name "rails" 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM