无法安装JSON / XS.pm

时间:2017-02-20 21:30:01

标签: perl

我得到了:

Can't locate JSON/XS.pm in @INC (you may need to install the JSON::XS module)
(@INC contains:
/usr/local/lib/perl5/site_perl/5.24.1/darwin-2level
/usr/local/lib/perl5/site_perl/5.24.1
/usr/local/lib/perl5/5.24.1/darwin-2level
/usr/local/lib/perl5/5.24.1
.
) at get.pl line 13.

(为了便于阅读,添加了换行符。)

我尝试使用cpan安装此模块并收到以下消息:

Can't write to cpanm home '/Users/sa/.cpanm': You should fix it with chown/chmod first.

我想知道在什么地方和哪里找到它来解决它?

$ ls -al ~/.cpanm
total 16
drwxr-xr-x   5 root staff  170 Feb 20 10:37 .
drwxr-xr-x+ 50 sa   staff 1700 Feb 20 13:51 ..
lrwxr-xr-x   1 root staff   51 Feb 20 10:37 build.log -> /Users/sa/.cpanm/work/1487615857.2117/build.log
lrwxr-xr-x   1 root staff   41 Feb 20 10:37 latest-build -> /Users/sa/.cpanm/work/1487615857.2117
drwxr-xr-x   4 root staff  136 Feb 20 10:37 work

1 个答案:

答案 0 :(得分:2)

您在某个时间点sudo cpanm,并且它在您的主目录中创建了属于root而不是sa的文件。修正:

sudo chown -R sa:staff ~/.cpanm

将来,请使用cpanm --sudo代替sudo cpanm来避免此问题。 (它还避免在必要时使用root。)