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

Definitive to guide to re-installing a package on Windows #62

Open
jennybc opened this issue Oct 22, 2019 · 7 comments
Open

Definitive to guide to re-installing a package on Windows #62

jennybc opened this issue Oct 22, 2019 · 7 comments
Labels
radmin personal R administration

Comments

@jennybc
Copy link
Member

jennybc commented Oct 22, 2019

We have all explained this so many times, referring to the repetitive dance necessary to avoid borked Windows package installs, where the R code gets upgraded but the compiled code does not.

Let's add that content here, with rich section links, so we have a useful place to point to from elsewhere.

@lionel-
Copy link
Collaborator

lionel- commented Oct 22, 2019

Updating packages on Windows with install.packages() can be dangerous. Simply running this command to update a package that contains a DLL file may fail if the DLL is already loaded by R. Unfortunately, failing to update the DLL only causes a warning, leaving the package in a partially installed state. The symptoms of this are varied, but the package won't work properly.

To avoid this:

  • Close all R sessions on your computer. This includes closing all instances of RStudio, Rgui, or R in a shell.

  • If you use RStudio, open a single instance and use "Check for package updates" from the "Tools" menu to launch updates. RStudio will make sure no packages are loaded in memory at the time of installing.

  • Otherwise, run R the usual way, but check with sessionInfo() that no packages are loaded at startup. They could be automatically loaded via your .RProfile. If that is the case, restart R with the --vanilla option.

After updating the package, check that it is correctly installed with:

tools::checkMD5sums("packageName")

@lionel-
Copy link
Collaborator

lionel- commented Oct 22, 2019

@kevinushey Does the advice above sound correct, regarding RStudio?

@jennybc
Copy link
Member Author

jennybc commented Oct 22, 2019

A version of this used by @wch:

Please note that on Windows, it is very important to quit or restart all R processes before upgrading , because if any R process has loaded, it will keep the .dll file open and the installer will not be able to overwrite .dll. The error message when this happens is very easy to overlook, and the new version will be partially installed: the package description and R code will be updated but the compiled code (in .dll) will not.

@jennybc
Copy link
Member Author

jennybc commented Oct 22, 2019

A comment made elsewhere by @kevinushey:

it might also be worth saying that renv helps here

in an renv project library on Windows, packages are normally links (junction points) to a global cache of installed packages, so even if a package is already in use you can still install a new copy of that package (since you're just installing to a new location in the global cache + updating a junction point)

that's probably more infrastructure / workflow than users want to buy into by default, but it was a nice surprising win in renv

@kevinushey
Copy link

kevinushey commented Oct 22, 2019

@lionel- that all looks correct. We're also tracking a similar sort of issue here: rstudio/rstudio#2656

Close all R sessions on your computer. This includes closing all instances of RStudio, Rgui, or R in a shell.

In some cases, a background R process that is hung while a particular package is loaded can also be the culprit. In such cases, the only real solution may be to restart the computer and try again from a clean slate.

@namnp506

This comment has been minimized.

@edavidaja edavidaja added the radmin personal R administration label Jun 11, 2023
@sda030
Copy link

sda030 commented Dec 7, 2023

Hm, my novice colleagues forget this guideline quite often, leading to occasionally worst-case scenarios with broken installations where reinstallation of the entire library seems the easy way out. It gets a bit embarrassing as they come from proprietary software solutions where such things are never an issue. I get that it is not straightforward to disable the update all packages if one is in a project with DLLs loaded, etc.

  1. However, could we at least add a more informative dialog box (especially if clicking update all, which is likely the solution the novice user will pick) which reminds the user to close all open projects and restart a clean state before updating?
  2. Or incorporating pak with a more extensive checking of DLLs into RStudio?
  3. And if the user has an "outdated" (not most recent R version) not list the base R packages in the update-all-packages list? Seems that this is the most common cause for my colleagues. I never face these problems myself as I am almost always up to date with everything (except my work).
    I am getting a bit tired of running around sorting out this problem, haha.

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

No branches or pull requests

6 participants