sftp icon indicating copy to clipboard operation
sftp copied to clipboard

sftp_list Error in function (type, msg, asError = TRUE)

Open a-bro-0227 opened this issue 2 years ago • 6 comments

Hi There,

I updated the sftp package and I am now getting the error message Error in function (type, msg, asError = TRUE) when trying to list files recursively in a folder on and sFTP site. This was working properly before the update.

below is the code I am running that results in the error:

sftp_con <- sftp_connect(server = server,
                         username = username ,
                         password = password ,
                         folder = 'folder')

sftp_list(sftp_con, recurse = T, verbose = F, type = 'f')

If I try to list the files in a sub directory it does work:

sftp_con <- sftp_connect(server = server,
                         username = username ,
                         password = password ,
                         folder = 'folder/subfolder')

sftp_list(sftp_con, recurse = T, verbose = F, type = 'f')

a-bro-0227 avatar Jul 05 '22 13:07 a-bro-0227

I have a similar issues when I launch sftp_download:

> sftp_download(file=file,tofolder=outdir,sftp_connection=sftp_con)
SFTP source: sftp://<.../>
Save to folder: <../>
1 file(s) to download.
Error in function (type, msg, asError = TRUE)  : 

Thank you

ecor avatar Jun 09 '23 13:06 ecor

We encountered the same issue, and in our case, it was due to the file names we were trying to download. The sftp package doesn't handle file names with spaces in them. Removing spaces from the file names resolved the problem.

MarcelHuesing avatar Jul 19 '23 14:07 MarcelHuesing

We encountered the same issue, and in our case, it was due to the file names we were trying to download. The sftp package doesn't handle file names with spaces in them. Removing spaces from the file names resolved the problem.

I faced this error when tried to run the script that earlier worked on laptop - there was a folder on sftp with the name contaings the space and Cyrillic symbols.

This session worked:

R version 4.1.0 (2021-05-18) Platform: i386-w64-mingw32/i386 (32-bit) Running under: Windows 7 x64 (build 7601) Service Pack 1 Matrix products: default locale: [1] LC_COLLATE=English_United Kingdom.1252 [2] LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252 [4] LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252

attached base packages: [1] stats graphics grDevices utils datasets methods base
other attached packages: [1] stringr_1.5.0 readr_2.1.4 purrr_1.0.1 dplyr_1.1.2 sftp_2.0.11


The session below returned the error when doing sftp_list (it correctly retrieved the folder name in Cyrillic on reading the parent folder (recurse = F), but failed to go deeper, returning the error with with recurse = T).

R version 4.2.1 (2022-06-23 ucrt) 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 Kingdom.1252 LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252
system code page: 1251

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

other attached packages: [1] stringr_1.5.0 readr_2.1.3 purrr_1.0.1 dplyr_1.0.10 sftp_2.0.11

The difference was in R version and in system code page (1252 worked, 1251 failed). Hope this is useful.

alexeilutay avatar Jul 31 '23 10:07 alexeilutay

I also have the same error (type, msg, asError = TRUE), the files present in the sftp have no problems when downloaded from a Windows machine, but when I run it on Linux I have the problem, any ideas?

BenjaParraguezC avatar Aug 04 '23 15:08 BenjaParraguezC

Has anyone managed to resolve this issue in a Windows environment without having to remove spaces in filenames (as detailed above by @MarcelHuesing)?

Oliver-CISC avatar Oct 18 '23 09:10 Oliver-CISC

I have been having the same issue when trying to connect to an sftp on Workbench. It works fine locally. Any thoughts? Thanks!

NEinterz avatar Jul 29 '24 18:07 NEinterz