在lion系統下使用sudo /Users/papabox/Downloads/cocos2d-iphone-2.0-rc1/install-templates.sh -f 命令安裝新版本cocos2d(cocos2d 2.0-rc1)的時候總是返回以下資訊:
1 cocos2d-iphone template installer 2 3 Error: Do not run this script as root. 4 5 'root' is no longer supported 6 7 RECOMMENDED WAY: 8 /Users/papabox/Downloads/cocos2d-iphone-2.0-rc1/install-templates.sh -f
在網上搜尋後發現已經有哥們(博文地址:http://hulefei29.iteye.com/blog/1493653)找出是 install-templates.sh 檔案中以下代碼判斷root許可權有問題
1 # Make sure root is not executed 2 if [[ "$(id -u)" == "0" ]]; then 3 echo "" 4 echo "Error: Do not run this script as root." 1>&2 5 echo "" 6 echo "'root' is no longer supported" 1>&2 7 echo "" 8 echo "RECOMMENDED WAY:" 1>&2 9 echo " $0 -f" 1>&2 10 echo "" 11 exit 1 12 fi
只要將這段判斷root的指令碼代碼刪除掉就好。
然後使用命令 sudo /Users/papabox/Downloads/cocos2d-iphone-2.0-rc1/install-templates.sh -f 進行安裝,如果出現輸入password的話,就輸入password,然後就可以正常安裝了!
PS:/Users/papabox/Downloads/cocos2d-iphone-2.0-rc1/install-templates.sh 是我的路徑。需要將此替換成自己的路徑。
參考博文地址:http://hulefei29.iteye.com/blog/1493653