Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Using File::ShareDir in development

by willymacoy (Acolyte)
on Apr 18, 2011 at 10:24 UTC ( [id://899913]=perlquestion: print w/replies, xml ) Need Help??

willymacoy has asked for the wisdom of the Perl Monks concerning the following question:

From my questions tonight, you can guess what I have been doing. Here is another question about developing modules. Thanks for any ideas in advance.

I can install any shared files (from the ./share directory and installed using Module::Install::Share) onto my system and access them at runtime using File::ShareDir. That, I understand.

However, while I am developing my module it remains uninstalled but it still needs access to these files (in ./share remember). But that directory is not registered anywhere as a shared directory and is thus not accessible using File::ShareDir.

Given this, does anyone know how I would access the shared files in development using the same code that will be deployed?

Replies are listed 'Best First'.
Re: Using File::ShareDir in development
by Anonymous Monk on Apr 18, 2011 at 11:08 UTC
    Given this, does anyone know how I would access the shared files in development using the same code that will be deployed?

    Install the module
    set PERL_MB_OPT=--install_base /home/user/devstuff set PERL_MM_OPT=INSTALL_BASE=/home/user/devstuff
    cpanp i Mo::Dule
    cpan  Mo::Dule
    perl Build.PL --install_base /home/user/devstuff
    perl Makefile.PL  INSTALL_BASE=/home/user/devstuff
    Then use it
    set PERL5LIB=/home/user/devstuff/lib/perl5
    use lib '/home/user/devstuff/lib/perl5';
      Except this doesn't actually solve the problem. If you are writing tests that rely on finding files in the shared directory, when an end user attempts to install the module, they are going to get errors on these tests that the shared directory cannot be found. The tests are going to fail until the module is installed. So unless you write specific instructions that the user needs to force install before testing... A clean solution that allows you to develop and install with no special instructions is ideal.

        Except ... blah ...

        Development doesn't imply "tests that rely on sharedir" :) its perfectly possible to develop this way ... sure its no File::Share (or the other longer named module) but not a big deal :)

Re: Using File::ShareDir in development
by ikegami (Patriarch) on Apr 18, 2011 at 14:52 UTC
    Or just half-install it.
    perl Makefile.PL make perl -Mblib sometest.pl
Re: Using File::ShareDir in development
by Anonymous Monk on May 07, 2019 at 22:03 UTC
    The proper way to do this is with Test::File::ShareDir. You just need an extra line of boilerplate in your test pointing to the local directory:
    use Test::File::ShareDir -share => { -dist => { 'Name-Of-Your-Dist +ribution' => 'share/somefolder' } };
    Then, normal calls to File::ShareDir::dist_dir will find the local folder, before looking in your @INC directories for the installed sharedirs.

    -ether@cpan.org

Re: Using File::ShareDir in development
by basiliscos (Pilgrim) on May 08, 2014 at 17:24 UTC
Re: Using File::ShareDir in development
by Anonymous Monk on Jun 16, 2011 at 09:20 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://899913]
Approved by anonymized user 468275
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2024-03-28 21:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found