tidyverse installing error : there is no package called ‘fansi’ - r

I installed 'tidyverse' but it was showing an error.
Error: package or namespace load failed for ‘tidyverse’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
there is no package called ‘fansi’
So I installed 'fansi', and it was showing below.
> install.packages("fansi")
There is a binary version available but the source version is later:
binary source needs_compilation
fansi 0.4.2 0.5.0 TRUE
Do you want to install from sources the package which needs compilation? (Yes/no/cancel) yes
But I received below error message.
* installing *source* package ‘fansi’ ...
** package ‘fansi’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
ERROR: compilation failed for package ‘fansi’
* removing ‘/Library/Frameworks/R.framework/Versions/4.1/Resources/library/fansi’
Warning in install.packages :
installation of package ‘fansi’ had non-zero exit status
I tried to run 'tidyverse' again, but still having the same error.
Do you know what's causing this and how to solve?

In general as a new user, it is much less hassle to just select "No", when presented with the question Do you want to install from sources the package which needs compilation? (Yes/no/cancel) in R.
Explanation of the question by R and responses
The question Do you want to install from sources the package which needs compilation? (Yes/no/cancel) is telling you that one (or more) of the packages you are trying to install has a newer version than what is available as a binary. To understand what this means, you need to understand a bit about the R package ecosystem.
CRAN
The default location where packages are installed from is called CRAN (Comprehensive R Archive Network). This is a web-server (actually many servers world-wide), that has a copy of many R packages. When packages are written for R, they are initially written and submitted to CRAN as source code. The source code submitted to CRAN is then compiled into binary packages for the Windows and Mac OS operating systems.
You could think of it like a clothing shop. You can go to the shop and get a jacket for cold weather, or a hat for sunny weather, or lots of other options.
Binary Packages
Packages are compiled into binaries because they have several advantages: they enable faster installation by end users as the user doesn't need to compile the source code for themselves, which saves them time. They are also easier for users to manage as a user doesn't require extra software or tools, and they tend to be more stable. The downsides however are that the binaries are specific to a particular system, usually an Operating system, and sometimes even particular versions of an operating system. Compiling a package from source takes time, especially if it's a large package. Binaries also (potentially) don't contain the latest version of the code, so there may be bugs that haven't been fixed, or it may be missing new features or additions.
The CRAN Process
When CRAN receives an updated package, it can take a few days to get around to compiling the source code into a binary. In the meantime, if users try to install that package, the message you observed is displayed, giving the user the choice of installing the binary, which is usually much quicker, but may not have some new features or may contain bugs that haven't yet been fixed, or the source code version which is the latest version, but requires the extra tools you discovered.
In the context of a store analogy, you could think of this as new stock for the clothing shop. They have received the new stock, but haven't yet put it out on the racks. You can come back in a few days, or you can find the box (which will need a tool like a knife to open) and unpack it yourself, and then get the item.
Installing from source
As mentioned in the comment by #Bruno, you will need to install Xcode to install packages from source on MacOS or rtools on Windows. Most of the time installing these additional tools is all that's required to build packages from source, but sometimes things may not work so smoothly, which is why installing binaries is usually better.
Aditional note about conflicts
The note you received about conflicts is entirely normal when loading the tidyverse. It's there to alert you to the fact that there are multiple functions with the same name that come from different packages, and this may cause problems if you don't realise. In most cases you don't need to worry about it, but is pretty easy to solve if there are issues.

Related

How to solve an error when loading a package under development from git?

