ropensci-review-tools / pkgstats

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

pkgstats does not install ctags or gtags properly on Windows #65

Open willgearty opened 12 hours ago

willgearty commented 12 hours ago

Just wanted to echo the issues that @schneiderpy was experiencing in #63 and #64. Upon installing and loading pkgstats, I also got this error:

Error: package or namespace load failed for ‘pkgstats’:
 .onAttach failed in attachNamespace() for 'pkgstats', details:
  call: NULL
  error: No ctags installation found.

I further investigated the issue, and found that the .onAttach function never passes this check: https://github.com/ropensci-review-tools/pkgstats/blob/8d2959a772f5d7364282be260ba6d533bcc75474/R/zzz.R#L4-L6

This is because ctags_test() does not return a boolean value, it throws an error, which causes .onAttach to end abruptly, never making it past line 6. Therefore, the package never prompts the user to install ctags.

I tried installing ctags using install_ctags_windows(), but this also didn't work. The zip file is downloaded correctly, but then the code makes a folder in the working directory instead of the package's directory: https://github.com/ropensci-review-tools/pkgstats/blob/8d2959a772f5d7364282be260ba6d533bcc75474/R/zzz.R#L53-L55

Then it errors because it tries to make a file in a folder that doesn't exist: https://github.com/ropensci-review-tools/pkgstats/blob/8d2959a772f5d7364282be260ba6d533bcc75474/R/zzz.R#L56-L60

Now, if you manually make this folder, it will correctly unzip the file, but then it doesn't add the folder to the system PATH, which means Sys.which("ctags"), and thus has_ctags(), never works.

It also appears that there is currently no functionality in the package to install gtags on Windows (the only function is only for Unix), even once you have ctags installed and on the PATH. I was able to find a compiled version of gtags (GLOBAL?) for Windows, but it was on a somewhat sketchy site, and there were no instructions in pkgstats to affirm whether I was installing the correct software.

Ultimately, I have manually installed both pieces of software, but now I'm getting this error:

Error: package or namespace load failed for ‘pkgstats’:
 .onAttach failed in attachNamespace() for 'pkgstats', details:
  call: system(cmd, intern = TRUE)
  error: 'export' not found

But it seems that pkgcheck is now working (why I installed pkgstats in the first place), so I'm done debugging for now.

This package seems great, but right now the installation process is quite a chore, especially without any documentation to guide the user. Hope this all helps! (I'm happy to help test on Windows if that is a limiting factor)

mpadge commented 11 hours ago

Thanks so much@willgearty! The most helpful step would be if you could submit a PR with fixes for widows. (The .onAttach one i can easily fix, but less so the install issues.)

schneiderpy commented 10 hours ago

@willgearty since we are both on Windows, did you also observe the "00LOCK-" file mentioned in #64? (installing to C:/Users/Acer/AppData/Local/R/win-library/4.4/00LOCK-pkgstats/00new/pkgstats/libs/x64) which usually prevent packages to install/update. Would be interesting to see if the installation works on MacOS.

willgearty commented 10 hours ago

@schneiderpy I did not observe that issue when installing. I've found that uninstalling the package (remove.packages())and then fully closing R and reopening it usually resolves that problem.

@mpadge I'm not too familiar with installing external software as part of R packages, but I'll see if I can find some time to put together a PR.