Subject: | UNIX-style filesystem paths not recognized under cygwin |
ENVIRONMENT:
- Windows XP Home SP1
- uname -a: CYGWIN_NT-5.1 SLEEPWALK 1.5.10(0.116/4/2) 2004-05-25 22:07 i686 unknown unknown Cygwin
- Perl v5.8.2 built for cygwin-thread-multi-64int, installed via cygwin setup.exe
- DBD::SQLite 1.00, built under cygwin /bin/tcsh using "perl -MCPAN -e shell" with command "install DBD::SQLite".
BEHAVIOR:
- DBI->connect fails when database is specified with a UNIX-style file path (e.g., "/tmp/dbfile.db").
- DBI->connect succeeds when database is specified with a DOS-style file path (e.g., "D:\cygwin\tmp\dbfile.db") or with no path information ("dbfile.db").
NOTES:
- I have confirmed that dbitest.db is created in specified location when DOS-style path is used and not created when UNIX-style path is used. UNIX-style paths should be valid when run under cygwin.
SAMPLE CODE:
#!/bin/perl
use DBI;
use strict;
foreach my $dbfile (qw(dbitest.db d:\cygwin\tmp\dbitest.db /tmp/dbitest.db)) {
my $data_source = "dbi:SQLite:$dbfile";
print "Opening data source '$data_source'\n";
my $dbh = DBI->connect($data_source, "", "") || die $DBI::errstr;
print "Opened $dbfile\n";
print "SQLite version $dbh->{sqlite_version}\n";
$dbh->disconnect;
print "Closed $dbfile\n\n";
}
SAMPLE OUTPUT:
% ./dbitest.pl
Opening data source 'dbi:SQLite:dbitest.db'
Opened dbitest.db
SQLite version 3.0.2
Closed dbitest.db
Opening data source 'dbi:SQLite:d:\cygwin\tmp\dbitest.db'
Opened d:\cygwin\tmp\dbitest.db
SQLite version 3.0.2
Closed d:\cygwin\tmp\dbitest.db
Opening data source 'dbi:SQLite:/tmp/dbitest.db'
DBI connect('/tmp/dbitest.db','',...) failed: unable to open database file(1) at dbdimp.c line 57 at /home/Ernie/dbitest.pl line 12
unable to open database file(1) at dbdimp.c line 57 at /home/Ernie/dbitest.pl line 12.