I recently installed R on Ubuntu 16.04 and tried installing a package that I need:
install.packages('gimme')
The dependencies seem to download fine but their installation is where the errors pop. Even tho g++ is installed for example, R can't seem to use it:
* installing *source* package ‘nloptr’ ...
** package ‘nloptr’ successfully unpacked and MD5 sums checked
checking for g++... no
checking for c++... no
checking for gpp... gpp
checking whether the C++ compiler works... no
configure: error: in `/tmp/Rtmpq1Yg7t/R.INSTALLedf3b8432e7/nloptr':
configure: error: C++ compiler cannot create executables
See `config.log' for more details
ERROR: configuration failed for package ‘nloptr’
* removing ‘/usr/local/lib/R/site-library/nloptr’
From what I can tell it looks like R can't find the compilers on my system, but I can't seem to find out how to fix this. I installed the package on a windows machine just fine.
Any experience setting up and installing R packages on Ubuntu?
apt-get install --reinstall g++
made all the difference. was missing the --reinstall flag
Related
I would like to install a package from my local environment. I have a mac and tried with both R 4.0.0 and R 3.6.3 and encounter the same issues with both R versions. When installing the package I get the following error and I do not know what to make out of this. Can anyone help interpreting it and suggest possible sources for this problem?
* installing *source* package ‘package’ ...
** using staged installation
checking whether the C++ compiler works... no
configure: error: in `/private/tmp/RtmpCtsuxn/R.INSTALL3d701f92995/goldfish':
configure: error: C++ compiler cannot create executables
See `config.log' for more details
ERROR: configuration failed for package ‘package’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/package’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/package’
Warning in install.packages :
installation of package ‘/Users/simon/Downloads/package_1.4.1.tar’ had non-zero exit status
After updating to R 4.0.0 on my Windows machine, I can't install some packages such as xml2 (the same goes for foreign and nnet). When I try to install I get this error message:
* installing *source* package 'foreign' ...
** package 'foreign' successfully unpacked and MD5 sums checked
** using staged installation
** libs
*** arch - i386
"c:/rtools40/mingw32/bin/"gcc -I"C:/PROGRA~1/R/R-40~1.0/include" -DNDEBUG -O2 -Wall -std=gnu99 -mfpmath=sse -msse2 -mstackrealign -c R_systat.c -o R_systat.o
sh: c:/rtools40/mingw32/bin/gcc: No such file or directory
make: *** [C:/PROGRA~1/R/R-40~1.0/etc/i386/Makeconf:222: R_systat.o] Error 127
ERROR: compilation failed for package 'foreign'
* removing 'C:/R-PKGS/win-library/3.6/foreign'
* restoring previous 'C:/R-PKGS/win-library/3.6/foreign'
Warning in install.packages :
installation of package ‘foreign’ had non-zero exit status
The main reason for installing the xml2 package is that I want to use the tidyverse package, but when I try to run library(tidyverse) I get this message:
Error: package or namespace load failed for ‘tidyverse’:
package ‘xml2’ was installed before R 4.0.0: please re-install it
So I guess that I will have to be able to solve the problem that occurs when I try to install the xml2 package as it may occur in the future when other packages will have to be updated.
Kind regards, Andrés
R 4.0 on Windows is accompanied with a new tool set rtools40 that can be installed separately. The tool set contains compilers and other programming tools to install source code packages on Windows, while the compilers are usually already available on Linux systems. The tool set can be installed from CRAN, but it is usually not necessary, if only pre-compiled "binary packages" are installed.
An additional confusion can sometimes occur if packages from different versions of R are installed in the same folder, the so-called "personal library", in Windows by default:
c:\users\<username>\R\win-library
... or another user-specified folder. After updating to a new R version, it can be a good idea to clean up older win-libraries. Make sure, that the folders do not contain valuable personal data.
Im using anaconda, so RStudio 1.1.456.
When I try to
install.packages("igraph")
I get this message:
trying URL 'https://cran.rstudio.com/src/contrib/igraph_1.2.4.1.tar.gz'
Content type 'application/x-gzip' length 2704004 bytes (2.6 MB)
==================================================
downloaded 2.6 MB
* installing *source* package ‘igraph’ ...
** package ‘igraph’ successfully unpacked and MD5 sums checked
** using staged installation
checking for gcc... x86_64-apple-darwin13.4.0-clang
checking whether the C compiler works... no
configure: error: in `/private/var/folders/x1/zlhhtxm951v95d461h7d09bc0000gn/T/Rtmp0iNakh/R.INSTALL16a5d3eb16782/igraph':
configure: error: C compiler cannot create executables
See `config.log' for more details
ERROR: configuration failed for package ‘igraph’
* removing ‘/Users/RobinHorn/anaconda3/envs/Data_Analysis/lib/R/library/igraph’
Warning in install.packages :
installation of package ‘igraph’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/x1/zlhhtxm951v95d461h7d09bc0000gn/T/RtmpYbzkOw/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
So it looks like my C compiler is not working.
What I tried already:
installing command line tools
xcode-select --install
installing missing headers:
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
This results in:
installer: Error - the package path specified was invalid: '/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg'.
gcc seems to be installed correctly:
~ % gcc -v
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.0 (clang-1100.0.33.12)
Target: x86_64-apple-darwin19.0.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
~ %
I ran across your post because I had the same problem. My answer hinges on one question: do you really need to access RStudio through Anaconda? If your answer is "no," then the solution is simple:
I downloaded RStudio from rstudio.com and installed it directly on my Mac; the version happens to be 1.2.5033. Now when I install
install.packages("igraph")
everything works fine. I have tested several functions with no problem (but don't forget to load the package).
Note that when I return to RStudio through Anaconda, it still does not work. Apparently, Anaconda keeps its own copy of the install tree but does not play nicely with certain packages ...
When I try to install the package RGtk2 I get the following error:
> install.packages("RGtk2")
Package which is only available in source form, and may need
compilation of C/C++/Fortran: ‘RGtk2’
Do you want to attempt to install these from sources?
y/n: y
installing the source package ‘RGtk2’
trying URL 'https://cran.rstudio.com/src/contrib/RGtk2_2.20.33.tar.gz'
Content type 'application/x-gzip' length 2792938 bytes (2.7 MB)
==================================================
downloaded 2.7 MB
* installing *source* package ‘RGtk2’ ...
** package ‘RGtk2’ successfully unpacked and MD5 sums checked
checking for pkg-config... /usr/local/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for INTROSPECTION... no
checking for GTK... no
configure: error: GTK version 2.8.0 required
ERROR: configuration failed for package ‘RGtk2’
* removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/RGtk2’
Warning in install.packages :
installation of package ‘RGtk2’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/m4/l02774c51vx71qt6_wdq59lw0000gn/T/Rtmpa7sxIS/downloaded_packages’
>
I am running macOS Sierra (Version 10.12.4) and R version 3.4.0.
I assume you have R and RStudio installed already. If not, install it. Then do the following.
1) Install XQuartz
2) Install GTK 2.24.17-X11
3) Download cairoDevice and RGtk2
4) From terminal run R CMD INSTALL ~/Downloads/cairoDevice_2.24.tar.gz
5) Install Homebrew for Mac.
6) From terminal type the following commands:
brew uninstall cairo --ignore-dependencies
brew install --with-x11 cairo
7) Type brew edit gtk+ in terminal and scroll to def install section and edit the reference with quartz to (press i to edit and to save and exit, press escape key and type colon (shift+ semi colon key). Then type wq.)
"--with-gdktarget=x11",
"--enable-x11-backend"
8) Then type brew install --build-from-source --verbose gtk+ in the same terminal window.
9) Then type export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib/pkgconfig/gtk+-2.0.pc:/opt/X11/lib/pkgconfig
10) Type R CMD INSTALL ~/Downloads/RGtk2_2.20.33.tar.gz from the same terminal window.
Hopefully it will work for you.
You probably don't have GTK installed in your system (outside of R). You can try an install from the GTK package in the ../libs/ directory here:
http://r.research.att.com/libs/
Probably need XQuartz, Xcode of the proper version for your macOS version and the correct Command Line Tools first. The download and install code for the bash-install are at the bottom of that /libs/ page.
when I tried to install RGtk2 this comes up... I checked which gcc and it shows a c compiler. why does it say that C compiler is not working?
$ R CMD INSTALL ~/Downloads/RGtk2_2.20.33.tar.gz
* installing to library ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library’
* installing *source* package ‘RGtk2’ ...
** package ‘RGtk2’ successfully unpacked and MD5 sums checked
checking for pkg-config... /usr/local/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for INTROSPECTION... no
checking for GTK... yes
checking for GTHREAD... yes
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/private/var/folders/xh/kw0cr4xj52zd9pd8t46d6xwh0000gn/T/RtmpnYEC6D/R.INSTALL13a7b3357df80/RGtk2':
configure: error: C compiler cannot create executables
See `config.log' for more details.
ERROR: configuration failed for package ‘RGtk2’
* removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/RGtk2’
Following the directions on this website will likely be helpful: https://gist.github.com/sebkopf/9405675.
Be sure to read the additional conversations after the post for useful modifications.
I'm trying to install the gsl package for R, which I understand is simply a wrapper around the GSL, under OSX Mavericks. I've tried the obvious:
> install.packages('gsl')
Installing package into ‘/Users/myusername/Library/R/3.1/library’
(as ‘lib’ is unspecified)
package ‘gsl’ is available as a source package but not as a binary
Warning in install.packages :
package ‘gsl’ is not available (for R version 3.1.0)
So I ran
> install.packages('gsl',type = 'source')
Installing package into ‘/Users/myusername/Library/R/3.1/library’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/gsl_1.9-10.tar.gz'
Content type 'application/x-gzip' length 342803 bytes (334 Kb)
opened URL
==================================================
downloaded 334 Kb
* installing *source* package ‘gsl’ ...
** package ‘gsl’ successfully unpacked and MD5 sums checked
checking for gsl-config... no
configure: error: gsl-config not found, is GSL installed?
ERROR: configuration failed for package ‘gsl’
* removing ‘/Users/myusername/Library/R/3.1/library/gsl’
Warning in install.packages :
installation of package ‘gsl’ had non-zero exit status
No GSL install. D'oh! So I install GSL via Homebrew:
~ brew install gsl
==> Downloading http://ftpmirror.gnu.org/gsl/gsl-1.15.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/gsl/1.15
==> make
==> make install
/usr/local/Cellar/gsl/1.15: 239 files, 6.7M, built in 101 seconds
Try to install the R package again:
> install.packages('gsl',type = 'source')
Installing package into ‘/Users/myusername/Library/R/3.1/library’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/gsl_1.9-10.tar.gz'
Content type 'application/x-gzip' length 342803 bytes (334 Kb)
opened URL
==================================================
downloaded 334 Kb
* installing *source* package ‘gsl’ ...
** package ‘gsl’ successfully unpacked and MD5 sums checked
checking for gsl-config... /usr/local/bin/gsl-config
checking if GSL version >= 1.12... checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
configure: error: Need GSL version >= 1.12
ERROR: configuration failed for package ‘gsl’
* removing ‘/Users/myusername/Library/R/3.1/library/gsl’
Warning in install.packages :
installation of package ‘gsl’ had non-zero exit status
I'm obviously going about this the wrong way but am unsure about where exactly the problem lies.
I was able to get things working (OS X Yosemite 10.10, R 3.1.1, gsl 1.16, gsl R package 1.9-10) with standard brew-installed R and gsl by manually prefixing CFLAGS and LDFLAGS with the output from gsl-config --cflags and gsl-config --libs respectively.
The following:
CFLAGS="-I/usr/local/opt/gsl/include" LDFLAGS="-L/usr/local/opt/gsl/lib -lgsl -lgslcblas" R
...
> install.packages("gsl")
worked for me.
Note that gsl-config lists the direct path to my Cellar, the paths above are brew symlinks.
For Mac, just run:
brew install gsl
then install the package in r
I finally got this to work though I'm not sure which parts of the following are absolutely essential. Here's a step-by-step list of instructions:
(steps in parentheses may be optional. Perhaps the whole thing works with homebrew)
(download the latest version of the GSL from http://ftp.gnu.org/gnu/gsl/ (as of this writing the file to get is gsl-1.16.tar.gz))
(open up a terminal window, untar the file, cd into the directory and then run ./configure, make and make install)
download the sources to the R package from http://cran.r-project.org/web/packages/gsl/index.html
open up a terminal window and run launchctl setenv PATH "/usr/local/bin:$PATH"
in the same terminal window, build the R package (I couldn't get this to work from within R) by untar'ing the file just downloaded, cding into the directory and then running R CMD build ./gsl and R CMD INSTALL gsl_1.9-10.tar.gz
Note to self: On Debian, to fix
checking for gsl-config... no
configure: error: gsl-config not found, is GSL installed?
I needed to
sudo apt-get install libgsl-dev
Note that the package name on Debian is not gsl-devel as elsewhere. Sigh.
I believe that others will find your steps successful and I think they do need to be done in that order. The build of gsl from source does need to be done after adding the homebrew default directory to the path. If you had used the binary, it was built on a CRAN machine that was able to find the (external) GSL package in the expected directy (which is not the default for homebreww installations. You might have succeeded with `install.packages('gsl_1.9-10.tar.gz', repo=NULL, type="source") if the source package were in your working directory (or add the full path/name as the first argument.) Just as with using Terminal, if you click-hold-drag a file to the R console, you will get a text entry of the full path/name.
gsl-config in included with the gsl-devel package, try installing that. After that it should work
On OS X Mavericks at least, after installing gsl via brew install gsl, the gsl-config --prefix yields /usr/local/Cellar/gsl/1.16. However, many applications/libraries like gsll for Common Lisp (in my case) expect /usr/local/Cellar/gsl/1.16/lib instead. In my case, the super lazy (long-term unacceptable) solution was just to symlink the libs from /usr/local/Cellar/gsl/1.16/lib into /usr/local/Cellar/gsl/1.16 and all was well. Hope this helps.