我无法在 MacBook 上 cd“LaunchAgents”

我无法在 MacBook 上 cd“LaunchAgents”

在我的 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 上的一个奇怪的目录。

答案1

你确定你~/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

相关内容