Unable to install any packages - "Package which is only available in source form, and may need compilation" - "installation of package ‘...’ had non-zero exit status"

I'm trying to install packages but it doesn't work and I don't know why. I use the install.packages() function.

install.packages("ggplot2")

And then I get:

also installing the dependencies ‘isoband’, ‘rlang’
There are binary versions available but the source versions are later:
binary source needs_compilation
rlang 0.1.6 0.4.7 TRUE
ggplot2 2.2.1 3.3.2 FALSE

Do you want to install from sources the package which needs compilation?
y/n: y

and after that:

Package which is only available in source form, and may need compilation
of C/C++/Fortran: ‘isoband’
Do you want to attempt to install these from sources?
y/n: y

It doesn't matter if I select yes or no, it always does the same and in the end it says:

Warning in install.packages :
installation of package ‘ggplot2’ had non-zero exit status
The downloaded source packages are in ‘/private/var/folders/87/5r3pmptj43l2kkcv9nvhqchr0000gn/T/RtmpkqxLoS/downloaded_packages’

When I then type

library(ggplot2)

I get the warning that there is no ggplot2 installed.
I used ggplot2 as an example but it is the same with any package I try to install. I'm using an older MacBook.

Thanks a lot for any advice!

Must be some error in the internet connection. Please try again later sometime.

thanks a lot for your reply. I think it's unlikely that it's the internet connection, I have a stable connection and tried several times also after restarting the laptop and re-installing R Studio.

I've run into this type of error before, and seen others with it.

I've often found that if I individually install the packages the error message is complaining about, I'm then able to get my end-goal package installed. And if I'm struggling to get those dependencies installed, I'll at least get a bit more information about what is causing the trouble.

So, I'd suggest

install.packages("isoband")
install.packages("rlang")

Windows: Also, very likely, you need to install Rtools.
These error messages ("Package which is only available in source form, and may need compilation") may mean your machine doesn't have a compiler. If that's the case, install Rtools

Mac UPDATE, sorry, you said you're on a Mac -- Rtools is for Windows.
You'll want to make sure you have Xcode. Instructions on installing that here
https://www.r-project.org/nosvn/pandoc/devtools.html

Thanks a lot for the suggestion! Unfortunately, that didn't work either. When I try

install.packages("isoband")
install.packages("rlang")

I get the same error message:

install.packages("isoband")
Package which is only available in source form, and may need compilation of C/C++/Fortran: ‘isoband’
Do you want to attempt to install these from sources?
y/n: y
installing the source package ‘isoband’
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed
100 2242k 100 2242k 0 0 6653k 0 --:--:-- --:--:-- --:--:-- 6633k
Warnung in strptime(xx, f <- "%Y-%m-%d %H:%M:%OS", tz = tz)
unknown timezone 'zone/tz/2020a.1.0/zoneinfo/Europe/Zurich'

  • installing source package ‘isoband’ ...
    ** Paket ‘isoband’ erfolgreich entpackt und MD5 Summen überprüft
    ** libs
    xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
    ERROR: compilation failed for package ‘isoband’
  • removing ‘/Library/Frameworks/R.framework/Versions/3.2/Resources/library/isoband’
    Warning in install.packages :
    installation of package ‘isoband’ had non-zero exit status

The downloaded source packages are in ‘/private/var/folders/87/5r3pmptj43l2kkcv9nvhqchr0000gn/T/RtmpxvP5Pf/downloaded_packages’

And then I tried installing Xcode, but again, for that I would need to install the package "devtools" which gives the same error message... it's kind of a vicious circle :')

You don't need devtools to install XCode or Xcode Command Line Tools. Those are part of the toolchain on your OS, not part of your R installation or R packages.

The line involving devtools here is just one way you can check and see if you have the necessary system requirements, it's not actually related to installing what you need:

1 Like

Thanks a lot! I will see if it works when I have installed Xcode then.

Hi, rahelb!
Have you managed to solve the problem? I have the same

hey there, no, not yet, because I have problems installing Xcode (or Xcode Command Line Tools)... what kind of notebook do you use?

I'm using an old macbook air (mid 2012, 1.8Ghz i5, 4gb, 128, Catalina 10.15.7)
I've managed to install Xcode via Appstore, but have no idea what should I do next

