Conflicting packages

package-installation
packages

#1

Greetings.

Please correct me if I am wrong but it looks like evaluate is brought in through another package which also brings in stringr but a different version. Is there a way to find out what brought in evaluate or check up front for package conflicts like this?

When working in RStudio I have never had this come up before. Running the same code in a notebook in IBM Watson I get.....
" # Package 'stringr' version 1.3.0 cannot be unloaded: Error in unloadNamespace(package) : namespace 'stringr' is imported by 'evaluate' so cannot be unloaded "

Thanks for helping me


#2

Hi! Welcome!

I'm afraid I'm having trouble getting the whole picture of your question — a little more context might be helpful! For example:

  • When you ran your code in RStudio, was that on your local computer? Or somewhere else? (e.g., an RStudio Server installation)
  • What packages are you loading explicitly (via library() calls)?
  • What code are you trying to run when you get this error message? Are you trying to install stringr?
  • sessionInfo() output might also be helpful here

stringr is a dependency of evaluate, as you can see from the CRAN listing (it appears under "Imports"). You can also see that evaluate is itself a direct dependency of several other packages (look under "Reverse imports" and "Reverse suggests"), and of course it will be an indirect dependency of any packages that depend on those ones.

But evaluate doesn't bring along a specific older version of stringr — it just requires a minimum version. If you have an older version of stringr installed than you're expecting, remember that the package library on your cloud platform is completely separate from the library on your local machine (unless you are using something like packrat to carry a library snapshot along with your code).

If you're trying to install a newer version of stringr, you need to do that in a fresh session without any packages loaded (other than the base defaults). This might require restarting your Jupyter kernel and making sure you don't run any cells that load packages via library() or require(). In general, it's safest to install packages in a fresh R session and restart the session after installing, as well. Package installation code (install.packages() statements) should not usually be part of your analysis scripts.


#3

I have loaded the packages below.
When I run the below on a local instance in RStudio on my laptop I have no issue.
However, when I am in trying to load in a notebook in watson cloud I get the below.
It looks like another package brought in an older version of stringr
It should be noted i'm still learning this so I think i might be trying to load packages that are already being loaded because they are dependent on another.
example... stringr contains stringi, so I should probably not be doing library(stringi) because i'm doing library(stringr).

library(rvest)
library(dplyr)
library(stringr)
library(qdap)
library(stringdist)
library(parallel)
library(htmltab)
library(edgar)
library(stringi)
Error in value[[3L]](cond): Package ‘stringr’ version 1.2.0 cannot be unloaded:
 Error in unloadNamespace(package) : namespace ‘stringr’ is imported by ‘evaluate’ so cannot be unloaded

Traceback:

1. library(stringr)
2. tryCatch(unloadNamespace(package), error = function(e) {
 .     P <- if (!is.null(cc <- conditionCall(e))) 
 .         paste("Error in", deparse(cc)[1L], ": ")
 .     else "Error : "
 .     stop(gettextf("Package %s version %s cannot be unloaded:\n %s", 
 .         sQuote(package), oldversion, paste0(P, conditionMessage(e), 
 .             "\n")), domain = NA)
 . })
3. tryCatchList(expr, classes, parentenv, handlers)
4. tryCatchOne(expr, names, parentenv, handlers[[1L]])
5. value[[3L]](cond)
6. stop(gettextf("Package %s version %s cannot be unloaded:\n %s", 
 .     sQuote(package), oldversion, paste0(P, conditionMessage(e), 
 .         "\n")), domain = NA)

#4

I figured out what my issue was.

I was loading packages that required an updated version of other packages that were already in the cloud library. I used the code below to bypass the native package IBM holds and download the most to date package from CRAN.

install.packages("package name",dependencies = TRUE, repos = "http://cran.us.r-project.org")