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

7

30

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?

Syllabub answered 6/7, 2015 at 15:39 Comment(12)
What operating system are you on? It looks like you don't have compiler on your machine.Bernie
Ouch! sorry, I'm on Windows 7, R-Studio version 0.99.451, R i386 v.3.2.1. How could I get/install/connect to R a compiler?Syllabub
You need to instal RtoolsFeathered
Which CRAN mirror are you using? Binaries are currently available on CRAN.Berkeleianism
I've installed RTools, I'm using "Global (CDN) - RStudio" as CRAN mirror, and now I've this error: Warning in install.packages : package ‘stringi’ is not available (for R version 3.2.1)Syllabub
Update R to the most recent version.Pinnace
I am using R 3.5 version. I am getting the same error today. How do you resolve it? Anyone? @SyllabubTamp
@xkcvk2511 I'm getting the same error also today with 3.5 but only with data.table. Other packages installed fine - how is it for you? I already tried different mirrors and I have Rtools installed...Davit
@Davit Unfortunately, I can't install Rtools in my laptop. I tried installing data.table 1.10.5 through zip file. I receive the following error. Error: package or namespace load failed for ‘data.table’: package ‘data.table’ was installed by an R version with different internals; it needs to be reinstalled for use with this R versionTamp
@xkcvk2511 Maybe data.table is not available for R 3.5 yet? Do you have problems with different packages?Davit
@Davit I followed the solution of Matt mentioned in comment thread. It works now. #49839053 May be you should give it a go! cheers.Tamp
@xkcvk2511 Thanks, I didn't see that :)Davit
S
28

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:

  1. Brazil http://nbcgib.uesc.br/mirrors/cran/
  2. Italy http://cran.mirror.garr.it/mirrors/CRAN/
  3. Japan http://cran.ism.ac.jp/
  4. South Africa http://r.adu.org.za/
  5. 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.

Stagecraft answered 6/11, 2015 at 11:1 Comment(1)
perfect this works; was driving me nuts since I previously did not have any issue installing packages. I use Rstudio so I just had to change the default.Haney
L
14

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.

enter image description here

Laverne answered 7/11, 2015 at 4:2 Comment(1)
Do you know how to set y or yes as default?Thurstan
C
10

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()

Coupon answered 12/9, 2016 at 19:43 Comment(1)
Following your advice I realized that the package was not available as binary for my older R version. Once I upgraded it, the problem vanished. Thanks!Boondocks
D
2

Install the package from a zip file - downloadable from the r-project website.

In basic R

  1. go to Packages
  2. Install packages from local files.

In RStudio

  1. go to Packages
  2. Install packages
  3. Install from Package Archive File.
Drippy answered 12/9, 2016 at 12:13 Comment(0)
K
1

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.

Kacey answered 24/5, 2019 at 21:29 Comment(0)
M
1

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!

Molest answered 30/3, 2020 at 14:51 Comment(0)
C
0

I had to download the latest version of Rtools:

enter image description here

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")
Coop answered 3/8, 2021 at 11:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.