2

I've been trying to install WWW::Mechanize::Firefox through CPAN and I am having trouble installing the dependency MozRepl. The installation goes through but the tests all fail, and when I force install it and run my perl script, I run into an error

Failed to connect to ,  at /Library/Perl/5.12/MozRepl/RemoteObject.pm line 467.

SO I uninstalled MozRepl and looked at the tests I get the following errors in the log:

#   Failed test at t/10-plugin-repl-enter.t line 11.
Can't locate object method "repl_enter" via package "MozRepl" at t/10-plugin-repl-enter.t line 12.

...

#   Failed test at t/20-plugin-json.t line 16.
Can't locate object method "json" via package "MozRepl" at t/20-plugin-json.t line 17.

#   Failed test at t/19-plugin-repl-util-doc_for.t line 14.
Can't locate object method "repl_doc_for" via package "MozRepl" at t/19-plugin-repl-util-doc_for.t line 16.

#   Failed test at t/18-plugin-repl-util-help_url_for.t line 14.
Can't locate object method "repl_help_url" via package "MozRepl" at t/18-plugin-repl-util-help_url_for.t line 16.

etc..

I am running on Mac OSX 10.8.4, 4 GB Ram 2.5 Ghz, Perl version 5.12. Does anybody have any idea what is causing these errors?

UPDATE: i reinstalled mozrepl, and now I get this error when i run my script:

Failed to connect to , problem connecting to "localhost", port 4242: Connection refused at /Users/thui/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/MozRepl/Client.pm line 144
Tim Hui
  • 125
  • 1
  • 10
  • Do you use [cpanm](https://metacpan.org/pod/release/MIYAGAWA/App-cpanminus-1.7001/bin/cpanm)? If not it could help you with dependencies versions. – smonff Dec 28 '13 at 15:02
  • I'm not sure, but you might need an older version of MozRepl (the firefox addon). I think there have been breaking changes in the API that haven't made it to MozRepl (the perl Package). – David-SkyMesh Dec 30 '13 at 00:05
  • I just installed the MozRepl addon on firefox to no avail. And yes I am using cpanm. I just upgraded my version of Perl to 5.16 to no avail as well. – Tim Hui Dec 30 '13 at 08:23
  • I've created an answer with a working recipe below. I installed Debian 7 on a new VM, installed Firefox, installed CPANminus via `cpan`, then followed the recipe. – David-SkyMesh Dec 30 '13 at 12:33
  • Didn't see your update there. If it says `problem connecting to "localhost", port 4242: Connection refused` that means that MozRepl (the Firefox addon) isn't running IN FIREFOX. See the instructions in my answer for how to properly install and configure MozRepl (the Firefox addon). – David-SkyMesh Jan 03 '14 at 02:52

1 Answers1

1

This works for me with perl 5.10 or later, latest Firefox (26 as of writing) and Mozrepl from github.

At command propmpt:

(1) Download MozRepl and build the XPI file (Firefox extension):

git clone git://github.com/bard/mozrepl
cd mozrepl
zip -r ../mozrepl.zip *
cd ..
mv mozrepl.zip mozrepl.xpi

(2) Install the extension in Firefox via about:addons [Install from file].

In Firefox:

(3) Menu->Tools->Mozrepl->Activate On Startup

(4) Menu->Tools->Mozrepl->Start

At command propmpt:

(5) which firefox

Make sure the firefox executable (or your OS's wrapper script) is in $PATH - you should get some output!

(6) cpanm WWW::Mechanize::Firefox

(7) Test it!

At this point, if CPANminus reports no errors then WWW::Mechanize::Firefox should be working. The first example from the synopsis is a good test:

#!/usr/bin/perl
use WWW::Mechanize::Firefox;
my $mech = WWW::Mechanize::Firefox->new();
$mech->get('http://google.com');

That assumes MozRepl is listening on port 4242 (check in Menu->Tools->Mozrepl->Change Port). You can also change the port from the perl side; see options for ->new().

(8) cpanm HTML::Display::Common

I found that bcat.pl from the examples required this module, but it wasn't installed as a dependency.

David-SkyMesh
  • 5,041
  • 1
  • 31
  • 38
  • hello - i need to re-work your recipe for the OpenSuse version 13.1. I try to install Mecha :: FireFox for a long long time now. All fails. – zero Jun 26 '14 at 15:45