r-lib / remotes

Install R packages from GitHub, GitLab, Bitbucket, git, svn repositories, URLs
https://remotes.r-lib.org/
Other
336 stars 153 forks source link

`update_packages()` fails for its own dependencies #613

Closed pnacht closed 3 years ago

pnacht commented 3 years ago

I unfortunately have no idea how to write an MWE for this, but I just ran update_packages() on a new session (no loaded packages). I had some 70+ packages to update, amongst them was curl.

update_packages managed to update many packages, but once it got to curl it failed, saying it was loaded. I assume this is because some curl method is called somewhere along update_packages() (though a quick glance at the source code found nothing), which therefore attaches the package to the environment and therefore fails the update.

I am therefore forced to restart the session, update curl manually with install.packages("curl") and then call update_packages() again to update whatever is left.

I used to run this command using devtools::update_packages(), and would get this issue with multiple packages (rlang, vctrs, etc). Now with remotes it seems to have only been with curl (it's still running in the background).

If my theory is correct, I'd understand if the issue is unavoidable. However, in that case I'd suggest removing remote's dependencies from the update list (so that it won't fail) and then sending the user a warning saying "Unable to update curl, please reset your session and run install.packages("curl").

jimhester commented 3 years ago

You would need to set R_REMOTES_STANDALONE="true" before running the update to ensure that no optional dependencies are loaded in the current R session.

See https://github.com/r-lib/remotes#environment-variables for documentation on this and other available environment variables.

pnacht commented 3 years ago

For my education: why this isn't set by an argument to the function, instead of relying on an environment variable?

Or, even better, wouldn't it be possible to check the list of updates and, if a dependency is found, silently set standalone mode (or ask the user for permission)?