2

I am developing a bunch of Perl scripts for my workmates and me. To ease distribution, Perl itself resides on a network path and is used from there directly using this header:

@rem = '--*-Perl-*--
@echo off
\\network\path\to\Perl\bin\perl.exe -x -S %0 %*
goto EndOfPerl
@rem ';
#!perl
#line 8
#####################################################################

This worked fine (and still does!), but a collegue needed a standalone version, so we copied the complete network installation of Perl to the local hard disk. After changing the header to use the local location we get the message:

Can't locate Tk.pm in @INC (@INC contains: C:/tools/Perl/5.16.1/lib .) at Test.cmd line 30

Now I always thought @INC was compiled into Perl. At least, it shouldn't change by simply copying Perl to another location.

There is a slight difference in Perl -V output when started locally.

Here is what I get when started from the network:

Summary of my perl5 (revision 5 version 16 subversion 1) configuration:
  Platform:
    osname=MSWin32, osvers=5.2, archname=MSWin32-x86-multi-thread
    uname=''
    config_args='undef'
    hint=recommended, useposix=true, d_sigaction=undef
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=undef, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cl', ccflags ='-nologo -GF -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 -D_CONSOLE -DNO_STRICT -DPERL_TEXTMODE_SCRIPTS -DUSE_SITECUSTOMIZE -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D_USE_32BIT_TIME_T',
    optimize='-MD -Zi -DNDEBUG -O1',
    cppflags='-DWIN32'
    ccversion='12.00.8168', gccversion='', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=8
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='__int64',
    lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf
    -libpath:"C:\Perl\lib\CORE"  -machine:x86'
    libpth=\lib
    libs=oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib  netapi32.lib uuid.lib ws2_32.lib mpr.lib
    winmm.lib  version.lib odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib
    perllibs=oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib  netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib  version.lib odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib
    libc=msvcrt.lib, so=dll, useshrplib=true, libperl=perl516.lib
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug -opt:ref,icf  -libpath:"C:\Perl\lib\CORE"  -machine:x86'


Characteristics of this binary (from libperl):
  Compile-time options: HAS_TIMES HAVE_INTERP_INTERN MULTIPLICITY
                        PERLIO_LAYERS PERL_DONT_CREATE_GVSV
                        PERL_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS
                        PERL_MALLOC_WRAP PERL_PRESERVE_IVUV PL_OP_SLAB_ALLOC
                        USE_ITHREADS USE_LARGE_FILES USE_LOCALE
                        USE_LOCALE_COLLATE USE_LOCALE_CTYPE
                        USE_LOCALE_NUMERIC USE_PERLIO USE_PERL_ATOF
                        USE_SITECUSTOMIZE
  Locally applied patches:
        ActivePerl Build 1601 [296175]
  Built under MSWin32
  Compiled at Aug 30 2012 20:08:55
  @INC:
    //network/path/to/Perl/site/lib
    //network/path/to/Perl/Perl/lib
    .

And here is the output when executed from the local drive:

<snip>
Compiled at Aug 30 2012 20:08:55
  %ENV:
    PERL_DIR="C:\tools\Perl\5.16.1"
  @INC:
    C:/tools/Perl/5.16.1/lib
    .

The site/lib part is gone! Any ideas, anyone?

frankme
  • 21
  • 1
  • Just to be clear, this is not a request for help installing Tk. The OP is expecting to see the paths to the original installation location of `perl` on the network drive in `@INC`. Tk is installed there. – ikegami Oct 04 '17 at 16:44
  • Re "*Now I always thought @INC was compiled into Perl.*", Support for building a relocatable Perl was added a while ago. It's an option that's used when building Windows binary distributions, as it allows the user to choose to which directory to install Perl. – ikegami Oct 04 '17 at 16:45
  • Aside from adding the paths via env var `PERL5LIB`, you might be able to address your issue by replacing relatives paths with absolute ones in `Config.pm` (and possibly the associated "heavy" file). – ikegami Oct 04 '17 at 16:46
  • On *nix systems you just use "use lib '/home/pathtolib';" at the start of you script. not sure how this is done on windows though – hoffmeister Oct 05 '17 at 05:27
  • Explicitely setting the PERL5LIB environment variable does the trick, thanks @ikegami! But since I regard the explicit setting of paths somewhat ugly, I still would like to understand the underlying mechanism that changed the @inc array. Many thanks in advance. – frankme Oct 05 '17 at 10:58
  • Comments are not for extended discussion; a conversation between ikegami and stevesliva has been [moved to chat](http://chat.stackoverflow.com/rooms/156194/discussion-on-question-by-frankme-site-perl-directory-is-missing-in-perl-inc-se). – Cody Gray - on strike Oct 08 '17 at 09:07

0 Answers0