markvanderloo/stringdist

"R_stringdist" not resolved from current namespace (stringdist)

Closed this issue · 13 comments

Hey all,
When working with the package, I got this error from time to time:

Error in .Call("R_stringdist", a, b, method, as.double(weight), as.double(p), : "R_stringdist" not resolved from current namespace (stringdist)

Usually restarting R session works, but I am afraid that it might cause problems in the production. Is there any fix?

Best,
Anastasiia

Hi Anastasiia,

Thanks for posting. The same question was asked at #72 and the user seemed to have solved it (at least, the issue was closed some hours after it was opened). I've asked for an update on how it was solved.

Also, it would be good to have some more information, for example the output of

sessionInfo()

at the time the error occurred. It will be easier to help other users in the future that way.

Best,
Mark

Hey Mark,

Just wanted to add, I've also seen this bug a few times. Always came up while working on refinr functions (package that Imports stringdist). Steps that would cause it would be running devtools::load_all("refinr"), then if I tried to run stringdist::stringdistmatrix() directly in the same session, I would get this error ( "R_lower_tri" not resolved from current namespace (stringdist) ). I would restart R, and then I was able to run stringdist::stringdistmatrix() without issues.

I haven't use the workflow above in a few months, so I was seeing this in v0.9.4.6 from CRAN.

Hey Mark, didn't get that error in a while, but here is it again.

"R_stringdist" not resolved from current namespace (stringdist) 

15. | do_dist(a = b, b = a, method = method, weight = weight, q = q,      p = p, bt = bt, useBytes = useBytes, nthread = nthread)
-- | --

This is my sessionInfo()

> sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 9 (stretch)

Matrix products: default
BLAS/LAPACK: /opt/intel/compilers_and_libraries_2018.2.199/linux/mkl/lib/intel64_lin/libmkl_rt.so

locale:
 [1] LC_CTYPE=en_US.UTF-8          LC_NUMERIC=C                  LC_TIME=en_US.UTF-8          
 [4] LC_COLLATE=en_US.UTF-8        LC_MONETARY=en_US.UTF-8       LC_MESSAGES=en_US.UTF-8      
 [7] LC_PAPER=en_US.UTF-8          LC_NAME=en_US.UTF-8           LC_ADDRESS=en_US.UTF-8       
[10] LC_TELEPHONE=en_US.UTF-8      LC_MEASUREMENT=en_US.UTF-8    LC_IDENTIFICATION=en_US.UTF-8

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

other attached packages:
 [1] kredikk_1.2.9       kredipipe_2.0.1     Matrix_1.2-14       uuid_0.1-2          tibble_1.4.2       
 [6] purrr_0.2.5         largeList_0.3.1     jsonlite_1.5        plyr_1.8.4          stringi_1.2.4      
[11] stringr_1.3.1       dplyr_0.7.7         kredidb_1.0.9       RJDBC_0.2-7.1       rJava_0.9-10       
[16] DBI_1.0.0           data.table_1.11.4   futile.logger_1.4.3

loaded via a namespace (and not attached):
 [1] lubridate_1.7.4      devtools_1.13.6      RColorBrewer_1.1-2   SnowballC_0.5.1      tools_3.5.1         
 [6] backports_1.1.2      R6_2.3.0             rpart_4.1-13         KernSmooth_2.23-15   Hmisc_4.1-1         
[11] lazyeval_0.2.1       colorspace_1.3-2     nnet_7.3-12          withr_2.1.2          tidyselect_0.2.5    
[16] gridExtra_2.3        compiler_3.5.1       formatR_1.5          htmlTable_1.12       xml2_1.2.0          
[21] NLP_0.1-11           slam_0.1-43          scales_1.0.0         checkmate_1.8.5      tm_0.7-5            
[26] commonmark_1.5       digest_0.6.16        qualV_0.3-3          foreign_0.8-70       stringdist_0.9.5.1  
[31] base64enc_0.1-3      pkgconfig_2.0.2      htmltools_0.3.6      htmlwidgets_1.2      rlang_0.2.2         
[36] rstudioapi_0.8       textmineR_2.1.2      bindr_0.1.1          acepack_1.4.1        magrittr_1.5        
[41] modeltools_0.2-22    Formula_1.2-3        Rcpp_0.12.19         munsell_0.5.0        RcppProgress_0.4.1  
[46] RODBC_1.3-15         lda_1.4.2            yaml_2.2.0           RJSONIO_1.3-0        grid_3.5.1          
[51] crayon_1.3.4         lattice_0.20-35      splines_3.5.1        TraMineR_2.0-9       exasol_6.0.8        
[56] knitr_1.20           pillar_1.3.0         fastcluster_1.1.25   boot_1.3-20          topicmodels_0.2-7   
[61] xgboost_0.71.2       stats4_3.5.1         futile.options_1.0.1 glue_1.3.0           latticeExtra_0.6-28 
[66] lambda.r_1.2.3       testthat_2.0.0       gtable_0.2.0         openssl_1.0.2        assertthat_0.2.0    
[71] ggplot2_3.0.0        e1071_1.7-0          roxygen2_6.1.0       class_7.3-14         survival_2.42-3     
[76] memoise_1.1.0        bindrcpp_0.2.2       cluster_2.0.7-1     

interestingly enough, the error seems very random and hard to reproduce. It took me 4 restarts of the session and then it disappeared again. I also heard from my colleagues that they get it from time to time and restarting session usually helps.

Strange that you get it back since we haven't updated in a while now. Looking at your list of loaded packages, would it be possible that the maximum number of loaded dll's is reached? (I think it's 100, or used to be anyway).

See also this blog post

Hi Mark, I have found the issue can be solved by adding , PACKAGE="stringdist" to the .Call("R_stringdist") call.

Thanks, that's a great find!

Hi Mark, I have found the issue can be solved by adding , PACKAGE="stringdist" to the .Call("R_stringdist") call.

Hi, I faced the similar issue like this,

model <- catboost.train(learn_pool = train_pool, params = params)

Error in .Call("CatBoostSerializeModel_R", handle) : 
  "CatBoostSerializeModel_R" not resolved from current namespace (catboost)

However, I not sure how to add the , PACKAGE = "catboost" into the .Call("CatBoostSerializeModel_R" can you show me how to use it? It would help me a lot.

I guess it would be

.Call("CatBoostSerializeModel_R", handle, PACKAGE="catboost")
.Call("CatBoostSerializeModel_R", handle, PACKAGE="catboost")

Hi, I have tried this in the session before, but either got this or this

> .Call("CatBoostSerializeModel_R", handle, PACKAGE = "catboost")
Error: object 'handle' not found

> .Call("CatBoostSerializeModel_R", PACKAGE = "catboost")
Error in .Call("CatBoostSerializeModel_R", PACKAGE = "catboost") : 
  "CatBoostSerializeModel_R" not available for .Call() for package "catboost"

Should I add in certain files or anything else?

We'll, now your problem is that R cannot find the variable called handle.

None of this is related to stringdist though, so I suggest to continue this discussion elsewhere.