rfishbase icon indicating copy to clipboard operation
rfishbase copied to clipboard

Error in guess_header_ when using readr + packrat

Open juanmayorgahenao opened this issue 6 years ago • 7 comments

I'm trying to use the package in a Packrat project and I'm running into this error when I run the example:

fish <- validate_names(c("Oreochromis niloticus", "Salmo trutta"))

Error in guess_header_(datasource, tokenizer, locale) : Cannot read file /private/var/folders/9h/wqbg24kx5tv7qz_k383qcp100000gn/T/RtmppWU7my/file112f65096036: Invalid argument

Running this outside of the project works fine. Any thoughts what might be happening?

juanmayorgahenao avatar Jan 22 '19 20:01 juanmayorgahenao

Can you ensure that you are running the most recent version (3.0.0) of rfishbase in your Packrat project?

cboettig avatar Jan 22 '19 20:01 cboettig

I am. I just installed using

install.packages("rfishbase", repo = "http://cran.rstudio.com")

as well as

remotes::install_github("ropensci/rfishbase")

juanmayorgahenao avatar Jan 22 '19 20:01 juanmayorgahenao

@juanmayorgahenao Just double-check the version in packrat/packrat.lock file for your packrat repository?

To help us debug, it would be useful if you could set options(error=recover) and paste the full callback trace reported on the error. May also be useful to include the output of sessionInfo() for us. Thanks!

cboettig avatar Jan 22 '19 21:01 cboettig

@cboettig Here is the full callback trace reported on the error;

`Error in guess_header_(datasource, tokenizer, locale) : Cannot read file /private/var/folders/9h/wqbg24kx5tv7qz_k383qcp100000gn/T/Rtmp67rUAv/file13dc4c6a7f81: Invalid argument

Enter a frame number, or 0 to exit

1: validate_names(c("Oreochromis niloticus", "Salmo trutta")) 2: synonyms(species_list, server = server) %>% dplyr::filter(Status == "accepted name" | Status == "synonym") %>% dplyr::pull(Species) 3: eval(lhs, parent, parent) 4: eval(lhs, parent, parent) 5: synonyms(species_list, server = server) 6: fb_tbl("synonyms", server) %>% mutate(synonym = paste(SynGenus, SynSpecies)) %>% select(synonym, Status, SpecCode, SynCode, CoL_ID, TSN, WoRMS_ID, ZooBank_ID, TaxonLevel) 7: eval(lhs, parent, parent) 8: eval(lhs, parent, parent) 9: fb_tbl("synonyms", server) 10: withVisible(_f(tbl = tbl, server = server, ... = ...)) 11: _f(tbl = tbl, server = server, ... = ...) 12: suppressWarnings(suppressMessages(out <- readr::read_tsv(tmp, ...))) 13: withCallingHandlers(expr, warning = function(w) invokeRestart("muffleWarning")) 14: suppressMessages(out <- readr::read_tsv(tmp, ...)) 15: withCallingHandlers(expr, message = function(c) invokeRestart("muffleMessage")) 16: readr::read_tsv(tmp, ...) 17: read_delimited(file, tokenizer, col_names = col_names, col_types = col_types, locale = locale, skip = skip, skip_empty_rows = skip_empty_rows, comment = comment, n_max = n_max, gue 18: col_spec_standardise(data, skip = skip, skip_empty_rows = skip_empty_rows, comment = comment, guess_max = guess_max, col_names = col_names, col_types = col_types, tokenizer = token 19: guess_header(ds_header, tokenizer, locale) 20: guess_header_(datasource, tokenizer, locale)`

and here is my session info

` version 3.5.1 (2018-07-02) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS 10.14

Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib

locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages: [1] furrr_0.1.0 future_1.10.0 rredlist_0.5.0.9100 sf_0.7-0 forcats_0.3.0 stringr_1.3.1 dplyr_0.7.99.9000 purrr_0.2.5
[9] readr_1.3.1 tidyr_0.8.2 tibble_2.0.1 ggplot2_3.1.0 tidyverse_1.2.1.9000 raster_2.6-7 sp_1.3-1

loaded via a namespace (and not attached): [1] tidyselect_0.2.5 listenv_0.7.0 haven_2.0.0 lattice_0.20-35 colorspace_1.3-2 generics_0.0.2 htmltools_0.3.6 yaml_2.2.0 base64enc_0.1-3 rlang_0.3.1
[11] e1071_1.7-0 pillar_1.3.1 glue_1.3.0 withr_2.1.2 DBI_1.0.0.9001 modelr_0.1.2 readxl_1.2.0 plyr_1.8.4 munsell_0.5.0 gtable_0.2.0
[21] cellranger_1.1.0 rvest_0.3.2 codetools_0.2-15 evaluate_0.11 labeling_0.3 knitr_1.20 parallel_3.5.1 class_7.3-14 broom_0.5.1 Rcpp_1.0.0
[31] scales_1.0.0 backports_1.1.2 classInt_0.2-3 jsonlite_1.6 hms_0.4.2 packrat_0.5.0-5 digest_0.6.18 stringi_1.2.4 grid_3.5.1 rprojroot_1.3-2 [41] rgdal_1.3-6 cli_1.0.1 tools_3.5.1 magrittr_1.5 lazyeval_0.2.1 crayon_1.3.4 pkgconfig_2.0.2 xml2_1.2.0 spData_0.2.9.3 lubridate_1.7.4 [51] assertthat_0.2.0 rmarkdown_1.10 httr_1.4.0 rstudioapi_0.9.0 globals_0.12.4 R6_2.3.0 units_0.6-1 nlme_3.1-137 compiler_3.5.1 `

juanmayorgahenao avatar Jan 22 '19 21:01 juanmayorgahenao

The package version in packrat/packrat.lock is 3.0.0

juanmayorgahenao avatar Jan 22 '19 21:01 juanmayorgahenao

Thanks for your help!

juanmayorgahenao avatar Jan 22 '19 21:01 juanmayorgahenao

@jimhester Any idea why readr would throw the error:

Error in guess_header_(datasource, tokenizer, locale) :
Cannot read file /private/var/folders/9h/wqbg24kx5tv7qz_k383qcp100000gn/T/RtmppWU7my/file112f65096036: Invalid argument

when a user is using packrat but not otherwise? I can confirm this behavior:

  1. Create a new project in RStudio, check box "with packrat"
  2. install.packages("rfishbase")
  3. library(rfishbase)
  4. species()

Do the same without packrat, no errors. Seems to be an issue in how readr uses temporary files when guessing headers?

cboettig avatar Jan 22 '19 22:01 cboettig