2017-11-10 254 views
0

我最近安裝了Ruby版本管理器(RVM),並再次卸載它,使用這個「焦土」腳本:RVM的鬼魂糾纏着我

#!/bin/bash 
/usr/bin/sudo rm -rf $HOME/.rvm $HOME/.rvmrc /etc/rvmrc 
/etc/profile.d/rvm.sh /usr/local/rvm /usr/local/bin/rvm 
/usr/bin/sudo /usr/sbin/groupdel rvm 
/bin/echo "RVM is removed. Please check all .bashrc|.bash_profile|.profile|.zshrc for RVM source lines and delete or comment out if this was a Per-User installation."` 

(我發現這個劇本here我也嘗試過更膽小方法如rvm imploderm -rf ~/.rvm等)

現在

$ which rvm

個回報什麼,但RVM似乎仍然存在以某種形式,因爲當我輸入

$ rvm implode

我得到的反應,具體爲:

cat: /Users/lolan/.rvm/VERSION: No such file or directory Warning! PATH is not properly set up, '/Users/lolan/.rvm/gems/ruby-2.3.1/bin' is not available. Usually this is caused by shell initialization files. Search for 'PATH=...' entries. You can also re-add RVM to your profile by running: 'rvm get stable --auto-dotfiles'. To fix it temporarily in this shell session run: 'rvm use ruby-2.3.1'. To ignore this error add rvm_silence_path_mismatch_check_flag=1 to your ~/.rvmrc file. -bash: /Users/lolan/.rvm/scripts/base: No such file or directory -bash: /Users/lolan/.rvm/scripts/functions/implode: No such file or directory Are you SURE you wish for rvm to implode? This will recursively remove /Users/lolan/.rvm and other rvm traces? (anything other than 'yes' will cancel) > Psychologist intervened, cancelling implosion, crisis avoided :)

(這時候我輸入的回報當它提示我'是'時。其他時間,我輸入'是'。)

基本上,我很迷惑$ which rvm如何返回什麼,但$ rvm implode不返回「找不到命令」。這與我認爲我對命令行的理解是相反的......

無論如何,我怎麼才能真的殺死RVM,連同它的心理學家和所有? :)

PS:我在macOS 10.12上。

==============

更新:看來,儘管已通過所有標準步驟後去除RVM(見上文),儘管刷新殼(點菜source .bash_profile,source .bashrc,source .profile),外殼仍然留着一些內存,不知何故,RVM,當我開始一個全新的外殼時就消失了。

我仍然想更好地理解shell是如何保持周圍的,因爲保留腳本文件夾的各個部分(在刪除腳本文件夾之後!?!?)對我來說似乎是危險的,違反直覺的。

回答

0

這是因爲rvm位於您的主目錄的隱藏目錄中,而不是您的PATHwhich使用與bash相同的算法在環境變量PATH中列出的目錄中搜索可執行文件或腳本。如果它沒有找到它,那麼它將不會被退回。如果你想知道如何刪除RVM there is already an answer for that。最簡單的方法是:rm -rf ~/.rvm

+0

正如我的問題所述,我已經做了'rm -rf〜/ .rvm'。您指出的鏈接也已經在我的問題中引用。無論如何,我只是再次檢查一下'rm〜/ .rvm'不會改變結果。下次請仔細閱讀該問題。 – Labrador

+0

順便說一句,如果'〜/ .abc'是一個隱藏文件夾,在命令行輸入'abc xyz'會發送shell在〜/ .abc目錄下尋找腳本「xyz」somwhere?即使〜/ .rvm文件夾仍然存在(它不是),我不明白「rvm」將被視爲可執行命令的機制......你能解釋一下嗎? – Labrador

+1

檢查[二進制與功能模式](https://rvm.io/workflow/scripting)。rvm作爲shell函數加載。 – anothermh