17

I am trying to use the po2json parser/converter from the JS gettext library (http://jsgettext.berlios.de/), but when I try to convert I get this error:

Can't locate JSON.pm in @INC (@INC contains: /Library/Perl/5.12/darwin-thread-multi-2level /Library/Perl/5.12 /Network/Library/Perl/5.12/darwin-thread-multi-2level /Network/Library/Perl/5.12 /Library/Perl/Updates/5.12.4 /System/Library/Perl/5.12/darwin-thread-multi-2level /System/Library/Perl/5.12 /System/Library/Perl/Extras/5.12/darwin-thread-multi-2level /System/Library/Perl/Extras/5.12 .) at ./po2json line 23.
BEGIN failed--compilation aborted at ./po2json line 23.

As far as I understand I am missing a perl module, namely JSON.pm, an I think it's this one: http://cpansearch.perl.org/src/MAKAMAKA/JSON-2.53/lib/JSON.pm

Now, how do I install it on OSX? I am using Mountain Lion.

I tried to do cpan install JSON, but it doesn't work, I get the following error:

Writing Makefile for JSON
  MAKAMAKA/JSON-2.53.tar.gz
  make -- NOT OK
'YAML' not installed, will not store persistent state
Running make test
  Can't test without successful make
Running make install
  Make had returned bad status, install seems impossible
LeoNerd
  • 8,344
  • 1
  • 29
  • 36
ragulka
  • 4,312
  • 7
  • 48
  • 73

6 Answers6

38

Use homebrew to install cpanm:

brew install cpanm

Then you can install JSON with

sudo cpanm install JSON

Gabe Kopley
  • 16,281
  • 5
  • 47
  • 60
Gavin
  • 4,273
  • 3
  • 27
  • 39
11

The output said that make didn't return success. Probably due to some dependency. Try using cpanm http://search.cpan.org/~miyagawa/App-cpanminus-1.5017/bin/cpanm, it's really hassle free and bootstrapped quite well (no need to install other stuff).

Install using this:

curl -L http://cpanmin.us | perl - --sudo App::cpanminus

Mike Rossi
  • 291
  • 2
  • 3
  • I tried to install using your command, but got this error: `! Can't configure the distribution. You probably need to have 'make'. See /Users/ragulka/.cpanm/build.log for details.` The log file has this: `Finding PREREQ from Makefile ... Checking if you have ExtUtils::MakeMaker 6.31 ... Yes (6.56) Checking if you have Module::Build 0.36 ... Yes (0.3603) Checking if you have ExtUtils::Install 1.46 ... Yes (1.55) -> FAIL Can't configure the distribution. You probably need to have 'make'.` – ragulka Aug 20 '12 at 07:05
  • Do you have `make` installed? You'll need it to install perl modules. – Mike Rossi Aug 20 '12 at 07:06
  • Found it :) On Mac OS X those command line tools come with the Apple developer tools. You can get those at their site http://developer.apple.com/ – Mike Rossi Aug 20 '12 at 07:07
  • Thnaks, I'll install them and see what happens then :) – ragulka Aug 20 '12 at 07:10
  • I installed XCode (Developer Tools) and tried running cpanm, it wasnät found, tried to run your install command, and it still did not work. Any ideas? – ragulka Aug 20 '12 at 10:33
  • 3
    Ah, I figured it out. I had to Open Developer Tools, go to Preferences -> Downloads and then install Command Line Tools. After that, I just had to do "sudo cpan App::cpanminus" in my Terminal – ragulka Aug 20 '12 at 10:45
  • You need the XCode [command line tools](https://developer.apple.com/downloads/index.action) (Apple really make this a pain). – Quentin Aug 20 '12 at 10:45
7

cpan install JSON Having the JSON in all caps made it work for me.

Neza
  • 117
  • 1
  • 7
3

I know this is an old topic, but wanted to share my solution after finding that I needed JSON when trying to use zap2xml (perl based). I was getting the error: "Can't locate JSON.pm in @INC..." after installing perl via Homebrew.

This is how I installed JSON via Homebrew. I will also include the steps required to install Homebrew (for those who would like to know). ;)

Prerequisites:

Install Xcode from the App Store (Download):

https://itunes.apple.com/us/app/xcode/id497799835

Install Command Line Tools for Xcode (Run in Terminal):

xcode-select --install

Install Homebrew (Run in Terminal):

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Update Homebrew (Run in Terminal):

brew update

brew upgrade

brew doctor (correct issues found by brew doctor. Instructions will be given by The Doctor. :P)

Install cpanminus (Run in Terminal):

brew install cpanm

Check perl (Run in Terminal):

which perl

perl -V (with a capital -V)

Check/Install JSON module (Run in Terminal):

sudo cpanm -v JSON

DONE.

2

Following worked for me:
Run on terminal:
sudo perl -MCPAN -e shell

you should get the cpan shell prompt and run below commond at cpan shell:

cpan[1]> install JSON

Regards,
Anand Choubey

Andy
  • 338
  • 3
  • 10
-4

this way is OK, Follows the Command:sudo apt-get install libjson-perl

Shiva Saurabh
  • 1,281
  • 2
  • 25
  • 47
OiSoft
  • 1
  • 1