R's devtools - install from github with "configure" file - r

I have an R package on github that uses a "configure" script (since some of the C code depends on GSL libraries). I try installing the package using github_install() function from devtools package and get the error:
(as ‘lib’ is unspecified)
* installing *source* package ‘wrightscape’ ...
ERROR: 'configure' exists but is not executable -- see the 'R Installation and Administration Manual'
Not sure what to do -- are there such a thing as execute permissions for a file on github? is this a devtools issue or a configuration issue? (Installing the package from source works fine for me). The package is here. https://github.com/cboettig/wrightscape

This is now fixed in the latest version of devtools (0.7).

Git does not manage file permissions directly. It is usually the responsibility of a build or install script to adjust permissions correctly once the bits are delivered from git. There are third party tools that can help with this. See the discussion on SO question Retaining file permissions with Git.
Hope this helps.

I had a similar issue which was caused by my /tmp dir being mounted noexec, and solved by setting a different TMPDIR, as explained here
export TMPDIR=~/tmp

Related

Can not install processr and procesR on Windows

Following this question, I am trying to install the package (running R64 as admin on Windows):
devtools::install_github("markhwhiteii/processr")
or
devtools::install_github("cardiomoon/processR")
However, I get the error message:
Error: Failed to install 'processr' from GitHub:
(converted from warning) cannot remove prior installation of package 'digest'
no matter which update option I select. Running the command .libPaths() I found the packages installation folder C:/Program Files/R/R-3.6.2/library and manually deleted the digest package and reinstalled it with package.install("digest"). But I still get the same error! I would appreciate it if you could help me understand what is the problem and how I can resolve it.
The simplest solution is to say no when install_github asks if it should replace digest.
If it still fails for some reason (and I can't see why; neither package requires a specific version of digest and you've reinstalled it in any case), then the problem is that devtools itself uses digest, so it can't be removed as long as devtools is loaded. So you can't use install_github.
You have a couple of options:
Clone the repo, then from the command line, run R CMD INSTALL . in that directory. Note that you'll need to insert the path to your R executable.
Install from the GitHub archive of the master branch: install.packages("https://github.com/markhwhiteii/processr/archive/master.tar.gz")
The steps to install the markhwhiteii/processr package:
install.packages("devtools")
library(devtools)
install.packages("https://github.com/markhwhiteii/processr/archive/master.tar.gz")
for testing the instalation:
library(processr)
processr::model1
Sent a PR on the GitHub repo.
and if you want to run R in the Jupyter environment just follow the instructions to install and regsiter the kernel:
install.packages('IRkernel')
IRkernel::installspec()

make not found when using dynr [duplicate]

The R Package ConvCalendar is not on Cran repository anymore (see here).
However, because I have intensively used this package for previous projects, it would be nice to have it installed on my machine, even an older version would suffice.
(Windows 10 environment)
In the link above it is possible to download older versions of ConvCalendar from the archive. I thus did it, and tried installing it by running (having devtools also installed and loaded):
install.packages("ConvCalendar_1.2.tar.gz", repos=NULL, type="source")
However, I get the following error message:
> install.packages("ConvCalendar_1.0.tar.gz", repos=NULL, type="source")
Installing package into ‘C:/Users/myname/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
* installing *source* package 'ConvCalendar' ...
** libs
*** arch - i386
Warning in system(cmd) : 'make' not found
ERROR: compilation failed for package 'ConvCalendar'
* removing 'C:/Users/myname/Documents/R/win-library/3.5/ConvCalendar'
In R CMD INSTALL
Warning in install.packages :
installation of package ‘ConvCalendar_1.2.tar.gz’ had non-zero exit status
Looking for a solution to this problem.
what do you need is to update the Rtool, here is the link I had the same issue before once you update it will work.
Reinstall Rtools, Please check the below link to figure out the right version of Rtools.
https://cran.r-project.org/bin/windows/Rtools/history.html
'make' not found is a pretty clear cut message on what's the issue, and as noted here and elsewhere it is caused by Rterm not knowing where to find it (unlike other tools like RStudio, base R is completely clueless about the Windows registry value where the Rtools path gets set by default).
Up to Rtools 3.5 this could be neatly avoided with a checkbox in the installer (which took care of adding the right directory to PATH), but newer versions dropped it. Presumably to focus on the RTOOLS_HOME variable (which is far more independent and resilient to whatever else you may have installed on your system), if just so it wasn't that until R 4.2 nothing really cared for it in the code.
On top of that, it's only since Rtools 4.0 (maybe because they updated the old MSYS2/Cygwin environment, or maybe it was something in the accompanying R 4.0?) that you can use long filenames with spaces to point to the folder containing make. Also, hopefully you haven't been manually setting BINPREF anywhere.
TL;DR: just add something like "C:\rtools40\usr\bin" (or whatever you have) to your PATH.
Building on #mirh's answer.
I had installed Rtools 4.0 in the in "C:\rtools" on windows and had the "'make' not found" issue (I also had a warning that RTools was not found). I could not change the PATH through the traditional route though because I was missing admin rights. The following helped:
Add to your .RProfile the line:
Sys.setenv(PATH = paste0(Sys.getenv("PATH"), ";C:\\rtools40\\usr\\bin"))
This will change the path from within R for the current session. You might have to alter it if you have a different version of RTools or a different installation directory.
After this I can install from source and I don't get the RTools warning anymore.

unable to access index for repository in R

I am on Windows 7 and I am using R Studio 0.99.902 with R3.3.1. When I am trying to install a package I get the Warnings:
Warning: unable to access index for repository http://cran.rstudio.com/src/contrib:
cannot open URL 'http://cran.rstudio.com/src/contrib/PACKAGES'
Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/src/contrib:
cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/src/contrib/PACKAGES'
It is the first time I see it and I cannot solve it. Can anyone help me ?
This issue is likely caused by the package being too old or too new for your R version. For example, if a package is released during R-3.4.1, it will not be available for R-3.3.1. Packages which are removed from CRAN before your R version are also not available. The package DESCRIPTION file shows if there is a hard restriction on which R versions the package will run.
Search for the package's CRAN page and see its status. You may still be able to install the package by downloading the package source (the tar.gz file) and in RStudio selecting Install from: Package Archive File in the Tools/Install Packages... menu (or using install.packages with repos = NULL). Beware that the package is not available from CRAN for a reason; you may need to make some changes to the package for it to work correctly.
Running options(download.file.method="libcurl") then installing packages did the trick for me. You may find an answer here.
Please note that compiling from source for Windows requires the appropriate version of Rtools that is compatible with the R version you are working with. This list is available at the Rtools site:
https://cran.r-project.org/src/contrib/Archive/
If compilation from source is complicated, it is also possible to find the Windows-compiled binaries (.zip files) for older versions of R at:
https://cran-archive.r-project.org/bin/windows/contrib
This link is referenced by the ReadMe file available at the "regular" repository for Windows binaries for different versions of R, namely at:
https://cran.r-project.org/bin/windows/contrib
Once the zip file is downloaded, you can run the following R code line to install the package:
# Use repos=NULL so that the first argument is a path to the local zip file
# containing the binary package to install
# (as opposed to just the name of the package to install from the web)
install.packages("<local-path-to-downloaded-zip-file>", repos=NULL)

Library is not writable

I have this issue during package installation in R version 3.0.2 (2013-09-25) on an Ubuntu machine:
install.packages("randomForest")
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Warning in install.packages :
'lib = "/usr/local/lib/R/site-library"' is not writable
How to resolve it?
For R version 3.2.2 (2015-08-14) this problem should be dealt with since R suggests within the installation process a different path to store your R libraries. The installation looks like this:
(Here 'random' is used as an example package)
install.packages('random')
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Warning in install.packages("random") :
'lib = "/usr/local/lib/R/site-library"' is not writable
Would you like to use a personal library instead? (y/n) y
Would you like to create a personal library
~/R/pc-linux-gnu-library/3.2
to install packages into? (y/n) y
So during the installation answering both questions with 'y' should install the package correctly.
Update 18/01/19
In case you don't want to store your R packages in an additional file:
As Antoine-Sac and Robert TheSim point out you can add yourself to the staff group in order to be able to write to 'site-library'. (Click on the names to see their important additions)
Before this update I mentioned in this comment the option of changing the permission of the folder 'site-library' using 'chmod o+w' in order to be able to write to it. Assuming security issues but unable to tell at the time I warned about it but have primarily been waiting for somone to clear this up. Antoine-Sac and Robert TheSim have done so in the meantime. Thanks!
add yourself to the group called 'staff'
sudo usermod -a -G staff your_user_name
replace your_user_name with your login username, then logoff and relogin.
DO NOT use chmod 777 which is a breach of security and btw. a complete non-sense!!!
If you are on Windows, you can run R (or RStudio) as an administrator.
Close your R, then go to the R or RStudio icon, right-click and "open as administrator". It works perfectly, all error messages while installing packages are gone forever.
For someone who tried to use install.packages() with multiple packages like this:
install.packages("vcd","vcdExtra","plyr")
and got similar warning:
Warning in install.packages :
'lib = "vcdExtra"' is not writable
Would you like to use a personal library instead? (yes/No/cancel) cancel
Error in install.packages : unable to install packages
You should put the package names in a vector:
install.packages(c("vcd","vcdExtra","plyr"))
as the second parameter in install.packages() is lib.
The problem is that the default install location is a place where you do not have write permissions.
The solution is to use an install location where you do have write permissions.
Specifically, I'd suggest using the following commands to create a personal library folder in a place that doesn't require special permissions and that will automatically be detected the next time you startup R:
dir.create(Sys.getenv("R_LIBS_USER"), recursive = TRUE) # create personal library
.libPaths(Sys.getenv("R_LIBS_USER")) # add to the path
install.packages("randomForest") # install like always
library(randomForest) # use library like always
The call to dir.create follows the suggestion in this faq to create a folder named according to Sys.getenv("R_LIBS_USER"). This is a good choice since it will be found on the next startup of R so you will be able to use install.packages and library without specifying special locations. The .libPaths function call lets us avoid restarting R by immediately adding the new folder to the library path. The first two lines are only needed if you do not yet have a personal library created, but there is no harm in running them repeatedly. After that, installing packages and using libraries can be done as usual.
It means exactly what it says. You don't have write permission in that folder. Either you need to change the permissions for that folder, or change the R library location.
If you are using OS windows 10 then maybe Ransomware protection is on. You need to disable that.
I was facing the same problem. I had the access to write. but suddenly it stopped. I couldn't install the packages. Disabling Ransomware protection worked for me.
The "XX" is not writable error can also mean that the library path you're providing does not exist.
Use sudo to Rscript code. I have same error fixed using sudo Rscript filename.R
Error
$ Rscript babynames.R
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Warning in install.packages("babynames") :
'lib = "/usr/local/lib/R/site-library"' is not writable
Error in install.packages("babynames") : unable to install packages
Execution halted
Fix
$ sudo Rscript babynames.R
[sudo] password for abhay:
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
also installing the dependencies ‘cli’, ‘glue’, ‘utf8’, ‘fansi’, ‘lifecycle’, ‘magrittr’, ‘pillar’, ‘pkgconfig’, ‘rlang’, ‘vctrs’, ‘tibble’
Maybe can try sudo chmod +777 #nameoflib
It works for me
You can change permission to 'site-library' and all included directories.
sudo chmod 777 -R /usr/local/lib/R/site-library
If you are using R with RStudio, rather than starting RStudio with tray icon, start Rstudio or R with command line using sudo rstudio or sudo R.
It will solve your problem for sure, it works for me. It requires sudo privilege to write something in installation directory.

install a R package needed for your package upon installation

I'm developing a R package that depends on another R package being installed on the users system.
I've added a Depends:pkgname in the DESCRIPTION file and import(pkgname) in the NAMESPACE. What I was hoping this would do is check if pkgname is already installed and if not install.packages(pkgname,repos="CRAN or Rforge or wherever the package is") if not.
However upon attempted installation of my package i get the error:
ERROR: dependency 'pkgname' is not available for package 'mypkg'
Does anyone know how to implement an installation of pkgname, should pkgname not already be on the system?
Many thanks
In the help file of R CMD INSTALL there is no mention of a flag to install additional packages if needed for dependencies. If you submit your package to CRAN, your problems are solved because install.packages then solves any dependencies. install.packages does not support solving dependencies when installing from a local file.
Until you submit to either R-forge or CRAN, I think it will suffice to add a remark to the README file that a few additional packages need to be present. You could even post a snippet of R code containing the needed install.packages command.

Resources