Installing packages from source fails with "unexpected $end" error - r

This one is killing me:
Problem: I can't install any packages in R from source code using standard repositories.
install.packages("quantreg", type="source")
Installing package into ‘/Users/foo/Library/R/3.0/library’
(as ‘lib’ is unspecified)
trying URL 'http://cran.wustl.edu/src/contrib/quantreg_5.05.tar.gz'
Content type 'application/x-gzip' length 1636075 bytes (1.6 Mb)
opened url
downloaded 1.6 Mb
Error: 1:5: unexpected $end
Execution halted
The downloaded source packages are in
‘/private/var/folders/h3/yfhgnv7n5gq84ly4kr6334gr0000gn/T/Rtmp3kothF/downloaded_packages’
Warning message:
In install.packages("quantreg", type = "source") :
options("unzip")
$unzip
[1] "internal"
Details
OS: OSX.9
I made a clean install of Mavericks and installed Xcode 5 + command line tools.
R: 3.0.2 installed from CRAN binary
I realize that I could install binary packages for "quantreg", but that's not the point.
Question: How can I fix this?
I've tried:
installing R from source (actually, this is how I first noticed the problem)
1b. installing R from source using clang and clang++
modifying /Library/Frameworks/R.framework/Versions/3.0/Resources/etc/Makeconf file to change CC and CXX to clang, clang++
Voodoo
Obviously, none of these things worked for me. Am I just doing something naively stupid? Use small words in simple sentences, please.
UPDATE:
Using the r-sig-mac archives, there was some stuff that was appropriate regarding the incredible, dissapearing GNUTAR. I also found on my own some problems with the gfortran call. I made some headway (but still not solved) by adding the following lines to my "/Users/foo/.R/Makevars" file
TAR=/usr/bin/tar
FC=/usr/local/bin/gfortran
F77=/usr/local/bin/gfortran
FLIBS = -L/usr/local/lib/gcc/i686-apple-darwin8/4.2.3/x86_64 -L/usr/local/lib/x86_64 -L/usr/local/lib/gcc/i686-apple-darwin8/4.2.3
Note that this removes the "-lgfortran" option from FLIBS.
Now, the packages will install using R CMD INSTALL /path/to/source.tar.gz (which is new), but still won't work using my original command in R.

Related

installation of package ‘rmarkdown’ had non-zero exit status - How to solve that?

