Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
willgearty opened this issue Oct 4, 2024 · 4 comments
Open

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

willgearty opened this issue Oct 4, 2024 · 4 comments

Comments

@willgearty
Copy link

willgearty commented Oct 4, 2024

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:

pkgstats/R/zzz.R

Lines 4 to 6 in 8d2959a

if (!interactive () || ami::on_cran () || ctags_test ()) {
return ()
}

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:

pkgstats/R/zzz.R

Lines 53 to 55 in 8d2959a

if (!dir.exists ("windows")) {
dir.create ("windows", recursive = TRUE, showWarnings = FALSE)
}

Then it errors because it tries to make a file in a folder that doesn't exist:

pkgstats/R/zzz.R

Lines 56 to 60 in 8d2959a

if (!file.exists (ctags_path)) {
utils::download.file (u, "lib.zip", quiet = TRUE)
utils::unzip ("lib.zip", exdir = "windows")
unlink ("lib.zip")
}

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
Copy link
Member

mpadge commented Oct 4, 2024

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
Copy link

@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
Copy link
Author

@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.

@schneiderpy
Copy link

Hello @mpadge .. do you have any news on this issue?

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

No branches or pull requests

3 participants