Mac

我無法在 macbook 上 cd “LaunchAgents”

  • January 12, 2011

在我的 macbook-pro 上安裝 mongdb 後,它告訴我:

如果這是您的第一次安裝,請在登錄時自動載入:

cp /usr/local/Cellar/mongodb/1.6.3-x86_64/org.mongodb.mongod.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/org.mongodb.mongod.plist

如果這是升級並且您已經載入了 org.mongodb.mongod.plist:

launchctl unload -w ~/Library/LaunchAgents/org.mongodb.mongod.plist
cp /usr/local/Cellar/mongodb/1.6.3-x86_64/org.mongodb.mongod.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/org.mongodb.mongod.plist

或者手動啟動它:

mongod run --config /usr/local/Cellar/mongodb/1.6.3-x86_64/mongod.conf

但是在我複製org.mongodb.mongod.plist到之後~/Library/LaunchAgents,它告訴我:

launchctl load -w ~/Library/LaunchAgents/org.mongodb.mongod.plist
launchctl: Couldn't stat("/Users/why/Library/LaunchAgents/org.mongodb.mongod.plist"):
Not a directory

而且我不能cd "~/Library/LaunchAgents",但我可以ls目錄!

~/Library/LaunchAgents是mac上的一個奇怪目錄。

您是否確保首先創建了~/Library/LaunchAgents目錄?您可能剛剛複製/usr/local/Cellar/mongodb/1.6.3-x86_64/org.mongodb.mongod.plist到一個名為~/Library/LaunchAgents

試著ls -la ~/Library/LaunchAgents看看輸出是什麼。它應該看起來像:

[why@why ~]$ ls -la ~/Library/LaunchAgents
total 40
drwxr-xr-x   7 why  why   238 Jan 11 09:47 .
drwx------+ 68 why  why  2312 Sep 28 19:39 ..
-rw-r--r--   1 why  why   543 Jan 11 09:47 org.mongodb.mongod.plist

相反,如果您看到:

[why@why ~]$ ls -la ~/Library/LaunchAgents 
-rw-r--r--  1 why  why  543 Jan 11 09:47 /Users/why/Library/LaunchAgents

然後將 MongoDB plist 複製到一個名為LaunchAgents. 以下是解決方法:

rm ~/Library/LaunchAgents
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/mongodb/1.6.3-x86_64/org.mongodb.mongod.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/org.mongodb.mongod.plist

引用自:https://serverfault.com/questions/221469