Skip to content
This repository has been archived by the owner on Nov 10, 2024. It is now read-only.

"No such file or directory" error (perhaps due to referencing network folder?) #563

Closed
sbinn opened this issue Apr 9, 2021 · 4 comments
Closed

Comments

@sbinn
Copy link

sbinn commented Apr 9, 2021

Updated to include result of traceback() below

Problem

Receiving a "No such file or directory" error when calling basic rtweet functions.
(By 'basic' I mean common introductory rtweet functions, no fancy parameter values, not requiring data loading...)

This error is different to Issues 202, 413, 421, and 424, which received a "Permission denied" error.

Expected behavior

search_tweets() function should return tweets as per rtweet: Collecting Twitter Data.
create_token() function should set token as per vignette("auth", package = "rtweet").

Details

Tested rtweet functions in March, running fine on my system (Windows 10, R 4.0.4, rtweet 0.7.0). Encountered this issue around two weeks ago, without having changed my system. Now upgraded to R 4.0.5, reinstalled rtweet, still having the same issue.

The error message mentions it cannot find "\\staff1.rds". My humble suspicion is that it could have to do with rtweet navigating to a network folder. My Windows default folders such as Desktop, Documents, ... are under \\staff.ad.xxx.edu.au\ud\fr\xxx\Desktop. There is no "\\staff1" folder.

Working directory is set to a non-network location, and R is also installed in a non-network location.

Interestingly, collecting tweets with the vosonSML package, which wraps the search_tweets() function, does not give any errors.

Sincere apologies if this has been addressed already or is not encountered by anyone else in the community.

Reproduce the problem

setwd("C:/Users/abcd/rtweet-test-folder")
library(rtweet)

## Receiving error using search_tweets() function
rt <- search_tweets(
  "#rstats", n = 1000, include_rts = FALSE
)

Requesting token on behalf of user...
Waiting for authentication in browser...
Press Esc/Ctrl + C to abort
Authentication complete.
Error in gzfile(file, mode) : cannot open the connection
In addition: Warning message:
In gzfile(file, mode) :
cannot open compressed file '\\staff1.rds', probable reason 'No such file or directory'

traceback()

12: gzfile(file, mode)
11: saveRDS(token, file = pathtotoken)
10: rtweet_token()
9: (function (pat, env = globalenv())
{
if (identical(pat, ".httr-oauth")) {
readRDS(pat)
}
else if (identical(pat, "system")) {
rtweet_token()
}
else if (if_load(pat)) {
x <- load(pat)
get(x)
}
else if (if_rds(pat)) {
readRDS(pat)
}
else if (any(grepl("token", ls(envir = env), ignore.case = TRUE))) {
global_token_finder()
}
else {
rtweet_token()
}
})(pat = dots[[1L]][[1L]], env = )
8: mapply(FUN = f, ..., SIMPLIFY = FALSE)
7: Map("load_tokens_", pat = pat, MoreArgs = list(env = env))
6: load_tokens(twitter_pat())
5: get_tokens()
4: check_token(token)
3: search_tweets_(q = "#rstats", n = 1000, type = "recent", include_rts = FALSE,
geocode = NULL, max_id = NULL, parse = TRUE, token = NULL,
retryonratelimit = FALSE, verbose = TRUE)
2: do.call("search_tweets_", args)
1: search_tweets("#rstats", n = 1000, include_rts = FALSE)

## Receiving error using create_token() function
api_key <- "xxx"
api_secret_key <- "xxx"
access_token <- "xxx"
access_token_secret <- "xxx"

token <- create_token(
  app = "xxx",
  consumer_key = api_key,
  consumer_secret = api_secret_key,
  access_token = access_token,
  access_secret = access_token_secret)

Error in file(file, mode) : cannot open the connection
In addition: Warning message:
In file(file, mode) :
cannot open file '\\staff1.rds': No such file or directory

traceback()

4: file(file, mode)
3: saveRDS(token, file = pathtotoken, compress = FALSE)
2: create_token_(app, consumer_key, consumer_secret, access_token,
access_secret, set_renv)
1: create_token(app = "xxx", consumer_key = api_key,
consumer_secret = api_secret_key, access_token = access_token,
access_secret = access_token_secret)

rtweet version

0.7.0

Session info

R version 4.0.5 (2021-03-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 16299)

Matrix products: default

locale:
[1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252    LC_MONETARY=English_Australia.1252 LC_NUMERIC=C                      
[5] LC_TIME=English_Australia.1252    

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

other attached packages:
[1] rtweet_0.7.0

loaded via a namespace (and not attached):
 [1] httr_1.4.2       compiler_4.0.5   magrittr_2.0.1   R6_2.5.0         promises_1.2.0.1 later_1.1.0.1    tools_4.0.5      curl_4.3         Rcpp_1.0.6      
[10] jsonlite_1.7.2   httpuv_1.5.5     openssl_1.4.3    rlang_0.4.10     askpass_1.1  
@llrs
Copy link
Collaborator

llrs commented Apr 9, 2021

The documentation of search_tweets that you should look up is for rtweet 0.7.0 with ?search_tweets. The documentation on the website corresponds to the development version (0.7.0.9000) and there have been a lot of changes.

I'm a bit surprised by rtweet looking for a file called staff1.rds. Could you paste the output of traceback() after encountering this error? Also report the traceback() after creating the token too please.

@sbinn
Copy link
Author

sbinn commented Apr 12, 2021

Thank you, llrs. I've updated the issue description with the output of traceback() for both scenarios. I notice that the error occurs after saving a file with saveRDS() and then trying to access it with gzfile(file, mode)/file(file, mode).

@llrs
Copy link
Collaborator

llrs commented Apr 12, 2021

Thanks. I expected something different.
I don't know why you are encountering this. On version 0.7.0 it saved the tokens as ".rtweet_token.rds" not "staff.rds". It shouldn't try to open anything like this. If this is a folder it is very weird because it has a file extension on the name of a folder.

Rereading now that you didn't change anything on the R side I would check with your IT team to see if they can provide further help, because it doesn't look to me like anything rtweet would do.

I'm closing the issue because on the development version the tokens management has been changed to a more usual localization. Even if this is due to rtweet it shouldn't happen again from now on.

@llrs llrs closed this as completed Apr 12, 2021
@sbinn
Copy link
Author

sbinn commented Apr 13, 2021

Thank you, llrs! I appreciate your time looking into it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants