R can't find path for sh - r

Having a critical issue installing packages in R (I'm on Mac OS). I tried installing a package (below) using Rstudio:
> install.packages("igraph")
Installing package into ‘/usr/local/lib/R/3.6/site-library’
(as ‘lib’ is unspecified)
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
./configure: line 473: sed: command not found
./configure: line 472: expr: command not found
./configure: line 473: sed: command not found
./configure: line 487: sed: command not found
: error: cannot create .lineno; rerun with a POSIX shell
ERROR: configuration failed for package ‘igraph’
* removing ‘/usr/local/lib/R/3.6/site-library/igraph’
sh: rm: command not found
Warning in install.packages :
installation of package ‘igraph’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/ll/jmydhb6n7jqg5rv_c58jxkkh0000gn/T/Rtmpi1rAL3/downloaded_packages’
I then tried it in R console:
> install.packages("igraph")
Installing package into ‘/usr/local/lib/R/3.6/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://cran.ma.imperial.ac.uk/src/contrib/igraph_1.2.4.1.tar.gz'
Content type 'application/x-gzip' length 2704004 bytes (2.6 MB)
==================================================
downloaded 2.6 MB
/usr/local/Cellar/r/3.6.1/lib/R/bin/R: line 143: exec: sh: not found
The downloaded source packages are in
‘/private/var/folders/ll/jmydhb6n7jqg5rv_c58jxkkh0000gn/T/Rtmpq31bYd/downloaded_packages’
Warning messages:
1: In system2(cmd0, args, env = env, stdout = outfile, stderr = outfile, :
error in running command
2: In install.packages("igraph") :
installation of package ‘igraph’ had non-zero exit status
I'm guessing the issue is related to one of my PATH variables. I also tried installing the most recent version of xcode to no avail. Below are the details I can get on my various PATHs:
From Rstudio:
Sys.getenv("PATH")
[1] "/Users/gordon.beattie/.virtualenvs/r-reticulate/bin:/Users/gordon.beattie/.virtualenvs/r-reticulate/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/gordon.beattie/Downloads/R_packages/gliph-master/gliph/bin"
From R console
> Sys.getenv("PATH")
[1] "/usr/local/bin"
From .Renviron
R_LIBS=~/R/library
PAGER=/usr/local/bin/less
PATH=/Users/gordon.beattie/Downloads/R_packages/gliph-master/gliph/bin
PATH=/usr/local/bin
PATH=/usr/local/bin
PATH=/usr/bin
PATH=/bin
PATH=/usr/sbin
PATH=/sbin
PATH=/Users/gordon.beattie/.virtualenvs/r-reticulate/bin
PATH=/Users/gordon.beattie/.virtualenvs/r-reticulate/bin
PATH=/usr/bin:/bin:/usr/sbin
PATH=/sbin
PATH=/usr/local/bin
My system PATH
echo $PATH
/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
Additional info:
echo $0
-bash
echo $SHELL
/bin/bash
which sh
/bin/sh

Related

R cannot download websockets package from the github

The manual is written here:https://github.com/Refinitiv/websocket-api/tree/master/Applications/Examples/R
The mentioned code is written in Section 2 of Install libraries
Problems are with this part
library(devtools)
install_github("brettjbush/R-Websockets")
With R and RTools versions above 4.0 I have following error.
> install_github("brettjbush/R-Websockets")
Downloading GitHub repo brettjbush/R-Websockets#HEAD
Installing 1 packages: caTools
Installing package into ‘\\energia.sise/dfs/REDIRECT/german.suhharukov/Documents/R/win-library/4.0’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.0/caTools_1.18.0.zip'
Content type 'application/zip' length 317292 bytes (309 KB)
downloaded 309 KB
package ‘caTools’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\german.suhharukov\AppData\Local\Temp\RtmpoRYGc0\downloaded_packages
√ checking for file 'C:\Users\german.suhharukov\AppData\Local\Temp\RtmpoRYGc0\remotes1aa03e212c08\brettjbush-R-Websockets-fc7ee9c/DESCRIPTION' (1s)
- preparing 'websockets':
√ checking DESCRIPTION meta-information ...
- cleaning src
Warning in system2(command, args, stdout = NULL, stderr = NULL, ...) :
'CreateProcess' failed to run 'C:\rtools40\usr\bin\make.exe -f "C:/PROGRA~1/R/R-40~1.3/share/make/clean.mk" -f Makevars.win clean'
- checking for LF line-endings in source and make files and shell scripts
- checking for empty or unneeded directories
- building 'websockets_1.1.7.tar.gz'
Installing package into ‘\\sise/dfs/REDIRECT/MYNAME/Documents/R/win-library/4.0’
(as ‘lib’ is unspecified)
'\\sise\dfs\REDIRECT\MYNAME\Documents'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
* installing *source* package 'websockets' ...
** using staged installation
** libs
*** arch - i386
Error in system(cmd) :
(converted from warning) 'CreateProcess' failed to run 'C:\rtools40\usr\bin\make.exe -f "Makevars.win" -f "C:/PROGRA~1/R/R-40~1.3/etc/i386/Makeconf" -f "C:/PROGRA~1/R/R-40~1.3/share/make/winshlib.mk" SHLIB="websockets.dll" OBJECTS="libsock.o"'
* removing '\\sise/dfs/REDIRECT/MYNAME/Documents/R/win-library/4.0/websockets'
Error: Failed to install 'websockets' from GitHub:
(converted from warning) installation of package ‘C:/Users/MYNAME/AppData/Local/Temp/RtmpoRYGc0/file1aa0518554ea/websockets_1.1.7.tar.gz’ had non-zero exit status
> install.packages("caTools")
Installing package into ‘\\sise/dfs/REDIRECT/MYNAME/Documents/R/win-library/4.0’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.0/caTools_1.18.0.zip'
Content type 'application/zip' length 317292 bytes (309 KB)
downloaded 309 KB
package ‘caTools’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\MYNAME\AppData\Local\Temp\XXXXXXX\downloaded_packages
>
Errors are following
> library(devtools)
Loading required package: usethis
> install_github("brettjbush/R-Websockets")
Downloading GitHub repo brettjbush/R-Websockets#master
trying URL 'https://cran.rstudio.com/bin/windows/Rtools/Rtools35.exe'
Content type 'application/x-msdownload' length 108622512 bytes (103.6 MB)
downloaded 103.6 MB
Error: Failed to install 'websockets' from GitHub:
Could not find tools necessary to compile a package
Call `pkgbuild::check_build_tools(debug = TRUE)` to diagnose the problem.
> pkgbuild::check_build_tools(debug = TRUE)
trying URL 'https://cran.rstudio.com/bin/windows/Rtools/Rtools35.exe'
Content type 'application/x-msdownload' length 108622512 bytes (103.6 MB)
downloaded 103.6 MB
Error: Could not find tools necessary to compile a package
Call `pkgbuild::check_build_tools(debug = TRUE)` to diagnose the problem.
> find_rtools()
[1] TRUE
> Sys.which("ls.exe")
ls.exe
"C:\\Rtools\\bin\\ls.exe"
How can I download this package?
In the notes on github it says "NOTE: This package is no longer maintained. For implementing websocket servers in R, try the httpuv package"
Another possible problem could be that you are running a new version of R with an old version of Rtools. So I'd try to install the newest version of Rtools or run an older version of R with a compatible version of Rtools, such that you can build and compile the package.
I ran your code on my machine running R 4.0.2 and Rtools 4.0.0 and did not face any issues installing the package. So I'd suggest installinng the newest version of R and Rtools from here: https://cran.r-project.org/bin/windows/Rtools/ and trying again.

sed and expr not found and non-zero exit status when installing igraph

I'm getting the following issue installing igraph within rstudio on Mac. I've seen something similar on Linux forums that suggest it's an issue with my PATH, but not sure how to fix it in this context.
Thanks in advance for any assistance!
install.packages("igraph")
Installing package into ‘/usr/local/lib/R/3.6/site-library’
(as ‘lib’ is unspecified)
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
./configure: line 473: sed: command not found
./configure: line 472: expr: command not found
./configure: line 473: sed: command not found
./configure: line 487: sed: command not found
: error: cannot create .lineno; rerun with a POSIX shell
ERROR: configuration failed for package ‘igraph’
* removing ‘/usr/local/lib/R/3.6/site-library/igraph’
sh: rm: command not found
Warning in install.packages :
installation of package ‘igraph’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/ll/jmydhb6n7jqg5rv_c58jxkkh0000gn/T/Rtmpi1rAL3/downloaded_packages’

Knitr error when running R Markdown from batch

I was following this SO answer to create a batch file that runs an R script, which in turn runs a Markdown file.
In short. The test version has three parts.
I. R Script - knits and renders the markdown:
library(knitr)
library(rmarkdown)
setwd("~/r_directory")
knit("test_markdown.Rmd")
render("test_markdown.Rmd")
Sys.sleep(3)
II. R Markdown file
---
title: "Test"
output: html_document
---
## R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
```{r cars}
summary(cars)
```
III. Batch file:
"C:\Program Files\R\R-3.4.3\bin\R.exe" CMD BATCH --vanilla --slave "C:\Users\Stefan\Documents\r_directory\script.R" "C:\Users\Stefan\Documents\r_directory\script.Rout"
Now I'm getting two types of errors in the script.Rout file.
With the correct R.Script version the error I'm getting is:
Error in library(knitr) : there is no package called 'knitr'
Execution halted
So, ok. Obviouslly I should install knitr.
But when I change the script to include - install.packages("knitr"), I get:
Installing package into 'C:/Users/Stefan/Documents/R/win-library/3.4'
(as 'lib' is unspecified)
Error in contrib.url(repos, "source") :
trying to use CRAN without setting a mirror
Calls: install.packages -> contrib.url
Execution halted
Any idea where I'm missing something?
Edit: I provided multiple repos for the knitr package.
install.packages('knitr', repos = c('http://cran.rstudio.org', 'http://cran.us.r-project.org', 'http://rforge.net'),
type = 'source')
What I get as an error now is:
Installing package into 'C:/Users/Stefan/Documents/R/win-library/3.4'
(as 'lib' is unspecified)
also installing the dependencies 'mime', 'stringi', 'evaluate', 'markdown', 'stringr', 'yaml'
trying URL 'http://rforge.net/src/contrib/mime_0.5.1.tar.gz'
Content type 'application/x-gzip' length 11695 bytes (11 KB)
==================================================
downloaded 11 KB
trying URL 'http://cran.rstudio.org/src/contrib/stringi_1.1.6.tar.gz'
Content type 'application/x-gzip' length 3647049 bytes (3.5 MB)
==================================================
downloaded 3.5 MB
trying URL 'http://rforge.net/src/contrib/evaluate_0.10.3.tar.gz'
Content type 'application/x-gzip' length 19612 bytes (19 KB)
==================================================
downloaded 19 KB
trying URL 'http://rforge.net/src/contrib/markdown_0.8.1.tar.gz'
Content type 'application/x-gzip' length 88252 bytes (86 KB)
==================================================
downloaded 86 KB
trying URL 'http://cran.rstudio.org/src/contrib/stringr_1.2.0.tar.gz'
Content type 'application/x-gzip' length 94095 bytes (91 KB)
==================================================
downloaded 91 KB
trying URL 'http://cran.rstudio.org/src/contrib/yaml_2.1.16.tar.gz'
Content type 'application/x-gzip' length 85275 bytes (83 KB)
==================================================
downloaded 83 KB
trying URL 'http://cran.rstudio.org/src/contrib/knitr_1.19.tar.gz'
Content type 'application/x-gzip' length 649805 bytes (634 KB)
==================================================
downloaded 634 KB
* installing *source* package 'mime' ...
** libs
*** arch - i386
Warning: running command 'make -f "C:/PROGRA~1/R/R-34~1.3/etc/i386/Makeconf" -f "C:/PROGRA~1/R/R-34~1.3/share/make/winshlib.mk" SHLIB="mime.dll" OBJECTS="init.o rawmatch.o"' had status 127
ERROR: compilation failed for package 'mime'
* removing 'C:/Users/Stefan/Documents/R/win-library/3.4/mime'
In R CMD INSTALL
* installing *source* package 'stringi' ...
** package 'stringi' successfully unpacked and MD5 sums checked
Warning: running command 'sh ./configure.win' had status 127
ERROR: configuration failed for package 'stringi'
* removing 'C:/Users/Stefan/Documents/R/win-library/3.4/stringi'
In R CMD INSTALL
* installing *source* package 'yaml' ...
** package 'yaml' successfully unpacked and MD5 sums checked
** libs
*** arch - i386
Warning: running command 'make -f "Makevars" -f "C:/PROGRA~1/R/R-34~1.3/etc/i386/Makeconf" -f "C:/PROGRA~1/R/R-34~1.3/share/make/winshlib.mk" SHLIB="yaml.dll" OBJECTS="api.o dumper.o emitter.o implicit.o loader.o parser.o r_emit.o r_ext.o r_parse.o reader.o scanner.o writer.o"' had status 127
ERROR: compilation failed for package 'yaml'
* removing 'C:/Users/Stefan/Documents/R/win-library/3.4/yaml'
In R CMD INSTALL
ERROR: dependency 'mime' is not available for package 'markdown'
* removing 'C:/Users/Stefan/Documents/R/win-library/3.4/markdown'
In R CMD INSTALL
ERROR: dependency 'stringi' is not available for package 'stringr'
* removing 'C:/Users/Stefan/Documents/R/win-library/3.4/stringr'
In R CMD INSTALL
ERROR: dependency 'stringr' is not available for package 'evaluate'
* removing 'C:/Users/Stefan/Documents/R/win-library/3.4/evaluate'
In R CMD INSTALL
ERROR: dependencies 'evaluate', 'markdown', 'stringr', 'yaml' are not available for package 'knitr'
* removing 'C:/Users/Stefan/Documents/R/win-library/3.4/knitr'
In R CMD INSTALL
The downloaded source packages are in
'C:\Users\Stefan\AppData\Local\Temp\RtmpaiQed8\downloaded_packages'
There were 14 warnings (use warnings() to see them)
Error in library(knitr) : there is no package called 'knitr'
Execution halted

Error in installing 'RPostgreSQL' package

I am trying to install PostgreSQL package on R version 3.1.2. running on Linux.
I get the following error...
Installing package into ‘/usr/lib64/R/library’ (as ‘lib’ is unspecified) trying URL 'http://cran.cnr.berkeley.edu/src/contrib/RPostgreSQL_0.4.tar.gz' Content type 'application/x-gzip' length 477352 bytes (466 Kb) opened URL
==================================================
downloaded 466 Kb
* installing *source* package ‘RPostgreSQL’ ...
** package ‘RPostgreSQL’ successfully unpacked and MD5 sums checked
sh: ./configure: /bin/sh: bad interpreter: Permission denied
ERROR: configuration failed for package ‘RPostgreSQL’
* removing ‘/usr/lib64/R/library/RPostgreSQL’
> The downloaded source packages are in
> ‘/tmp/RtmpANw7OS/downloaded_packages’ Updating HTML index of packages in '.Library' Making 'packages.html' ... done Warning
> message: In install.packages("RPostgreSQL") : installation of here`package ‘RPostgreSQL’ had non-zero exit status
Any ideas on how to resolve this?
This looks odd:
./configure: /bin/sh: bad interpreter: Permission denied
Is your /bin/sh unsual or in bad shape? What happens when you (manually) untar the sources and run ./configure ?

R Studio installing xlsx package

I'm trying to install the xlsx package using R Studio but I am encountering some problems. When the installation process starts I am asked the question "Package which is only available in source form, and may need compilation of C/C++/Fortran:‘rJava’ Do you want to attempt to install these from sources?" to which I reply "y".
The program then goes on to download 3 .tar.gz files. I have copied the full code below.
Problem is, I'm not sure what I need to do next in order to complete the installation? Any help is greatly appreciated.
> install.packages("xlsx")
also installing the dependencies ‘rJava’, ‘xlsxjars’
Package which is only available in source form, and may need compilation of C/C++/Fortran:
‘rJava’
Do you want to attempt to install these from sources?
y/n: y
installing the source packages ‘rJava’, ‘xlsxjars’, ‘xlsx’
trying URL 'https://cran.rstudio.com/src/contrib/rJava_0.9-7.tar.gz'
Content type 'application/x-gzip' length 711181 bytes (694 KB)
downloaded 694 KB
trying URL 'https://cran.rstudio.com/src/contrib/xlsxjars_0.6.1.tar.gz'
Content type 'application/x-gzip' length 9477071 bytes (9.0 MB)
downloaded 9.0 MB
trying URL 'https://cran.rstudio.com/src/contrib/xlsx_0.5.7.tar.gz'
Content type 'application/x-gzip' length 312839 bytes (305 KB)
downloaded 305 KB
* installing *source* package 'rJava' ...
** package 'rJava' successfully unpacked and MD5 sums checked
Generate Windows-specific files (src/jvm-w32) ...
make: Entering directory `/cygdrive/c/Users/davish/AppData/Local/Temp/RtmpmOuT4w/R.INSTALL456448961b13/rJ ava/src/jvm-w32'
dlltool --as as -m i386:x86-64 --as-flags --64 --input-def jvm64.def --kill- at --dllname jvm.dll --output-lib libjvm.dll.a
gcc -m64 -O2 -c -o findjava.o findjava.c
gcc -m64 -s -o findjava.exe findjava.o
make: Leaving directory `/cygdrive/c/Users/davish/AppData/Local/Temp/RtmpmOuT4w/R.INSTALL456448961b13/rJ ava/src/jvm-w32'
Find Java...
ERROR*> JavaSoft\{JRE|JDK} can't open registry keys.
ERROR: cannot find Java Development Kit.
Please set JAVA_HOME to specify its location manually
Warning: running command 'sh ./configure.win' had status 1
ERROR: configuration failed for package 'rJava'
* removing 'C:/Program Files/R/R-3.2.2/library/rJava'
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-32~1.2/bin/x64/R" CMD INSTALL -l "C:\Program Files\R\R-3.2.2\library" C:\Users\davish\AppData\Local\Temp\Rtmp2FwjgL/downloaded_packages/rJava_0.9- 7.tar.gz' had status 1
Warning in install.packages :
installation of package ‘rJava’ had non-zero exit status
ERROR: dependency 'rJava' is not available for package 'xlsxjars'
* removing 'C:/Program Files/R/R-3.2.2/library/xlsxjars'
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-32~1.2/bin/x64/R" CMD INSTALL -l "C:\Program Files\R\R-3.2.2\library" C:\Users\davish\AppData\Local\Temp\Rtmp2FwjgL/downloaded_packages/xlsxjars_0.6.1 .tar.gz' had status 1
Warning in install.packages :
installation of package ‘xlsxjars’ had non-zero exit status
ERROR: dependencies 'rJava', 'xlsxjars' are not available for package 'xlsx'
* removing 'C:/Program Files/R/R-3.2.2/library/xlsx'
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-32~1.2/bin/x64/R" CMD INSTALL -l "C:\Program Files\R\R-3.2.2\library" C:\Users\davish\AppData\Local\Temp\Rtmp2FwjgL/downloaded_packages/xlsx_0.5.7.tar .gz' had status 1
Warning in install.packages :
installation of package ‘xlsx’ had non-zero exit status
The downloaded source packages are in
‘C:\Users\davish\AppData\Local\Temp\Rtmp2FwjgL\downloaded_packages’
Please see the error :
ERROR*> JavaSoft\{JRE|JDK} can't open registry keys.
ERROR: cannot find Java Development Kit.
Please set JAVA_HOME to specify its location manually
solution : install jdk

Resources