http://www.perlmonks.org?node_id=882541

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

Hi,

I just installed ActiveState Perl 5.10.1.1008 on two machines: One is a Windows XP Professional laptop for work, and the other is my home Windows 7 Professional machine. I am trying to set up Perl so I can keep several files and folders in sync between the two, and other admin tasks.

Both installs are pristine installs, followed by adding two modules using the GUI PPM: Win32::Hardlink and Win32::Symlink.

However, when trying to run any code, for example:

use strict; use warnings; use Win32::Hardlink;
I get the following error (edited to remove paths specific to my machine):
Can't locate Win32/Hardlink.pm in @INC (@INC contains: /path/to/perl/l +ib .) at path/test.pl line 31.

I have done some research and found I can add:

use lib "/path/to/perl/site/lib";
to my script, and then it works fine. While this fixes the problem, I do not want to have to hard-code the site lib into every script as the paths are different on both machines and may change in the future. How can I go about fixing this permanently? (I am curious as well, is this an issue with ActiveState's Perl build or something with Win32?)

TIA!

Replies are listed 'Best First'.
Re: @INC site/lib problem on Windows 7 and XP (ActiveState Perl)
by BrowserUk (Patriarch) on Jan 16, 2011 at 19:12 UTC

    Could it be that you used the .zip install rather than the .msi install and forgot to finish the job by running the install script?


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: @INC site/lib problem on Windows 7 and XP (ActiveState Perl)
by Marshall (Canon) on Jan 17, 2011 at 15:43 UTC
    I looked on the Active State website for downloads and all I see for version 5.10 is a single link to the .msi file. Its hard for me to see how you have selected the wrong thing there.

    I find your error report perplexing as I would have expected something like: "hey, it works on Machine A, but not Machine B". Do you mean that code doesn't work on either machine? You have two independent installations that have nothing to do with each other. Run the .msi and gui ppm on each machine separately - do not copy files between machines.

    I am on XP pro and the .msi installer has been working great for many years. I don't have a Win 7 box, but can help with XP and so can many others. Start with XP. Get specific about what you did during the installation. Default would be C:\Perl and be installed for all users. What thing differently did you do? Get as specific as you can. And let's talk about why your XP installation doesn't work. Then completely different topic: "My Win 7 installation doesn't work".

    In your case, you only have two packages so doing a manual GUI install on both machines separately is no big deal. But here's how to do it if there were 100 packages...use the command line ppm.

    Type at a command prompt: "ppm help profile" and you will learn about "profile save" and "profile restore". To "clone" my installation on another computer, I run "ppm profile save myinstall", go to the other machine, install AS from the .msi then after that from command line run "ppm profile restore myinstall". That runs the ppm installer for each of my packages on the other machine. That is the right way to get the same packages on multiple machines.

    The ppm installer adjusts things so that modules get put in the right directories. If you tried to copy Perl module files between machines, then I could see how you are in trouble! Don't do that.

      Thanks for the tip on the save/restore profile! I was under the impression that profiles only worked if you had a professional license or something from ActiveState.

      Regarding my original problem..

      On all machines, I downloaded the MSI installer and ran it to completion, using defaults for everything except the path. I set the path to <drive-letter>:/activestate/perl/5.10/ (where the only difference between machines is which drive I installed it on; C: on one computer, D: on the other.) Likewise, I used the PPM GUI on each to install the hardlink package (eventually, I have about 250 packages I want installed, but I wanted to install the base AS Perl and one package to test that everything was working before going full steam ahead.)

      I do remember many lifetimes ago when I installed the ancient AS Perl 5.6, I had a similar problem on another machine (Originally Win2K but later upgraded to XP--do not remember if I installed AS Perl 5.6 before or after the upgrade), but was able to fix it by modifying some file in the lib/ tree to modify the @INC var (it was some config file which I cannot seem to locate a similar file in 5.10.) If I can do something similar again, that would work fine for my needs. But I do not know where 5.10 stores it's config info as I cannot seem to find it.

      I've also worked around it for the time being by having all my scripts call C:/sys/bin/set-perl-env.bat (as all my machines have a C:/sys/bin folder for storing commonly used binaries and scripts) which sets up the Perl environment for the current machine before calling Perl.

      (Although I am still curious to understand why I am having this issue!)

      TIA

        Correction, I forgot I also used the PPM GUI to install a second package, Win32::Symlink, but have been only using the Win32::Hardlink package as my testing rat..
        There is a bug in core Perl on Windows that doesn't set up @INC correctly if Perl is installed into a directory that starts with the letter '5'. Your problem should go away if you install into C:/activestate/perl/v5.10 instead.

        This bug is at least 10 years old and somewhat related to finding additional site_lib directories when you are using the versioned directory layout scheme where multiple Perl versions share site_lib directories.