[R-pkg-devel] RTools 4.x Perl Incompatibility with WriteXLS CRAN Package
Marc Schwartz
m@rc_@chw@rtz @end|ng |rom me@com
Fri Jul 19 18:06:02 CEST 2024
Hi Ivan,
Thanks kindly for your expedient reply and pointer to the LF/CRLF issue. Not sure that I would have found that issue so quickly, so was hoping for some intuition here, as you have provided.
Thanks!
Regards,
Marc
-----Original Message-----
From: Ivan Krylov <ikrylov using disroot.org <mailto:ikrylov using disroot.org>>
Date: Friday, July 19, 2024 at 11:18 AM
To: Marc Schwartz <marc_schwartz using me.com <mailto:marc_schwartz using me.com>>
Cc: <r-package-devel using r-project.org <mailto:r-package-devel using r-project.org>>
Subject: Re: [R-pkg-devel] RTools 4.x Perl Incompatibility with WriteXLS CRAN Package
Dear Marc Schwartz,
В Fri, 19 Jul 2024 10:49:31 -0400
Marc Schwartz <marc_schwartz using me.com <mailto:marc_schwartz using me.com>> пишет:
> . No such file or
> directory\Kleinbub\AppData\Local\Temp\RtmpuO4911/WriteXLS/1.csv
This looks like an extra carriage return has messed up the output.
By debugging WriteXLS and running the command line manually with perl
-d, I can confirm this:
main::(C:/Users/redacted/AppData/Local/R/win-library/4.5/WriteXLS/Perl/WriteXLS.pl:135):
135: my @FileNames = "";
DB<3>
main::(C:/Users/redacted/AppData/Local/R/win-library/4.5/WriteXLS/Perl/WriteXLS.pl:136):
136: open (DFHANDLE, $Encode, "$CSVPath/FileNames.txt") || die
"ERROR: cannot open $CSVPath/FileNames.txt. $!\n";
DB<3>
main::(C:/Users/redacted/AppData/Local/R/win-library/4.5/WriteXLS/Perl/WriteXLS.pl:137):
137: @FileNames = <DFHANDLE>;
DB<3>
main::(C:/Users/redacted/AppData/Local/R/win-library/4.5/WriteXLS/Perl/WriteXLS.pl:138):
138: close DFHANDLE;
DB<3> x \@FileNames
0 ARRAY(0xa005e3c08)
0 "C:\\rtools44\\tmp\\Rtmpg9BxFb/WriteXLS/1.csv\cM\cJ"
DB<4> n
main::(C:/Users/redacted/AppData/Local/R/win-library/4.5/WriteXLS/Perl/WriteXLS.pl:141):
141: chomp(@FileNames);
DB<4> n
main::(C:/Users/redacted/AppData/Local/R/win-library/4.5/WriteXLS/Perl/WriteXLS.pl:302):
302: foreach my $FileName (@FileNames) {
DB<4> x \@FileNames
0 ARRAY(0xa005e3c08)
0 "C:\\rtools44\\tmp\\Rtmpg9BxFb/WriteXLS/1.csv\cM"
Since the R code always uses a text-mode connection with WriteLines,
it always results in CR-LF line endings on Windows. The difference must
be in the default PerlIO layers applied by Strawberry Perl by default.
MSYS is based on Cygwin, which does its best to pretend to be an
Unix-like environment, so it's reasonable for an MSYS build of Perl to
default to LF line endings. But that means special-casing the MSYS
build of Perl:
DB<5> x $Encode
0 '<:encoding(utf8)'
DB<6> x $^O
0 'msys'
...and adding $Encode .= ":crlf" if $^O eq 'msys'; somewhere.
--
Best regards,
Ivan
More information about the R-package-devel
mailing list