Check out this link
https://thecoatlessprofessor.com/programming/cpp/r-compiler-tools-for-rcpp-on-macos/

Pick the link at the top of that page based on your version of R

1 Like

Seems, like I've managed, rahelb.
I made next (surpisingly simple) things:

  1. registered on AppStore and downleaded Xcode.
  2. downloaded the last version of R language, that is 4.0.2
  3. deleted and installed Rstudio.
  4. installed needed packages (devtools and tidyverse(choosed n to compiling) )

Thank you, EconProf! I'll check it.

After described operations it possible to install packages you've mentioned: isoband and rlang(yes to compiling, but decided not to restart R from Rstudio, beacuse begins endless cycle).

> install.packages("isoband")
пробую URL 'https://cran.rstudio.com/bin/macosx/contrib/4.0/isoband_0.2.2.tgz'
Content type 'application/x-gzip' length 4016637 bytes (3.8 MB)
==================================================
downloaded 3.8 MB


The downloaded binary packages are in
	/var/folders/_p/_lmvdgh976g_f1t83hx_bl9h0000gn/T//Rtmp56sEI1/downloaded_packages
> install.packages("rlang")
Error in install.packages : Updating loaded packages

Restarting R session...

> install.packages("rlang")
Error in install.packages : Updating loaded packages

Restarting R session...

> install.packages("rlang")
Error in install.packages : Updating loaded packages

Restarting R session...

> install.packages("rlang")
Error in install.packages : Updating loaded packages

Restarting R session...

> install.packages("rlang")
Error in install.packages : Updating loaded packages
> install.packages("rlang")

  There is a binary version available but the source version is
  later:
      binary source needs_compilation
rlang  0.4.7  0.4.8              TRUE

Do you want to install from sources the package which needs compilation? (Yes/no/cancel) y
installing the source package ‘rlang’

пробую URL 'https://cran.rstudio.com/src/contrib/rlang_0.4.8.tar.gz'
Content type 'application/x-gzip' length 847517 bytes (827 KB)
==================================================
downloaded 827 KB

* installing *source* package ‘rlang’ ...
** пакет ‘rlang’ удачно распакован, MD5 sums проверены
** using staged installation
** libs
clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I./lib/  -I/usr/local/include   -fPIC  -Wall -g -O2  -c capture.c -o capture.o
clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I./lib/  -I/usr/local/include   -fPIC  -Wall -g -O2  -c export.c -o export.o
clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I./lib/  -I/usr/local/include   -fPIC  -Wall -g -O2  -c internal.c -o internal.o
clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I./lib/  -I/usr/local/include   -fPIC  -Wall -g -O2  -c lib.c -o lib.o
clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I./lib/  -I/usr/local/include   -fPIC  -Wall -g -O2  -c version.c -o version.o
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o rlang.so capture.o export.o internal.o lib.o version.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing to /Library/Frameworks/R.framework/Versions/4.0/Resources/library/00LOCK-rlang/00new/rlang/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (rlang)

The downloaded source packages are in
	‘/private/var/folders/_p/_lmvdgh976g_f1t83hx_bl9h0000gn/T/RtmpucH7nJ/downloaded_packages’
> libra("rlang")
Ошибка в libra("rlang") :не могу найти функцию "libra"
> library("rlang")
Ошибка: package or namespace load failed for ‘rlang’ in get(method, envir = home):
 lazy-load database '/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rlang/R/rlang.rdb' is corrupt
Вдобавок: Предупреждение:
В get(method, envir = home) : internal error -3 in R_decompress1

Thanks a lot for the update! And great to hear that it worked for you. I will try it again – what is R language?

Sorry, I don't understand the question. Do you mean which version?

Sorry, no, I don't know what you mean by "I downloaded R language". Is that an application or something you downloaded in Xcode?

Oh, sorry for my english. I mean the software for the R language itself.
https://www.r-project.org/

And now I finally found out what my problem was! Even though I had the newest version of Rstudio, I did not install the newest version of R (I didn't use this laptop for a few years and didn't think about updating this one).
Problem solved :smiley:

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.