Having problems to install CPAN modules that use Module::Install on Windows?

I have been discussing this problem with Adam Kennedy and some other people at #win32@irc.perl.org today:

Line 388 of Module/Install/Makefile.pm is a blank line, but the line after it is a simple two-arg open().

open MAKEFILE, "> $makefile_name" or
die "fix_up_makefile: Couldn't open $makefile_name: $!";

Side-note: I don't know why they use two-arg open there, but it is probably because Module::Install needs to work back to the stone-age of Perl.

Since the file was opened for read access a couple of lines above it got me thinking. This invalid argument message Windows gives you is its way of saying "hey, the file is locked somewhere else, you can't mess with it".

In the end I figured out that the bad guy here was my anti-virus (AVG). An extremely crude workaround I found that worked was to just put the entire Strawberry Perl in the anti-virus exclusion list. This solved the "invalid argument" message for me, and now my Module::Install-based CPAN modules install as they should.

This is obviously not a very good long-term solution. So this got me thinking a bit more. Who is really at fault here? Is it perl or AVG? Should AVG not allow open() to return before it is finished with its scanning stuff, or should perl handle open() for write differently on Windows, considering the OS itself forces write locking.

I'd really like to hear more about what you guys that know the perl internals have to say about this subject.

Update: Kenichi Ishigaki replied a bit later with a patch to Module::Install that works around the problem. He applied the web counter solution mentioned in perlfaq5 to the problem, and it worked for me. I guess it is now just to wait for Adam Kennedy to release a new version of Module::Install and file bugs against the CPAN modules that show problems on Windows with a message that they should upgrade their Module::Install version and issue a new release of their module.

Update2: Adam Kennedy has released Module::Install 0.98, which contains the patch. Please tell all CPAN module authors that use it to upgrade to the new version and Windows users will be very happy.

Apple, the devil in our midst

So Matt Trout has lost the Iron Man Challenge.

As part of the competition rules it is time to make a vote for a hair color for him and a talk title that he will present at an upcoming Perl conference.

My vote goes to a light blue color as the sky, and the talk title 'Apple, the devil in our midst'.

Are you unable to run the JavaME SDK 3.0 emulator on Windows 7? Workaround found!

If you get this error message when trying to run midlets through the built-in emulator of the JavaME SDK 3.0, try disabling DEP for runMidlet.exe.

Error message given by Netbeans and/or Eclipse:

*** Error ***
Failed to connect to device 0!
Reason:
Emulator 0 terminated while waiting for it to register!

Data Execution Prevention (DEP) configuration can be found at the following place in Windows: Control Panel > System Security > System > Advanced system Settings > Advanced tab > Performance > Data Execution Prevention.

Add this file to the DEP exclusion list:

<javame-install-dir>\runtimes\cldc-hi-javafx\bin\runMidlet.exe

If things work for you now, complain loudly to Sun (now Oracle) that they need to make software without buffer overflows.

Personally I filed a bug-report against the JavaME SDK 3.0. You should do that too, or make your voice heard on the same bug-report that you're having this problem as well.

How to get a PSGI app running with mod_fastcgi on Ubuntu with Apache2

First make sure you activate the multiverse repository for apt.

Then install the required modules (if you don't already have them enabled)

sudo aptitude install libapache2-mod-fastcgi apache2-suexec

Enable the fastcgi and rewrite modules:

sudo a2enmod fastcgi
sudo a2enmod rewrite

Edit /etc/apache2/mods-enabled/fastcgi.conf and enable the FastCgiWrapper so that the .fcgi script is run as the owner of the script. This is why apache2-suexec above is needed.

Then add the following to the file if you like to be able to just touch the psgi.fcgi file to get it to reload your app.

FastCgiConfig -autoUpdate

My /etc/apache2/mods-enabled/fastcgi.conf is like this:

<IfModule mod_fastcgi.c>
AddHandler fastcgi-script .fcgi
FastCgiWrapper /usr/lib/apache2/suexec
FastCgiIpcDir /var/lib/apache2/fastcgi
FastCgiConfig -autoUpdate
</IfModule>

Then you need a small wrapper script to actually run your PSGI app. I call it psgi.fcgi:

#!/usr/bin/perl
use strict;
use warnings;
# For CPAN modules in your home-dir (see local::lib)
use lib "/home/robin/perl5/lib/perl5";
use lib "/home/robin/perl5/lib/perl5/i486-linux-gnu-thread-multi";
use Plack::Server::FCGI;
Plack::Server::FCGI->new->run(do "app.psgi");

The use lib statements are there because I use local::lib. I just grabbed them from the PERL5LIB environment variable. If someone has a better solution on how to write this wrapper with support for local::lib, I'd like to hear it.

The next thing is to add a nice .htaccess file so that you can make flexible apps that use PATH_INFO and other nice things (this is where mod_rewrite comes in).

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ psgi.fcgi/$1 [QSA,L]

Change this one if you'd like Apache to handle static files by itself instead of forwarding the requests to your application.

Finally I just made a small app.psgi that prints the environment as you try out different paths below your base folder. Pay close attention to how PATH_INFO changes as you try it out.

#!/usr/bin/perl

use strict;
use warnings;

sub {
my ($env) = @_;
my @out = ( "Your \$env hash:\n\n" );
foreach my $key ( sort keys %{ $env } ) {
push @out, $key, ' = ', $env->{$key}, "\n";
}
return [
200,
[ 'Content-Type' => 'text/plain' ],
\@out,
];
};

I'm using Plack 0.9006 from CPAN for this little experiment.

I think this will be my quick-and-easy way to deploy PSGI apps from now on.

Update: It seems the suexec wrapper doesn't do its job properly. The FastCGI script, psgi.fcgi, is apparently still running as www-data(33). If you know how to fix this problem please shout out in the comments.

Talk: Morality and Pragmatism in Free Software and Open Source

I just wanted to inform you about a talk I'll be making on my local college about the differences in philosophy of the Free Software movement and the Open Source movement.

Feedback about content, accuracy etc. most wanted.

The talk is mostly about summarizing the content of Dave Yeats writings in the book The Handbook of Research on Open Source Software: Technological, Economic, and Social Perspectives (Chapter 3).

Thanks to the Dave Rolsky, Ricardo Signes, Florian Ragwitz and others in #moose@irc.perl.org for valuable input on the subject matter.