Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Installing CPAN on a Windows system

by GrandFather (Cardinal)
on Feb 16, 2006 at 06:52 UTC ( #530600=perlmeditation: print w/ replies, xml ) Need Help??

Assuming you have installed ActiveState Perl the following is a guide to getting CPAN's cpan module install tool working on a Windows XP system with Visual Studio.

Install Visual Studio1

First up, CPAN absolutely will not run nmake from a path including a space. If you have Visual Studio installed to its default location in .../Program Files/... and you are using NTFS then your best bet is to use System Internals' Junction to create a hard link to the Visual Studio install folder. You can pick Junction up from http://www.sysinternals.com/Utilities/Junction.html. Run it as:

junction c:/vs2003 "C:\Program Files\Microsoft Visual Studio 7"

If you are yet to install Visual Studio then you should seriously consider installing it to a non-default path that doesn't include spaces in the path.

Install cygwin

Install cygwin from http://cygwin.com/setup.exe. When the setup promts you to choose a download site you should choose four or so mirrors to help avoid stale mirror syndrome.

During the install you should add the following non-default packages:

  • Archive/unzip
  • web/lynx
  • web/wget
  • net/ncftp
  • utils/gnupg

Note that you can use the View button to toggle between different package views. "Not Installed" and "Category" are most usefull for this job. Click on "Skip" to select a package for installation.

Installing CPAN

Open a command window using "Programs|Microsoft Visual Studio 200x|Visual Studio Tools|Visual Studio 200x Command Prompt"2

Append the cygwin bin folder to the search path:

set path=%path%;c:\cygwin\bin

Run CPAN - just type cpan on the command line and hit enter. The AS Perl install proivides a batch file on the path that runs the cpan tool.

The first time cpan is run it wants to go through a configuration process. Mostly using the default options is fine. I'd recommend using "follow" at the "Policy on building prerequisites" prompt however.

The most important thing to check is that the path for nmake is correct and doesn't include spaces. If you have a default VS install then most likely you will need to change the path to use the hard link you created with Junction.

Other than that, just accept the defaults and you are done.

1Oh, there is a gotcha - things go rather pear shaped if you use VS 2005 to build against AS Perl 5.8.7 (815) and earlier builds (and possibly against 5.8.8 when it's available) because the binaries generated by VS 2005 do not play with the VC++ 6 binaries built with an earlier compiler.

2If you use the command line reguarly it is well worth migrating the contents of the batch file invoked by this command into your environment. demerphq has written a script to ease the process - see the update to this node


DWIM is Perl's answer to Gödel

Comment on Installing CPAN on a Windows system
Select or Download Code
Re: Installing CPAN on a Windows system
by rhesa (Vicar) on Feb 16, 2006 at 07:19 UTC
Re: Installing CPAN on a Windows system
by Roy Johnson (Monsignor) on Feb 16, 2006 at 15:16 UTC
    As an alternative to creating hard links with Junction, you can map a path to a virtual drive using the Windows-native command subst.

    Caution: Contents may have been coded under pressure.
Re: Installing CPAN on a Windows system
by Steve_p (Priest) on Feb 16, 2006 at 15:27 UTC
    One feature of ActiveState is that it works perfectly with the MinGW gcc on Windows as well. So, if you'd like an alternative to the massive Visual Studio downloads, you should check it out.
      That is a feature of perl
        Actually, no. Perl will look at the Config entry $Config{cc}, which with ActiveState would be some version of cl, the Visual Studio command line compiler. The ability to use either Visual Studio or MinGW was added by ActiveState employees. See the perl5-porters mailing list for details.

      Can you point me to a quick guide on getting MinGW working with active state and CPAN ? I have downloaded and installed MinGW, my cpan shell runs and I have NMAKE. As cpan was looking for cl not gcc I make a copy of gcc to cl and added the MinGW\Bin to my path, apart from disliking a few options gcc runs but now nmake dies as it can not find link.

      Thanks,
      R.

      Pereant, qui ante nos nostra dixerunt!
        Just a guess, but CPAN may be looking for cl.exe because it found nmake in your path. For MinGW/gcc, you should be using dmake rather than MSVC's nmake and cl. Among other places, you can find dmake on CPAN.
Re: Installing CPAN on a Windows system
by brian_d_foy (Abbot) on Feb 16, 2006 at 18:13 UTC

    The latest version of my cpan(1) script has some fixes to ease the pain of batch files. Although it should be part of the latest CPAN.pm distribution, I also have it on CPAN as the cpan-script distribution.

    If Windows people know any other requests for things I can do with that script to make it easier for them, please let me know.

    --
    brian d foy <brian@stonehenge.com>
    Subscribe to The Perl Review
Re: Installing CPAN on a Windows system
by andk (Novice) on Feb 17, 2006 at 04:29 UTC

    First up, CPAN absolutely will not run nmake from a path including a space.

    Why can this not be fixed by configuration in CPAN.pm? Or with a patch to CPAN.pm? How do you run nmake when it is in a path that contains spaces?

    Out of curiosity, I put my make command to "/tmp/path with spaces/bin/make" and then configured within CPAN.pm:

    o conf make "'/tmp/path with spaces/bin/make'"

    and could install random modules immediately. How would this work under Windows?

      I had a quick play with altering the configuration string and could not make it work - I may not have tried double quoting. Windows handles the command line differently than *nix for quote characters of various types in any case and that may have been where the problem was.


      DWIM is Perl's answer to Gödel

        Mostly, Windows is very braindead about commandlines and doesn’t handle quoting in any particular fashion at all, so every program involved in the execution of another adds its own conventions/complexities; sometimes irresolvable ones.

        Makeshifts last the longest.

      By avoiding the shell, you don't need to quote
      I had thought the problem was not with nmake, but the if .cpan directory was within a path with spaces in it. I've had problems with it in the past, but I haven't tried it with a newer CPAN. With all the changes, this may have been fixed. Let me test and see.
        problem still exists

      Actually I think its a mixture of CPAN related issues and Cygwin related issues. All I know is that installing anything development into a path with spaces On Win32 is just a really good way to get yourself frustrated and annoyed at some point or another.

      Sure you can argue that it shouldnt be like this, and that things should work fine, and all of that, but ultimately its my experience that it doesn't, and that its a lot easier to avoid the problem outright than figure out the workarounds later.

      ---
      $world=~s/war/peace/g

      This works on Windows too, but the Windows shell (cmd.exe) only knows about double quotes:

      o conf make '"C:\tmp\path with spaces\bin\nmake.exe"'

      works and allows to use a directory with whitespace in its name. The same should also be done for the gzip and tar paths, and also for Perl itself (especially $^X :-) ). See also RT 17877 - the approach proposed by you to add quoting if it becomes necessary is what I do as well.

Re: Installing CPAN on a Windows system
by adamk (Chaplain) on Feb 18, 2006 at 15:19 UTC
    The first version of Vanilla Perl (think Perl for Win32 done right) is now up.

    It's got some problems with CPAN.pm and I'm working through nigglies as we speak, but in a few weeks if you aren't tied to ActivePerl you might find it a refreshing change.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://530600]
Approved by planetscape
Front-paged by planetscape
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2014-08-23 16:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (175 votes), past polls