One of my perl script uses XML::SAX module. As this script would be run from any system on the network, I am working on writing a shell script which would automatically download the module and install it in a private lib.
The script works fine but in the middle of it, this question comes up:
Checking if your kit is complete...
Looks good
Warning: prerequisite XML::SAX::Base 1.05 not found. We have 1.04.
Do you want XML::SAX to alter ParserDetails.ini? [Y]
And the program waits for user input. Is there any way to skip this?
These scripts will be run as remote jobs and the people running the jobs aren't going to be looking at the console very often.
Also, I tried working with expect, but I get the error 'spawn' not found. So I'm thinking it's not a part of the standard shell utility.
Please advise if this is possible at all.
Configure your cpan client to use follow as the prerequisites_policy. In the cpan shell, enter:
o conf prerequisites_policy follow
o conf commit
Related
I've been searching for a couple of hours and I'm coming up empty trying to find a solution. I'm using Dist::Zilla. I have a module that uses a simple config file in .ini format located in the module's share/ directory. When my module is installed, I'd like the install script to prompt the user for configuration options and save the user's options in the config file. Then, using File::UserConfig, it will copy the file over to the user's configuration directory where it can be loaded by the module when it runs.
Someone had suggested the Dist::Zilla::Plugin::MakeMaker::Custom module but I know next to nothing about MakeMaker and how I might write a custom one to kick off the configuration script.
I'm surprised I can't find anything that makes this easy to do. Perhaps I'm searching on the wrong keywords?
You had discussed this in IRC, and the gist is:
You cannot rely on the installation process allowing any interaction, as a large amount of installations are via cpanm which is non-interactive and hides output from Makefile.PL by default. This is because users don't like having to configure things, and as an example, a Carton deployment is frequently non-interactive by its nature. You can allow configuration via environment variables recognized by your Makefile.PL to get around this.
You can document to install using the --interactive option for cpanm in order to respond to prompts in your Makefile.PL, injected into the generated file using the [MakeMaker::Awesome] plugin.
You can include a script with the distribution that will set up the configuration so the user can do it themselves separate from the installation.
My app, Alambic, uses The Great Mojolicious framework, and defines commands that can be executed with e.g. $ script/alambic alambic init.
Now when I look at Joel Berger's Galileo and other great pieces of work, I find they have a system command that can be directly invoked in a shell, e.g. $ galileo init. I looked into the mojolicious doc but found nothing to do that for my app. Now I'm not even sure if it's Mojolicious or the Perl CPAN Build process that makes it possible.. Any hint would be greatly appreciated.
I'll provide the complete answer here as a complement to #simbabque 's comment.
So for a Mojolicious application, one has to make it installable (i.e. cpan-aware) in order to have the binaries copied to a directory in the path. More specifically for Alambic I had to:
Setup InstallablePaths (I decided to go for Module::Build), see the documentation for the module
Create a Build.PL file
Run the Module::Build sequence to build the module:
perl Build.PL
./Build manifest
./Build
./Build test
./Build install
During the install step, binaries are copied to a Perl-managed directory that is in the $PATH. After that step the alambic command was available as a command in my shell.
Note: For one to have her/his own commands available on the CLI, the Mojolicious application has to define one or more commands of course.
I have a series of perl scripts for which I'm writing a Makefile.PL script, but I'm rather inexperienced with ExtUtils::MakeMaker.
One of the scripts I wrote makes a system call to a command line utility that must be installed in order for the script to run properly. My script can gracefully detect that the utility is missing and issue an error about installing it and putting it in the user's path, but is there some standard way to handle this in the Makefile.PL script? Could it even gasp attempt to install the third-party utility if I enter the download link in the Makefile.PL script?
At the very least, I'd like the script to warn the user if the external dependency was not found. I know I can write a test case that uses it. Is this as simple as copying and pasting the subroutine I wrote in the script itself that checks for the third party utility and prints an error if it's not found or would that be the "wrong way to do it"?
Let's call this external dependency foobar, for sake of argument.
As per #KeepCalmAndCarryOn's comment, firstly consider whether foobar could be replaced by something from CPAN (maybe Foo::Bar), or a few lines of Perl.
Otherwise, the best course of action is:
Create a new CPAN distribution called Alien::Foobar. The job of Alien::Foobar is to download, perhaps compile, and then install foobar, as part of Alien::Foobar's Makefile.PL or Build.PL.
(There exists a module called Alien::Base which aims to make doing this sort of thing easier. It's mostly aimed at installing libraries rather than binaries, though I've had some success using it for the latter.)
Now the Makefile.PL you were originally working on can declare a dependency on Alien::Foobar.
If you have an external dependency on a command-line utility (i.e. there's no perl module that does what the utility does), ExtUtils::MakeMaker is not designed to handle such a dependency. What you need to do is write an install script or edit the make file to handle the dependency. Here are the considerations in doing so:
Check if the dependency exists and if the version is sufficient.
Download the dependent package
Configure, compile, & install the dependent package
Test to make sure it works
Update the user's environment setup if necessary
Run your perl package's installation steps (e.g. perl makefile.PL;make;sudo make install)
Note, you may need to know whether your script is running as root or not, which you can verify using id -u to check if the user ID is root (i.e. '0').
I'm trying to install some perl modules as part of the set up for Circos. I'm installing the modules using cpan in terminal, and while the initial set up seems to go well, all the modules fail during the final step of the install, when the Makefile is being written.
Here's what the error looks like:
Checking if your kit is complete...
Looks good
Writing Makefile for Font::TTF
Can't exec "make": No such file or directory at /System/Library/Perl/5.12/CPAN/Distribution.pm line 2026.
MHOSKEN/Font-TTF-1.02.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
Failed during this command:
MHOSKEN/Font-TTF-1.02.tar.gz : make NO
I think the only option might be to manually install the modules instead of using cpan, but I figured it might be worth a shot to put up a question here.
It seems that /System/Library/Perl/5.12/CPAN/Distribution.pm is trying to find your system's "make" command. Since you're using Mac OS/X is "make" actually installed or do you need to add some developer tools?
To further on G. Cito's answer/question:
This old answer might do the trick for you, if you're on Mac OS/X, as the exact same error is thrown in the respective circumstances:
https://stackoverflow.com/a/6767528/2352071
I inherited a project which is supposed to be able to be deployed to other servers. This project has a number of simple module dependencies which however might not be present on all target machines.
As such I'd like to be able to run a single command line script that checks which Perl modules are installed and tries to automatically install missing ones via CPAN.
Since this should be very basic (i.e. needing to install stuff to run the module installer would defeat the point) said script should only use Perl 5.8.8 core modules.
Does something like that exist already or would i need to write it myself?
Creating a Bundle package is one possible answer.
You can then look at something like CPAN::Shell (see CPAN module) to automate the process.
/I3az/
Update re: brian's comment about Task:: - Here are some pertinent links:
Writing a CPAN Task (using Module::Install)
"Task:: or Bundle::"? (Perlmonks)
Use Module::Install, it will be bundled with your module/program. You can use "auto_install" command to automatically install dependencies.