How to fix Perl warning message when loading gdata package?
Asked Answered
E

1

5

I've updated Strawberry Perl 64-bit 5.30.2001 and the gdata package. Now, when loading library(gdata) I always get this warning messages which appear to be related to Perl.

suppressPackageStartupMessages(library(gdata))
# Warning messages:
#   1: In system(cmd, intern = intern, wait = wait | intern, show.output.on.console = wait,  :
#     running command 'C:\Windows\system32\cmd.exe /c ftype perl' had status 2
#   2: In system(cmd, intern = intern, wait = wait | intern, show.output.on.console = wait,  :
#     running command 'C:\Windows\system32\cmd.exe /c ftype perl' had status 2

However, read.xls, the function I need, seems to run well, except that the warning is repeated every time I use it.

read.xls("http://file-examples-com.github.io/uploads/2017/02/file_example_XLS_10.xls")
# trying URL 'http://file-examples-com.github.io/uploads/2017/02/file_example_XLS_10.xls'
# Content type 'application/vnd.ms-excel' length 8704 bytes
# downloaded 8704 bytes

#   X0 First.Name Last.Name Gender       Country Age       Date   Id
# 1  1      Dulce     Abril Female United States  32 15/10/2017 1562
# 2  2       Mara Hashimoto Female Great Britain  25 16/08/2016 1582
# 3  3     Philip      Gent   Male        France  36 21/05/2015 2587
# 4  4   Kathleen    Hanner Female United States  25 15/10/2017 3549
# 5  5    Nereida   Magwood Female United States  58 16/08/2016 2468
# 6  6     Gaston     Brumm   Male United States  24 21/05/2015 2554
# 7  7       Etta      Hurn Female Great Britain  56 15/10/2017 3598
# 8  8    Earlean    Melgar Female United States  27 16/08/2016 2456
# 9  9   Vincenza   Weiland Female United States  40 21/05/2015 6548
# Warning messages:
#   1: In system(cmd, intern = intern, wait = wait | intern, show.output.on.console = wait,  :
#     running command 'C:\Windows\system32\cmd.exe /c ftype perl' had status 2
#   2: In system(cmd, intern = intern, wait = wait | intern, show.output.on.console = wait,  :
#     running command 'C:\Windows\system32\cmd.exe /c ftype perl' had status 2

I'm not sure how to deal with this warning because it says nothing to me, I could probably just ignore it and wrap a suppressWarnings() around it.

Nevertheless, does anybody know a way to fix this? I couldn't find anything by googling and don't know where to start and what's actually wrong.

> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] gdata_2.18.0

loaded via a namespace (and not attached):
[1] compiler_4.0.2 tools_4.0.2    gtools_3.8.2  
Emilyemina answered 14/8, 2020 at 10:51 Comment(8)
sorry just irrelevant question. did you say you updated perl? Because I see the latest perl to be 5.32 on my computerInconsequential
@Inconsequential Yes, I found Strawberry Perl 64-bit 5.30.2001 as the newest. Would you suggest installing another Perl "distribution", or whatever you call it?Emilyemina
Could it be the path, on my windows pc it is something like c:/strawberry/perl/bin (from memory)Ken
Not really. I use windows, and since I do not want to install many things ie (perl, gcc, grep, python, Rtools, sed, bash, gawk etc) separately, I just installed MSYS2 then no need of installing any of those(even Rtools I dont have to install it)Inconsequential
just curious thouh. What is the command c:>ftype perl??Inconsequential
@Ken Thanks, checked the PATH, I have three related entries, C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin Could that be an issue?Emilyemina
@jay.sf; no that looks okayKen
@Inconsequential I have no idea...Emilyemina
P
6

I had the same issue with a freshly installed version of R, gdata and Strawberry Perl. I finally found this answer to a different (but related) question. Adapting the suggestion there, I ran the following on an elevated command promt:

FTYPE perl=C:\Strawberry\perl\bin\perl.exe %1 %*

This solved the issue for me – however: I am not sure if setting the FTYPE like this might have any unwanted side effects. So be careful.


Update: The command above did suppress the warning "ftype perl' had status 2" for me, but gdata still had issues:

gdata: Unable to load perl libaries needed by read.xls() gdata: to support 'XLSX' (Excel 2007+) files.

gdata: Run the function 'installXLSXsupport()' gdata: to automatically download and install the perl gdata: libaries needed to support Excel XLS and XLSX formats.

However, installXLSXsupport() failed with an unspecific error message.

I then ran

Sys.which("perl")
                              perl 
"C:\\rtools40\\usr\\bin\\perl.exe" 

and realized that the Perl version from RTools takes precedence over my Strawberry Perl installation – and apparently gdata does not "like" that Perl version.

Therefore, I decided to give Strawberry Perl precedence over RTools by changing my .Renviron file (usethis::edit_r_environ()):

PATH="${RTOOLS40_HOME}\usr\bin;${PATH}" # old
PATH="${PATH};${RTOOLS40_HOME}\usr\bin" # new

Again, I'm not entirely sure what ramifications this might have, but it fixed gdata for me. Maybe adjusting the PATH alone would also have done the trick (without the ftype stunt I made first), but I cannot test this anymore.

What I recommend:

  1. Adjust the PATH first.
  2. If gdata still complains about the ftype, set the ftype.
Publicly answered 8/9, 2020 at 7:51 Comment(1)
Yeah that works!! I followed your suggestion to adjust the PATH first, and it seems that this was enough and I didn't need to set the ftype.Emilyemina

© 2022 - 2024 — McMap. All rights reserved.