I am trying to install the interference package in R. The package is still under development, so one needs to install it from the website:
devtools::install_github('szonszein/interference', ref='0.1.0')
However, I receive the following error message:
ERROR: dependency ‘randnet’ is not available for package ‘interference’
* removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/interference’
Warning message:
In i.p(...) :
installation of package ‘/var/folders/sw/x2n7fwsj6p32wmcz0dfyk5p40000gn/T//RtmpVf6Xns/file58297d4fcf4a/interference_0.1.0.tar.gz’ had non-zero exit status
Even when I install radnet, however, things do not work. Any advice on how to deal with this?
I just tried that install, and it failed because randnet is not available. interference hasn't been updated in more than 2 years, so I think you'll have some work ahead of you: fork its repository, replace all references to randnet with something that is available.
randnet was removed from CRAN about 6 months ago because the authors were unresponsive to bug reports from CRAN. So an alternative would be to install the most recent (buggy!) version by downloading https://cran.r-project.org/src/contrib/Archive/randnet/randnet_0.5.tar.gz and installing that tar.gz file, but it appears the authors are no longer maintaining it, as is also the case for interference. I'd find a different solution.

How Can I Identify non-R Dependencies in an R Package?

I recently began using RStudio on a Linux system (Ubuntu 20.4) after having used it exclusively on Windows. I realized pretty quickly that a major difference between the two is that R will automatically locate and download non-R dependencies on Windows, but will not do so on Linux. Searching for the dependencies of any given package is easy enough and I'm comfortable with downloading non-R packages through the terminal. What I'm still struggling with, though, is identifying which packages are R packages and which packages are non-R packages and I haven't found a thread that outlines how to do this. I could certainly spend some time googling each, but, as an example, ggpubr alone has over 95 dependent packages that it uses. How can I efficiently determine which non-R dependencies a package needs?
You need to read the DESCRIPTION file. It has a free-form field called SystemRequirements that describes non-standard requirements of the package.
You can see this on the CRAN page, or use the utils::packageDescription() function to see it if you can get the package installed. For example,
cat(utils::packageDescription("rgl")$SystemRequirements)
#> OpenGL, GLU Library, XQuartz (on OSX),
#> zlib (optional), libpng (>=1.2.9, optional), FreeType (optional),
#> pandoc (>=1.14, needed for vignettes; if not present,
#> markdown package will be used)
Created on 2022-04-16 by the reprex package (v2.0.1)
On CRAN this is shown on https://cloud.r-project.org/web/packages/rgl/index.html .
Many packages test for their dependencies and try to give helpful messages about how to install their dependencies if they aren't found. Others just fail to install, sometimes with fairly inscrutable error messages.
The reason this can be easier on Windows is that binary versions of packages are available for Windows. The nice people at CRAN find and install a large number of system dependencies on their own systems, then use those to build binary versions of the package that statically link the required libs. However, some packages can't statically link; they need DLLs of the libs to be installed on the system. Those ones can be quite hard for Windows users to install.

R Studio 1.1.456 (Windows): Why do I sometimes have to install binary packages instead of installing from the source?

