ropensci-review-tools / pkgstats

Historical statistics of every R package ever
https://docs.ropensci.org/pkgstats/
17 stars 1 forks source link

ctags_test fails on first run #36

Closed assignUser closed 2 years ago

assignUser commented 2 years ago

Hello! When trying to run {pkgcheck} I noticed that ctags_test() fails on first run in any session, subsequent tests work: image

As {pkgcheck} only checks ctags_test in interactive sessions it is only a minor inconvenience.

R: 4.1.2 on pop_os 21.10 pkgstats 0.0.3.82 universal-ctags 5.9.20210829.0-1

mpadge commented 2 years ago

Thanks @assignUser, could you please run that as a reprex(), and include the following lines:

sessionInfo()
Sys.which("ctags")
Sys.which("gtags")

Thanks!

assignUser commented 2 years ago

Sure! I am running in VSC with radian just fyi.

sessionInfo()
#> R version 4.1.2 (2021-11-01)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Pop!_OS 21.10
#> 
#> Matrix products: default
#> BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
#> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=de_DE.UTF-8        LC_COLLATE=en_US.UTF-8    
#>  [5] LC_MONETARY=de_DE.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=de_DE.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=C       
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> loaded via a namespace (and not attached):
#>  [1] knitr_1.36        magrittr_2.0.1    R.cache_0.15.0    rlang_0.4.12     
#>  [5] fastmap_1.1.0     fansi_0.5.0       stringr_1.4.0     styler_1.6.2.9000
#>  [9] highr_0.9         tools_4.1.2       xfun_0.27         R.oo_1.24.0      
#> [13] utf8_1.2.2        withr_2.4.2       htmltools_0.5.2   ellipsis_0.3.2   
#> [17] yaml_2.2.1        digest_0.6.28     tibble_3.1.5      lifecycle_1.0.1  
#> [21] crayon_1.4.2      purrr_0.3.4       vctrs_0.3.8       R.utils_2.11.0   
#> [25] fs_1.5.0          glue_1.6.0        evaluate_0.14     rmarkdown_2.11   
#> [29] reprex_2.0.1      stringi_1.7.5     compiler_4.1.2    pillar_1.6.4     
#> [33] R.methodsS3_1.8.1 pkgconfig_2.0.3
Sys.which("ctags")
#>            ctags 
#> "/usr/bin/ctags"
Sys.which("gtags")
#>            gtags 
#> "/usr/bin/gtags"
pkgstats::ctags_test()
#> Warning in system2("gtags", args = list("--gtagslabel=\"new ctags\""), stdout =
#> TRUE, : running command ''gtags' --gtagslabel="new ctags" 2>&1' had status 1
#> [1] FALSE
pkgstats::ctags_test()
#> [1] TRUE

Created on 2022-01-15 by the reprex package (v2.0.1)

mpadge commented 2 years ago

Hmmm... Can you then please try in a shell the system command that it says fails there? The gtags one

assignUser commented 2 years ago
$ gtags --gtagslabel="new ctags" 2>&1
gtags: label 'new ctags' not found in '/etc/gtags/gtags.conf'.
mpadge commented 2 years ago

Okay, we're getting somewhere. Next try: gtags --version

assignUser commented 2 years ago
gtags (GNU GLOBAL) 6.6.5
Powered by Berkeley DB 1.85 and SQLite3 3.35.5.
Copyright (c) 1996-2019 Tama Communications Corporation

edit: installed via apt install global :)

mpadge commented 2 years ago

Then could you please show Sys.info()? gtags should be at 6.6.8, and that shows a need for diagnosing previous versions and implementing a work-around. So a real solution will take a while, as I'll have to set up a container with 6.6.5 to see how that behaves. In the meantime, you can solve it by either doing the steps shown in the gtags_install() function of pkgstats, but with sudo. That means downloading as shown there, then in the root directory of global:

./configure
make
sudo make install

Then you should have 6.6.8, which should work. Sorry about the inconvenience, but reports like this really help to debug so others won't have to go through this. Thanks!

assignUser commented 2 years ago

I am not sure if I have to install gtags 6.6.8 (I will do it just to see the difference though) as running ctags_test() a second time as seen above works (also weird?), No worries, thanks for your quick help!

Sys.info()
#>                                                            sysname 
#>                                                            "Linux" 
#>                                                            release 
#>                                          "5.15.8-76051508-generic" 
#>                                                            version 
#> "#202112141040~1639505278~21.10~0ede46a SMP Tue Dec 14 22:38:29 U" 
#>                                                           nodename 
#>                                                           "pop-os" 
#>                                                            machine 
#>                                                           "x86_64" 

Created on 2022-01-15 by the reprex package (v2.0.1)

assignUser commented 2 years ago

With 6.6.8 the same error from above happens: image

mpadge commented 2 years ago

Current code only runs the test once per session, so the second time will just skip those tests. But that means you'll get some but not all results. In pkgcheck, it will muck up the network diagram. That repeated error with 6.6.8 is odd - i'll have to look further later. Thanks for digging in to this! Cool that you're using popOS - system76 do some amazing stuff!! (It could somehow be related to their internal package distributions, because global cross-compiles with a host of system libs, but that's unlikely, and if it turns out to be the case, i won't follow it any further because the chance of any other popOS users "popping" up is very small. But i'll dig further locally first, and report back more here next week. Thanks again!

assignUser commented 2 years ago

popOS users "popping"

:rofl:

Yeah it looks like pkgcheck fails partway through with another error, maybe I'll just setup a Github action...

[...} 
── Package Structure ──

ℹ Package uses the following languages:
• R: 100%

ℹ Package has
• 2 authors.
• 2 vignettes.
• No internal data
• 12 imported packages.
• 32 exported functions (median 9 lines of code).
• 89 non-exported functions (median 8 lines of code).
• 2 parameters per function (median).
Error in as.environment(pos) : using 'as.environment(NULL)' is defunct
mpadge commented 2 years ago

No, that's just because you need to load the package itself for the print method to work. And as for GHA: https://github.com/ropensci-review-tools/pkgcheck/issues/62 - should hopefully appear one day soon

assignUser commented 2 years ago

I actually think the issue might be "new ctags" has a typo. I had a lock in gtags.conf:

ctags:\
        :tc=exuberant-ctags:tc=htags:
new-ctags:\
        :tc=universal-ctags:tc=htags:

When i run gtags --gtagslabel=new-ctags that works fine and finishes with status 0. After a quick search through the repo it does not look like you use "new ctags" somewhere else and a repeated run of {pkgcheck} seems to work fine. Should I test it with gtags 6.6.5?

mpadge commented 2 years ago

Ah, right, then it's probably that. Let me check on a few versions <6.6.8 to confirm, and then you can PR to change new ctags to new-ctags: https://github.com/ropensci-review-tools/pkgstats/blob/14db010862e078a2c8fced200bdb487cb71020f2/R/ctags-test.R#L110

mpadge commented 2 years ago

@assignUser I can't repeat that error at all, but the above commit removes the line shown above, and implements what should be a safer alternative. I tried with gtags from 6.6.4 on, but all worked fine, so it must be some system quirk on your side. It's nevertheless clearly a bug here, so i still want to get to the bottom of it. If it still occurs for you, then could you please try to reproduce within a docker container. My attempts with different version of global were all done in the rocker/tidyverse container. That should mean that you shouldn't be able to reproduce there, but maybe worth trying regardless? Or maybe within a popOS container? ... or even better, let's just hope you report back that it's fixed :smile: :rocket: :+1:

assignUser commented 2 years ago

Fixed! :tada: