R CMD INSTALL error: Unexpected Symbol in test_load_package() function - r

Issue:
I'm just trying to build a few packages from source and am running into an error
Error: unexpected symbol in "tools:::.test_load_package('rbenchmark',
'\per-homedrive1.corp.something.org/homedrive$/Tommy.O'Dell"
Full output below:
C:\ROracle>R CMD INSTALL --build --merge-multiarch rbenchmark_1.0.0.tar.gz
install for i386
* installing to library '\\per-homedrive1.corp.something.org/homedrive$/Tommy.O'Dell/R/win-library/2.15'
* installing *source* package 'rbenchmark' ...
** package 'rbenchmark' successfully unpacked and MD5 sums checked
** R
** demo
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Error: unexpected symbol in "tools:::.test_load_package('rbenchmark', '\\per-homedrive1.corp.something.org/homedrive$/Tommy.O'Dell"
Execution halted
ERROR: loading failed
* removing '\\per-homedrive1.corp.something.org/homedrive$/Tommy.O'Dell/R/win-library/2.15/rbenchmark'
Question:
Is the error coming from the apostrophe (') from O'Dell in the path?
If yes, is it a bug since it isn't escaping the apostrophe in the directory?
Is it trying to install into my default library?
If yes, can I change the library as a parameter in R CMD INSTALL?
If I can't specify the library, should I remove that library altogether?
Extra Info:
Here's the output of .libPaths()
[1] "\\\\per-homedrive1.corp.something.org/homedrive$/Tommy.O'Dell/R/win-library/2.15"
[2] "C:/Program Files/R/R-2.15.2/library"
[3] "C:/Program Files/RStudio/R/library"

As I see it, the error comes from the apostrophe - R can't know that this doesn't end the path, but is part of it. Try it without it and it should work I guess. One solution might be also to use this kind of quotation instead " ", maybe this works out as well, because then the apostrophe doesn't end it any more...
EDIT: In order to install a package foo via command line to an specific library folder via command line you can use
R CMD build foo
R CMD INSTALL -l /home/daniel/myPkg/ foo_1.0.tar.gz
This means in your case this should work:
R CMD INSTALL --build --merge-multiarch -l C:/Program Files/RStudio/R/library rbenchmark_1.0.0.tar.gz

Related

Installing R package ERROR: installing binary package failed

Complete newbie here, so there is probably something glaringly bad here. I created a Project following Hadley Wickham's book on R packages, and now I am trying add it to github for remote install (repository for reference).
Running devtools::install_github("alutterb/abcmlr") generated the following output:
Downloading GitHub repo alutterb/abcmlr#master
√ checking for file 'C:\Users\amlut\AppData\Local\Temp\RtmpMpn5uJ\remotes7146c405dd7\alutterb-abcmlr-918bf05/DESCRIPTION' ...
- preparing 'abcmlr':
√ checking DESCRIPTION meta-information ...
- checking for LF line-endings in source and make files and shell scripts
- checking for empty or unneeded directories
- building 'abcmlr_0.1.0.tar.gz'
Installing package into ‘C:/Users/amlut/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
* installing *binary* package 'abcmlr' ...
cp: unknown option -- )
Try '/Rtools/bin/cp --help' for more information.
ERROR: installing binary package failed
* removing 'C:/Users/amlut/Documents/R/win-library/3.5/abcmlr'
In R CMD INSTALL
Error in i.p(...) :
(converted from warning) installation of package ‘C:/Users/amlut/AppData/Local/Temp/RtmpMpn5uJ/file71463953e7b/abcmlr_0.1.0.tar.gz’ had non-zero exit status
In my repository, I have a Linux executable that is to be used with wsl as well as an .exe file that is called in my R code. These may be the culprits, but I am not entirely sure. The error states that it failed to install the binary package, but install_github() takes a source package, so I am not sure what is going on. Any help is appreciated.
Thank you.
EDIT: This problem is solved. It was because of a line in my DESCRIPTION file that had to do with Built.
Check your %PATH% and type: where cp.
Another cp (like one from the Git for Windows distribution) might overshadow the RTools cp, which might explain the error message.
As commented by the OP hkj447, the error was trigger by a line in the DESCRIPTION file:
Built: R 3.5.3; ; 2019-06-14 21:17:43 UTC; windows
As seen in this thread:
You have a field called 'Built:' in your package's DESCRIPTION file;
R normally tries to inject that field itself when it builds your package from sources.
I deleted "Built"'s line in DESCRIPTION and then installed again.
This time, no error appeared.

Devtools Install_github failes for Reprtree

Searched the whole internet, but couldn't find a solution.
Wrestling now for hours with this problem.
library(devtools)
install_github("araastat/reprtree")
But I receive an error every time (tried multiple things, like restarting, turn off my vpn).
Installation failed: Command failed (1)
Warning message:
S3 methods ‘[.git_tree’, ‘as.POSIXct.git_time’, ‘as.character.git_time’, ‘as.data.frame.git_commit’,
‘as.data.frame.git_repository’, ‘as.data.frame.git_tree’,
‘as.list.git_tree’, ‘diff.git_repository’, ‘diff.git_tree’,
‘format.git_blob’, ‘format.git_commit’, ‘format.git_merge_result’,
‘format.git_note’, ‘format.git_signature’, ‘format.git_tag’,
‘head.git_repository’, ‘length.git_blob’, ‘length.git_diff’,
‘length.git_tree’, ‘merge.character’, ‘merge.git_branch’,
‘merge.git_repository’, ‘plot.git_repository’, ‘print.git_blob’,
‘print.git_branch’, ‘print.git_commit’, ‘print.git_config’,
‘print.git_diff’, ‘print.git_merge_result’, ‘print.git_note’,
‘print.git_reference’, ‘print.git_reflog’, ‘print.git_reflog_entry’,
‘print.git_repository’, ‘print.git_signature’, ‘print.git_status’,
‘print.git_tag’, ‘print.git_time’, ‘print.git_tree’, ‘sha.git_blob’,
‘sha.git_branch’, ‘sha.git_commit’, ‘sha.git_fetch_head’,
‘sha.git_merge_result’, ‘sha.git_note’, ‘sha.git_reference’,
‘sha.git_reflog_entry’, [... truncated]
Edit. Another approach (as mentioned in the comments)
devtools::install("reprtree-master")
Installing reprtree
"C:/PROGRA~1/R/R-34~1.4/bin/i386/R" --no-site-file --no-environ --no-save --no-restore --quiet CMD INSTALL \
"C:/Users/asdf/Downloads/reprtree-master" --library="C:/Users/asdf/Documents/R/win-library/3.4" --install-tests
* installing *source* package 'reprtree' ...
** R
** preparing package for lazy loading
** help
*** installing help indices
converting help for package 'reprtree'
finding HTML links ... done
ReprTree html
finding level-2 HTML links ... done
plot.getTree html
plot.reprtree html
reprtree-package html
snip.depth html
text.tree html
Error: C:/Users/asdf/Downloads/reprtree-master/man/text.tree.Rd:41: Bad \link text
* removing 'C:/Users/asdf/Documents/R/win-library/3.4/reprtree'
In R CMD INSTALL
Error: Command failed (1)
>
For future readers
Something is wrong in text.tree.RD at line 41. What I did propably isn't the most perfect solution, but it works.
You can download the package as a .zip and unzip it. Then remove everything after line 39 in ./man/text.tree.RD. Afterwards you can install the package like this:
library(devtools)
if(!('reprtree' %in% installed.packages())){
install_local('path_to_extracted_zip/reprtree-master/')
}
Try devtools but from different sources:
install.packages('devtools', repos = 'http://cran.us.r-project.org')
library(devtools)
devtools::install_github('skinner927/reprtree')
library(reprtree)

Compile R package "arulesSequence" for older release

I want to use arulessequences for sequence mining. I have to use it in Oracle R distribution version R 3.3.0 (last released) and The problem is that the last version of the arulesSequences package is R >= 3.3.2. So I get an error for this problem:
Error: this is R 3.3.0, package arulesSequences needs >=3.3.2
So I decided to compile the source code for older release. I downloaded an older package that needs R 3.2.5 or above. And I know that this package is depended to arules. so I have installed it already. I used following instructions to compile the arulessequences package:
in the source directory I run this command:
R CMD build arulesSequences
the output of this command is:
c:\rr\arulesSequences_0.2-17>R CMD build arulesSequences
* checking for file 'arulesSequences/DESCRIPTION' ... OK
* preparing 'arulesSequences':
* checking DESCRIPTION meta-information ... OK
* cleaning src Warning in cleanup_pkg(pkgdir, Log) : unable to run 'make clean' in 'src'
* checking for LF line-endings in source and make files
* checking for empty or unneeded directories
* looking to see if a 'data/datalist' file should be added
* building 'arulesSequences_0.2-17.tar.gz'
a file named 'arulesSequences_0.2-17.tar.gz' get created but when I check it as below I get the following as output:
c:\rr\arulesSequences_0.2-17\arulesSequences>R CMD check arulesSequences
* using log directory 'c:/rr/arulesSequences_0.2-17/arulesSequences/arulesSequences.Rcheck'
using R version 3.4.0 (2017-04-21)
using platform: x86_64-w64-mingw32 (64-bit)
using session charset: ISO8859-1
checking for file 'arulesSequences/DESCRIPTION' ... OK
this is package 'arulesSequences' version '0.2-17'
checking package namespace information ... OK
checking package dependencies ... ERROR Package required but not available: 'arules'
See section 'The DESCRIPTION file' in the 'Writing R Extensions'
manual.
* DONE Status: 1 ERROR
I know the arules package is installed and I checked it. It seems the build process is not successful. do you have any idea to help solve this out?
You have to first install c/c++ compiler for R(called gcc) that is under R's additional build tools.
to do that, in RStudio goto File->New File ->c++ File.
It will show the following dialogue:
Then click on yes.
to compile a package under windows, you have to set repo to Null and type to source.
you can use this command to do that:
install.packages("SOURCEADDRESS",type="source",repo=null)
as #EugèneAdell mentioned above you have to first install arules. then arulessequences.
Instead of building, take the archive packages that seem to be ok for your R version and install them. On my Linux, this gives :
wget http://cran.univ-paris1.fr/src/contrib/Archive/arules/arules_1.5-0.tar.gz
R CMD INSTALL $HOME/arules_1.5-0.tar.gz
* installing to library ‘/home/ruser/R-3.2.5/lib64/R/library’
* installing *source* package ‘arules’ ...
...
** testing if installed package can be loaded
* DONE (arules)
wget http://cran.univ-paris1.fr/src/contrib/Archive/arulesSequences/arulesSequences_0.2-17.tar.gz
R CMD INSTALL $HOME/arulesSequences_0.2-17.tar.gz
* installing to library ‘/home/ruser/R-3.2.5/lib64/R/library’
* installing *source* package ‘arulesSequences’ ...
...
** testing if installed package can be loaded
* DONE (arulesSequences)
R
> library(arulesSequences)
Loading required package: arules
Loading required package: Matrix
Attaching package: ‘arules’
Maybe a more recent version for arules is possible, I just took the first one from the 1.5 series.

checkCompilerOptions Error while installing package (littler/Docker)

On its last line, this Docker file calls littler::install.r to install Rcpp RcppEigen and matrixStats.
The whole code was working like a charm a couple of months back. Now, it bombs at that last step. More precisely, Rcpp and RcppEigen still install perfectly, but when it comes to installing matrixStats, I get:
installing to /usr/local/lib/R/site-library/matrixStats/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
Error in get(name, envir = asNamespace(pkg), inherits = FALSE) :
object 'checkCompilerOptions' not found
Calls: ::: -> get
Execution halted
ERROR: loading failed
* removing ‘/usr/local/lib/R/site-library/matrixStats’
The downloaded source packages are in
‘/tmp/downloaded_packages’
Warning message:
In install.packages(f, lib, if (isMatchingFile(f)) NULL else repos) :
installation of package ‘matrixStats’ had non-zero exit status
It's an error I never had before and have trouble locating where it is even coming from. What could be causing this problem? Any info would already help a lot.
However, with R-devel using rocker/r-devel,
docker run --rm -ti rocker/r-devel /bin/bash
RD
install.packages("matrixStats")
Gives the same error. I'm guessing this is another R-devel change which takes away things we took for granted before, in this case something to do with compiler package. I don't however have a solution, yet. Just (re-)installing or attaching compiler doesn't help.
Update
Using R CMD INSTALL --no-byte-compile allows backports to install for me, which was the package I was having trouble with.
From the top of my head I'd blame a change in matrixStats [ but see below and it appears blameless ] -- I am somewhat familiar with all the other moving parts and not aware of changes or bugs.
One thing that is fishy though is the trailing line break:
RUN install.r Rcpp RcppEigen matrixStats \
You may try without it.
Edit: And for what it is worth I just fired up our standard base layer Docker image r-base via
docker run --rm -ti r-base /bin/bash
and invoked
install.r Rcpp RcppEigen matrixStats
which executed just fine.
So if sonething is wrong with that other Docker container you may have to take it up with its author and work through his changes relative to our Dockerfile he seems to have used as a base.

Trouble installing an R package using R CMD install

I just ran the following command after running R CMD build pkg and R CMD check pkg and it completed without errors.
R CMD install -t /home/wdkrnls/R/x86_64-unknown-linux-gnu-library/3.1 pkg_0.1.0.tar.gz
However, I still can't use it via library(pkg) from R. Looking in the library directory, all I see is the tarball, no pkg directory. When I try and untar it and then load in R, I get the error:
Error in library(e2pa) : 'e2pa' is not a valid installed package
Alternatively, when I try to install with
R CMD install -l /home/wdkrnls/R/x86_64-unknown-linux-gnu-library/3.1 pkg_0.1.0.tar.gz
It tells me -l is an invalid option.
Another failed possibility:
R CMD install -t /home/wdkrnls/R/x86_64-unknown-linux-gnu-library/3.1/pkg pkg_0.1.0.tar.gz
install: accessing `/home/wdkrnls/R/x86_64-unknown-linux-gnu-library/3.1/pkg': No such file or directory
What is the right way to install a package into a personal library in R?
Unix commands are case-sensitive and
R CMD install ....
as you typed invokes a different /usr/bin/install than the R-internal script INSTALL which the actually mandated form
R CMD INSTALL ...
uses. See all the relevant docs -- it is always UPPERCASE.
Once you have the correct script, -l ... is recognised:
edd#max:~$ R CMD INSTALL -l /tmp/demo git/drat_0.0.2.4.tar.gz
* installing *source* package ‘drat’ ...
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (drat)
edd#max:~$

Resources