I am asking this question because I recently solved a problem installing R Shiny (see below). However, the answers I find don't expand in detail about why this problem occurs and I really want to understand to improve my knowledge of R and why these things happen.
So my attempt to install Shiny in RStudio failed and I believe these are the important error messages:
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
namespace 'httpuv' 1.3.3 is being loaded, but >= 1.4.3 is required
ERROR: lazy loading failed for package 'shiny'
* removing 'C:/Program Files/R/R-3.2.2/library/shiny'
* restoring previous 'C:/Program Files/R/R-3.2.2/library/shiny'
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-32~1.2/bin/x64/R" CMD INSTALL -l "C:\Program Files\R\R-3.2.2\library" C:\Users\Sam\AppData\Local\Temp\RtmpuI3XHe/downloaded_packages/shiny_1.1.0.tar.gz' had status 1
Warning in install.packages :
installation of package ‘shiny’ had non-zero exit status
I went through the usual processes first to find a solution.
Checked my RStudio was up to date
Checked for and installed package updates
Among the further solutions I tried were:
Downloading the package directly from the R Studio interface
Using devtools to install Shiny from Github
Using install.packages("shiny", dependencies=TRUE).
None of these solutions worked and I believe it is to do with the dependency httpuv, but I'm not sure why.
So in the end the code I was able to use is: install.packages('shiny', type = "binary") and this allowed me to begin using Shiny.
While it wasn't too difficult for me to find a work around for this problem, I would really appreciate someone taking some time out of their day to explain why my version of RStudio in Windows (Version 1.1.456) doesn't support the source package of Shiny and why installing the binary package works. I hate fixing an issue but having zero understanding of it.
R version 3.2.2
Thank you.
Binary versus Source Code Options and Issue
You are experiencing the push-pull friction between the old and new code and R environment dependencies. The reality here is you have to choose between stability and progress. It is difficult to have both.
Consider:
You are running R version 3.2.2 in binary form, that R version was released on August 15th 2015. Yet, you are trying to install the latest source code version of Shiny.
There is a 3-year delta between the package source code version and R version you are using. The package code and R environment source code have evolved.
A lot of changes have occurred between then and now in the compile and source code environment.
Think of it this way.
The binary package image is a snapshot of the compile and source code environment assumptions at the time of compilation. If you download the current source code image you are using a snapshot of the current code environment (Now) which includes literally thousands of small incremental changes to the assumptions and dependencies in the source code files and compile environment. if you look in the shiny package description you note:
Shiny depends on httpuv which depends on Rcpp
httpuv is built on top of the libuv and http-parser C libraries.
To get httpuv to compile from source you'll need to match the R Environment, the dependent libraries and source dependencies manually. No small feat.
Case in point to compile the above packages from source code (github) you'll likely be using Devtools which if you download in binary form was compiled under R version 3.2.5.
The changes, assumptions and inter-dependencies make for a complex backport compile situation. Hence, the advantage of binary package snapshots.
Options:
In this situation, you generally have two options. You can either:
Download a source version that is old that matches your R version and environment.
The downside of this approach is you cannot access current package features.
The upside is that the package and R environment match historical context.
Upgrade to a current R environment
The downside of this approach is you have to roll with the R releases.
The upside is that you get to gain access to the latest package features made available in the current source code.
Solution Options:
How to do the above? In the first case, you might use devtools::install_git and pull the source for a particular branch or version of a package and compile it. In the second, you can upgrade your environment, and then pull and upgrade your packages.
If you want to work off a particular R environment version you have to use the binary versions. Why? These will match the R environment version coding environment assumptions.
This is a classic problem highlighting the push-pull between current code and old code. You have to choose between stability and progress. It is difficult to have both.
I hope the above helps explain the situation.

Error in R: (Package which is only available in source form, and may need compilation of C/C++/Fortran)

I'm trying to install the 'yaml' and 'stringi' packages in R-Studio, and it keeps giving me these errors:
> install.packages("stringi")
Package which is only available in source form, and may need compilation of C/C++/Fortran: ‘stringi’
These will not be installed
or
> install.packages('yaml')
Package which is only available in source form, and may need compilation of C/C++/Fortran: ‘yaml’
These will not be installed
How can I get these to install properly?
The error is due to R being unable to find a binary version of the package on CRAN, instead only finding a source version of the package and your Windows installation being unable to compile it. Usually this doesn't occur, but in this case was caused by the (temporary) outage of some of the mirrors at CRAN. If you type:
> getOption('repos')
CRAN CRANextra
"http://cran.rstudio.com" "http://www.stats.ox.ac.uk/pub/RWin"
attr(,"RStudio")
[1] TRUE
You will see that R uses "http://cran.rstudio.com" by default to look for a package to download. If you see the cran mirrors web page you can see at the top that "http://cran.rstudio.com" actually redirects you to different servers world wide (I assume according to the geo location).
When I had the above issue, I solved it by manually changing the repo to one of the urls in the link provided. I suggest you use a different country (or even continent) in case you receive the above error.
I provide below some of the urls in case the link above changes:
Brazil http://nbcgib.uesc.br/mirrors/cran/
Italy http://cran.mirror.garr.it/mirrors/CRAN/
Japan http://cran.ism.ac.jp/
South Africa http://r.adu.org.za/
USA https://cran.cnr.Berkeley.edu/
You need to run the function install.packages as follows:
install.packages('<package_name>', repo='http://nbcgib.uesc.br/mirrors/cran/')
#or any other url from the list or link
One of them should then work to install a binary from an alternative mirror.
You need to install RTools to build packages like this (i.e., a source package rather than a binary). After you install Rtools, then try again to install.packages("ggplot2") and R will prompt you with:
Do you want to attempt to install these from source?
y/n:
(see the picture below)
You need to answer y and it will try to compile the package so it can be installed.
Struggled with this issue today, solved it for now by first downloading the windows binary and then installing e.g.
install.packages("https://cran.r-project.org/bin/windows/contrib/3.3/stringi_1.1.1.zip", repos =NULL)
Just go to https://cran.r-project.org/ and then R Binaries/Windows/contrib and copy the url as argument to install.packages()
Install the package from a zip file - downloadable from the r-project website.
In basic R
go to Packages
Install packages from local files.
In RStudio
go to Packages
Install packages
Install from Package Archive File.
I had this issue when using an out-of-date version of R, so no binaries were available. The simple solution was to update my version of R.
Anything worked for me, until I found out my computer had an old version of R installed. Uninstalling everything and installing the newest R version worked!
I had to download the latest version of Rtools:
Go into the downloads folder and double click it to install it.
Close and reopen any R session.
Now packages should install like normal.
However, if you still have trouble, try installing the package from source (using type="source")
Like this:
install.packages("dplyr", type="source")