I am trying to install ‘rmarkdown’ in my RStudio Version 1.4.904 and R version 4.0.3 but getting the following error. I cannot open a new rmarkdown and knit a rmarkdown file. Every time I try, this message pops up,
R Markdown documents requires an updated version of the rmarkdown package. Do you want to install this package now?
Can anyone help me with that?
install.packages(ç, dependencies=TRUE)
Installing package into ‘/Users/Library/R/4.0/library’
(as ‘lib’ is unspecified)
There is a binary version available but the source version is later:
binary source needs_compilation
rmarkdown 2.3 2.4 FALSE
installing the source package ‘rmarkdown’
trying URL 'http://cran.utstat.utoronto.ca/src/contrib/rmarkdown_2.4.tar.gz'
Content type 'application/x-gzip' length 3202546 bytes (3.1 MB)
==================================================
downloaded 3.1 MB
Warning in file(con, "r") :
cannot open file '/var/db/timezone/zoneinfo/+VERSION': No such file or directory
dyld: lazy symbol binding failed: Symbol not found: _utimensat
Referenced from: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libR.dylib (which was built for Mac OS X 10.13)
Expected in: /usr/lib/libSystem.B.dylib
dyld: Symbol not found: _utimensat
Referenced from: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libR.dylib (which was built for Mac OS X 10.13)
Expected in: /usr/lib/libSystem.B.dylib
/Library/Frameworks/R.framework/Resources/bin/INSTALL: line 34: 30112 Done echo 'tools:::.install_packages()'
30113 Abort trap: 6 | R_DEFAULT_PACKAGES= LC_COLLATE=C "${R_HOME}/bin/R" $myArgs --no-echo --args ${args}
Warning in install.packages :
installation of package ‘rmarkdown’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/70/lgr12kdn6wn_k36sscnc0_dw0000gn/T/Rtmpmc0jUR/downloaded_packages’```
download the binary tgz (https://cran.r-project.org/web/packages/rmarkdown/index.html) and install directly from it.
It should work. I had pretty much the same issue and I solved it that way. Keep me posted!
F
I also faced a similar problem and I spent a half-day on getting the correct solution.
Step I followed:
Uninstalled the existing version
Installed updated version of R - R version 4.0.4 (2021-02-15).
Clicked on File->New file->R markdown. It asked to install Rmarkdown packages.
Noted the packages I need to install
Typed install.packages("rmarkdown", dependencies = TRUE) on R source(can be done on R console)
Then I tried installing Rmarkdown packages individually and it worked for me. Below are the packages I needed to install.
install.packages('knitr')
install.packages('tinytex')
install.packages('base64enc')
install.packages('digest')
install.packages('jsonlite')
install.packages('htmltools')
install.packages('rmarkdown')
A somewhat more technical workaround but it worked for me.
Go to https://cran.r-project.org/ select "Packages" from the menu on the right and navigate until you find the package you need.
Download the binary.zip file for your operating system and extract the files.
Copy the extracted folder into the installation directory for your packages. It should be shown somewhere in the error messages from where you attempted to install the package originally. Replace any existing files. Restart RStudio to recognize the updated versions.

What does this error mean when I try and install the Mosaic package in R?

When I try and install the mosaic package in R studio, I get the following messages:
> install.packages('mosaic', dependencies = TRUE)
Warning in install.packages :
dependencies ‘latticeExtra’, ‘fastR’ are not available
also installing the dependency ‘rgl’
There are binary versions available but the source versions are later:
binary source needs_compilation
rgl 0.100.50 0.100.54 TRUE
mosaic 1.5.0 1.6.0 FALSE
Do you want to install from sources the package which needs compilation? (Yes/no/cancel) No
trying URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.5/rgl_0.100.50.tgz'
Content type 'application/x-gzip' length 4709273 bytes (4.5 MB)
==================================================
downloaded 4.5 MB
The downloaded binary packages are in
/var/folders/c8/lyjrvw_x18q2trr07z2s7m8w0000gn/T//RtmpOfzCf6/downloaded_packages
installing the source package ‘mosaic’
trying URL 'https://cran.rstudio.com/src/contrib/mosaic_1.6.0.tar.gz'
Content type 'application/x-gzip' length 12425406 bytes (11.8 MB)
==================================================
downloaded 11.8 MB
ERROR: dependency ‘latticeExtra’ is not available for package ‘mosaic’
* removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/mosaic’
Warning in install.packages :
installation of package ‘mosaic’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/c8/lyjrvw_x18q2trr07z2s7m8w0000gn/T/RtmpOfzCf6/downloaded_packages’
How can I avoid this? I have tried saying both Yes and no on the following line:
Do you want to install from sources the package which needs compilation? (Yes/no/cancel) No
And get an error both times. When I say yes and it attempts to install rgl I repeatedly get this message:
You have not agreed to the Xcode license agreements, please run 'sudo xcodebuild -license' from within a Terminal window to review and agree to the Xcode license agreements.
When I run xcodebuild -license in my terminal window it asks me for a password but does not allow me to type anything in the password slot and does not continue to install.
Is there any other way I can install the mosaic package?
I'm clearing a backlog as my semester winds down. Sorry I didn't get to this sooner.
Short answer: a new version of mosaic is on CRAN, and this issue should go away if you install the new version.
The particular issue you were having looks like it was related to an archived package that was suggested (i.e., not required) by the mosaic package. That package is no longer in the dependency list for mosaic.
In general, when I have issues like this, I often find that manually installing the packages listed in imports: and depends: in the DESCRIPTION file of a package will either (a) resolve the problem or (b) identify exactly where the problem lies.
It seems its dependencies are not installed yet. Maybe install the following packages first: latticeExtra and fastR
install.packages("latticeExtra")
install.packages("fastR")

Can't load geoR package (R, library())

for a project in university, I need to install a package which depends on geoR. Unfortunately, I can't load the package with library(geoR). The installation is not a problem. I've tried to uninstall and install the package and updated R. It still loads "forever". It is particularly strange since I can easily load any other installed package with library(...). Since I don't get any error message in the console, I'm very frustrated and have no idea how to solve that issue. I use Mac OS X 10.14.4. I'm using RStudio Version 1.1.463.
The installation seems to be no problem:
> install.packages("geoR")
trying URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.5/geoR_1.7-5.2.1.tgz'
Content type 'application/x-gzip' length 1544028 bytes (1.5 MB)
==================================================
downloaded 1.5 MB
The downloaded binary packages are in
/var/folders/cn/p44ynxg91mq7_ld8qrllxtx80000gn/T//RtmpGJbn5O/downloaded_packages
> library(geoR)
After the library-call, a never-ending process starts. Is there a way to track the library call? I haven't found any proper solution online. Since it loads forever, the only thing I can do is to force quit R Studio. I've tried to load it in R as well, didn't work either. I've also tried to delete the (installed geoR)-folder manually in library/Frameworks/r.framework/..., it didn't help as well.
Try installing an older version using devtools:
remove.packages("geoR")
install.packages("devtools")
require(devtools)
install_version("geoR", version = "1.7-4.1", repos = "http://cran.r-project.org")
options(gsubfn.engine = "R")
library(geoR, verbose = TRUE)

How to install R-packages not in the conda repositories?

I am using Anaconda to manage my R-installation. It works great for packages available in the R-channels provided by Anaconda, but I am having troubles installing packages not contained in the Anaconda repos.
I have tried a few different approaches, all listed below together with their error output.
1. install.packages('rafalib')
Suggested to work here conda - How to install R packages that are not available in "R-essentials"?. My .libPaths() points to '/home/user/anaconda2/lib/R/library'.
Out:
--- Please select a CRAN mirror for use in this session ---
Error in download.file(url, destfile = f, quiet = TRUE) :
unsupported URL scheme
Error: .onLoad failed in loadNamespace() for 'tcltk', details:
call: fun(libname, pkgname)
error: Can't find a usable init.tcl in the following directories:
/opt/anaconda1anaconda2anaconda3/lib/tcl8.5 ./lib/tcl8.5 ./lib/tcl8.5 ./library ./library ./tcl8.5.18/library ./tcl8.5.18/library
This probably means that Tcl wasn't installed properly.
I installed tcl from the conda channel r-old, but install.packages() still threw the same error message.
2. options(menu.graphics=FALSE) and then install.packages('rafalib')
I got a list of mirrors and chose one.
Out:
Selection: 15
trying URL 'http://cran.utstat.utoronto.ca/src/contrib/rafalib_1.0.0.tar.gz'
Content type 'application/x-gzip' length 11798 bytes (11 KB)
==================================================
downloaded 11 KB
sh: symbol lookup error: sh: undefined symbol: rl_signal_event_hook
The downloaded source packages are in
‘/tmp/Rtmphwpta0/downloaded_packages’
Warning message:
In install.packages("rafalib") :
installation of package ‘rafalib’ had non-zero exit status
Both 2 and 3 are from Disable/suppress tcltk popup for CRAN mirror selection in R
3. Setting the mirror in ~/.Rprofile
Before trying install.packages(), I added the following to my ~/.Rprofile.
## Default repo
local({r <- getOption("repos");
r["CRAN"] <- "http://cran.us.r-project.org";
options(repos=r)})
Out:
trying URL 'http://cran.us.r-project.org/src/contrib/rafalib_1.0.0.tar.gz'
Content type 'application/x-gzip' length 11798 bytes (11 KB)
==================================================
downloaded 11 KB
sh: symbol lookup error: sh: undefined symbol: rl_signal_event_hook
The downloaded source packages are in
‘/tmp/RtmppIz9rT/downloaded_packages’
Warning message:
In install.packages("rafalib") :
installation of package ‘rafalib’ had non-zero exit status
4. Setting the download method to 'curl' or 'wget'.
While keeping the new ~/.Rprofile configuration. I guess this wasn't necessary since the package seems to be downloading fine now, but I tested it just in case.
Out:
sh: symbol lookup error: sh: undefined symbol: rl_signal_event_hook
Warning in download.packages(pkgs, destdir = tmpd, available = available, :
download of package ‘rafalib’ failed
Warning message:
In download.file(url, destfile, method, mode = "wb", ...) :
download had nonzero exit status
5. Manual download of rafalib
install.packages('../Downloads/rafalib_1.0.0.tar.gz', repos=NULL, type='source')
Out:
sh: symbol lookup error: sh: undefined symbol: rl_signal_event_hook
Warning message:
In install.packages("../Downloads/rafalib_1.0.0.tar.gz", repos = NULL, :
installation of package ‘../Downloads/rafalib_1.0.0.tar.gz’ had non-zero exit status
6. Building a conda package from rafalib
I opened a separate issue for this Errors building R-packages for conda. In short, it complains about missing dependencies that I already have installed. Update I got a round the dependency problem and I am now stuck at the same rl_signal_event_hook-error as for my other approaches.
7. sudo ln /usr/lib/libncursesw.so.6 /usr/lib/libncursesw.so.5
As per https://github.com/conda/conda/issues/1679, but it didn't fix the issue for me.
So it seems like I can now download the package fine, but installing it fails. I have seen the error message sh: symbol lookup error: sh: undefined symbol: rl_signal_event_hook previously when using R with irkernel in the Jupyter Notebook, but it has never obstructed my work. I have never seen anything relating to that error message when running python through anaconda.
I'm out of ideas. Does anyone know how I can install R-packages not provided by anaconda, such as rafalib or swirl?
I am on Linux (Antergos, an Arch derivative) with kernel 4.4.5-1-ARCH.
UPDATE 2016/04/15
There is some related discussion in this thread. I have tried to get around this error by installing different versions of ncurses, including this patched version, and I have tried to link the readline libraries, as suggested here, but I keep running into the same error. I'm quite lost at this point and any help to solve this would be greatly appreciated.
Detailed post on managing packages that are and are not in Anaconda R: http://ihrke.github.io/conda.html
Essentially is using commands:
conda skeleton cran <package_name>
conda build <package_name>
If the package has dependencies that are also not in Anaconda:
conda skeleton cran <dependency1>
conda skeleton cran <dependency2>
conda build <package_name>
Essentially I would agree with this post in saying that I don't understand how install.packages() works with Anaconda. What I seem to see is that Anaconda creates a R environment where all the packages installed from install.packages() are kept.
Whenever I am working in Jupyter with R, I use this environment and am able to access all the packages that I have installed with install.packages()
In the end, I got around the rl_event_hookproblems by following the approach recommended here and symlinking anaconda's libreadline to the system one:
mv ~/anaconda3/lib/libreadline.s.6.2 ~/anaconda3/lib/libreadline.s.6.2.bak
ln -s /usr/lib/libreadline.so.6.3 ~/anaconda3/lib/libreadline.s.6.2
I am still having troubles installing some dependency heavy R-packages due to failure to load shared objects when using install.packages() from withing R. However, simpler packages work fine and I can get most of the dependency heavy packages from anacondas R-repositories.

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