How to upgrade a package when using packrat

Hello,

If I want to upgrade the version of the package in my packrat enabled library, how do I do that?

I tried the following:

packrat::off()
install.packages("pkgname")
packrat::on()
packrat::restore()

But that seems to still try to restore the version of package that was previously in packrat and not the upgraded version.

I would appreciate any help on this.

Thanks,
Shankar

From my understanding you should write

packrat::on()
install.packages("pkgname")
packrat::snapshot()

restore() instead of snapshot() would bring u to the old state of your packrat library. Also packrat::on() might not be needed since you should be in packrat mode normally always when you are in a packrat project.

1 Like

Sorry for the very delayed response. Thanks for your suggestion.

Hi,

the suggestion seems to be the correct way to upgrade package in packrat lib.
Know also that packrat::packrat_lib() contains the path to the packrat private library. It can be useful.

If it is working for you, can you mark your question as solved

It will help other knows the status of the question right from the list of question or by searching for related topic.

Thank you.

I edited your post to add a more readable formatting