R Newbie Confused about Install Packages

I am somewhat new to R, and I thought I understood how to install packages from CRAN mirrors and from source files, but now I am stumped. I currently am using R 2.10.0 on a Windows 7 32-bit machine.
I want to try to use the RGoogleAnalytics package found here and am trying to follow the instructions. They instruct us to install both RCurl and the XML packages from omegahat. For example,
install.packages("RCurl", repos = "http://www.omegahat.org/R")
however this does not work, as I get the following error:
Warning message:
In getDependencies(pkgs, dependencies, available, lib) :
package ‘RCurl’ is not available
When I try this instead:
install.packages("RCurl", repos = "http://www.omegahat.org/R", type="source")
I get the following error after the file downloads. I previously had version 1.0 and that is restored.
trying URL 'http://www.omegahat.org/R/src/contrib/RCurl_1.5-0.tar.gz'
Content type 'application/x-gzip' length 735041 bytes (717 Kb)
opened URL
downloaded 717 Kb
* installing *source* package 'RCurl' ...
Warning in system("sh ./configure.win") : sh not found
ERROR: configuration failed for package 'RCurl'
* removing 'C:/PROGRA~1/R/R-210~1.0/library/RCurl'
* restoring previous 'C:/PROGRA~1/R/R-210~1.0/library/RCurl'
The downloaded packages are in
‘C:\Users\Brock\AppData\Local\Temp\Rtmpc9wt5N\downloaded_packages’
Warning message:
In install.packages("RCurl", repos = "http://www.omegahat.org/R", :
installation of package 'RCurl' had non-zero exit status
Without going into details, I haven't been able to use the RGoogleAnalytics package as I get the same error that is found in this post. I simply am trying to exhaust every possible option to get around the error.
Any help or insight you can provide will be greatly appreciated!
The RCurl project page on CRAN says the Windows binary is not available. The ReadMe points you to a page maintained by Professor Ripley, where he provides binaries of RCurl and several other packages that have special build needs on Windows. However, he only provides them for the most recent major revision of R, so you would need to upgrade to R-2.12.0 to install them from his page.
If you want to build packages from source on Windows, you need to install Rtools first. It looks like you haven't done that. Even if you had them installed, it will still require extra steps to build RCurl on Windows... else the Windows binary would already be on CRAN.
Your best bet is probably to upgrade R and install RCurl from Prof. Ripley's page.
You are probably missing the components to build packages under Windows:
http://www.murdoch-sutherland.com/Rtools/
According to RCurl FAQ, either
curl-config is not found in your path
or
curl-config and related devlopment libraries (libcurl) are not installed.

Resources