R session aborded package raster - r

Hello stackoverflow community,
I upgraded to the latest version of R and R studio this week, and have my R sessions encountering fatal error whenever I try to load the package raster.
I tried looking at the dependencies of the package, and re-installed all of them just to be sure.
# Install dependencies
db <- available.packages()
(deps <- tools::package_dependencies("raster", db)$raster)
# [1] "sp" "Rcpp" "methods"
install.packages(deps)
Any ideas?
Below are my session infos.
devtools::session_info("raster")
─ Session info ───────────────────────────────────────────────────────────────────
setting value
version R version 3.6.3 (2020-02-29)
os macOS Mojave 10.14.6
system x86_64, darwin15.6.0
ui RStudio
language (EN)
collate en_US.UTF-8
ctype en_US.UTF-8
tz America/New_York
date 2020-04-17
─ Packages ───────────────────────────────────────────────────────────────────────
package * version date lib source
lattice * 0.20-41 2020-04-02 [1] CRAN (R 3.6.2)
raster 3.0-12 2020-01-30 [1] CRAN (R 3.6.0)
Rcpp 1.0.4.6 2020-04-09 [1] CRAN (R 3.6.3)
sp 1.4-1 2020-02-28 [1] CRAN (R 3.6.0)
[1] /Library/Frameworks/R.framework/Versions/3.6/Resources/library
While looking for a solution, I also found out that my Makevars file is incomplete. I used the solution described in here, which asks RStudio to ensure it always saves files with a trailing newline, but it doesn't work here.
Problem is I don't know if I have had this issue for a long time, or whether it is related to the raster issue.
I tried loading >50 other packages, and the error seems to be tied to the raster library.
> writeLines(readLines(file.path(Sys.getenv("HOME"), ".R/Makevars")))
##CC=clang
##CXX=clang++
CPPFLAGS="-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"
CC = gcc
CXX=/usr/local/bin/g++-9
CXX1X=/usr/local/clang6/bin/clang++
CXX98=/usr/local/clang6/bin/clang++
CXX11=/usr/local/clang6/bin/clang++
CXX14=/usr/local/clang6/bin/clang++
CXX17=/usr/local/clang6/bin/clang++
LDFLAGS=-L/usr/local/clang6/lib
Warning message:
In readLines(file.path(Sys.getenv("HOME"), ".R/Makevars")) :
incomplete final line found on '/Users/Rosalie/.R/Makevars'
Thanks a lot in advance for any help you may be able to provide. I really have no idea what to test next!
Best,
Rosalie

The issue was with clang.
I first updated to macOS Catalina 10.15.4, then uninstalled the R development toolchain I had for previous version using this code. Then, I used some here:
In the terminal, I used the code xcode-select --install, that open a pop-up window. Press "Install", and follow the steps to install xcode.
Verify installation by taping in gcc --version.
Then, download and install the appropriate gfortran binary find correct version here.
In R, I re-installed Rcpp and raster install.packages("Rcpp", "raster").
I am now able to load the raster without the session abording!

Related

R Unable to Install Packages From GitHub (System Error 267 #win/processx.c:1040)

TL;DR
Unable to install any package from GitHub, System Error 267
I've newly setup R (v4.1), Rstudio and just installed devtools.
I also additionally installed Rtools40 and added it to my path (global environment)
Rtools seems to work properly as validated with: Sys.which("make") & maketools::rtools_find() (output below)
Problem
I am unable to install any package from GitHub, e.g. rstudio/gt. The error is nearly identical for any GitHub Package, allways stating system error 267
devtools::install_github("rstudio/gt")
Downloading GitHub repo rstudio/gt#HEAD
Error: Failed to install 'gt' from GitHub:
create process 'C:/PROGRA~1/R/R-41~1.0/bin/x64/Rcmd.exe' (system error 267, Der Verzeichnisname ist ungültig.
) #win/processx.c:1040 (processx_exec
Update
As suggested I reinstalled R 4.1.0 to the most simple folde possible C:/R/
The error ist still the same despite now lacking tildes ~
devtools::install_github("rstudio/gt")
Downloading GitHub repo rstudio/gt#HEAD
Error: Failed to install 'gt' from GitHub:
create process 'C:/R/bin/x64/Rcmd.exe' (system error 267, Der Verzeichnisname ist ungültig.
) #win/processx.c:1040 (processx_exec)
Update 2:
Changed the .libPaths to a folder without any special characters
.libPaths( c( "D:/tmp" , .libPaths() ) )
.libPaths()
[1] "D:/tmp" "C:/Users/Björn/Documents/R/win-library/4.1"
[3] "C:/R/library"
Error is still the same
Update 3:
I updated some packages, and checked the version of packageVersion('processx')= 3.5.2
install.packages("testthat")
install.packages("pkgload")
install.packages("devtools")
install.packages("remote")
Content of Sys.getenv
Sys.getenv('Path')
[1] "C:\\rtools40\\usr\\bin;C:\\R\\bin\\x64;C:\\rtools40\\usr\\bin;C:\\rtools40\\mingw64\\bin;
Diagnostics
Session Info
> sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)
Matrix products: default
locale:
[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252
[4] LC_NUMERIC=C LC_TIME=German_Germany.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
Rtools successful installed / setup
Sys.which("make")
make
"C:\\rtools40\\usr\\bin\\make.exe"
maketools::rtools_find()
$version
[1] ‘4.0’
$compiler
[1] "gcc 8.3.0"
$api
[1] ‘8’
$PATH
[1] "C:\\rtools40\\usr\\bin"
$BINPREF
[1] "C:/rtools40/mingw$(WIN)/bin/"
$available
[1] TRUE
$compatible
[1] TRUE
The standalone mode of the remotes package solved the issue for me,
as suggested by the maintainer of processx (Gábor Csárdi) here
devtools::install_github() only calls remotes::install_github().
However, for the remotes, there is the option to be exectued in standalone mode
Source: Cran
Standalone mode
remotes will use the curl, git2r and pkgbuild packages if they are
installed to provide faster implementations for some aspects of the
install process. However if you are using remotes to install or update
these packages (or their reverse dependencies) using them during
installation may fail (particularly on Windows).
If you set the environment variable R_REMOTES_STANDALONE="true" (e.g.
in R Sys.setenv(R_REMOTES_STANDALONE="true")) you can force remotes to
operate in standalone mode and use only its internal R
implementations. This will allow successful installation of these
packages
With the following lines of code, gt was finally successfull installed from github.
Sys.setenv(R_REMOTES_STANDALONE="true")
remotes::install_github("rstudio/gt")
Thanks all the commentators for your help!
Update October / 2021
To avoid having to do these steps (Set in standanlone mode, and install with remotes) over and over again everytime you want to install a new package from github another convenient workaround is to just rollback to the previous version of processx as adviced by #rempsy in the github issue:
install.packages("pacman")
pacman::p_del(processx)
# Installing previous verison 3.5.1
install.packages("https://cran.r-project.org/src/contrib/Archive/processx/processx_3.5.1.tar.gz", repos=NULL, type="source")
After the rollback of processx to version 3.5.1, devtools::install_github() works as expected, e.g.
devtools::install_github("rstudio/gt")

CRAN binary packages outdated for tidyverse

When I try to update to the latest version of the tibble package, I am unable to access the binary version 3.1.0 from CRAN. I am given the option to install 3.1.0 from source, but I am running MacOS and unfortunately do not have sufficient hard drive space to install xcode, meaning that I get an error every time I try to install from source. The CRAN tibble page indicates that 3.1.0 should be available as a binary package. Does anyone know why I'm not able to install tibble 3.1.0 as a binary package? Here is what I see when I try to install:
> install.packages('tibble')
There are binary versions available but the source versions are later:
binary source needs_compilation
rlang 0.4.5 0.4.10 TRUE
vctrs 0.2.4 0.3.6 TRUE
tibble 2.1.3 3.1.0 TRUE

Error: Bioconductor version '3.13' requires R version '4.1' (R version 4.0.2)

I found 'similar' questions from other users but none of the answers worked. I am trying to install these packages among others:
if (!require("BiocManager"))
install.packages("BiocManager")
BiocManager::install("maEndToEnd", version = "devel")
if (!require("BiocManager"))
install.packages("BiocManager")
BiocManager::install("ArrayExpress")
----------------------------------------------------------
Error: Bioconductor version '3.13' requires R version '4.1'
My R version 4.0.2, my OS is Ubuntu 20.10
I thought that maybe I could:
a) Change my R version (I did not find for ubuntu R version 4.1)
b) Change my Bioconductor version. For that reason I executed:
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install(version = "3.12")
------------------------------------------------------
Error in packageVersion("BiocManager") :
there is no package called ‘BiocManager’
install("BiocManager")
------------------------------
Error: Can't find 'BiocManager'
´´´
I also tried so many things that I believe I just made worse the situation by eliminating packages from other libraries:
/usr/lib/R/site-library
/home/usr_name/R/x86_64-pc-linux-gnu-library/4.0
This are the packages directories I currently have:
library()
------------------------------------
Packages in library ‘/usr/lib/R/site-library’:
askpass
assertthat
backports
base64enc
BH
Metapackage
bit
bit64
bitops
blob
brew
callr
cli
cliapp
clipr
colorspace
and
etc...
Packages in library ‘/usr/lib/R/library’:
base
boot
for
class
cluster
Extended
etc ...
How may I proceed? As you can tell I am a beginner in everything related to informatics. Any detail would be appreciated.
Unless you really need a particular version of a BioConductor package, you don't need to specify version. Try the following standard approach and see if that works:
install.packages("BiocManager")
library(BiocManager)
install() # Install BioConductor core packages
install("maEndToEnd")
install("ArrayExpress")
'R-4.1' is what current R-devel will become; R-devel is usually installed from source on linux platforms, but is conveniently available as rocker https://hub.docker.com/r/rocker/r-devel/ and Bioconductor https://hub.docker.com/r/bioconductor/bioconductor_docker/tags (look for the 'devel' tag) docker images.
The report about
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install(version = "3.12")
------------------------------------------------------
Error in packageVersion("BiocManager") :
there is no package called ‘BiocManager’
looks incomplete. What happens with
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
? It should install (successfully) BiocManager, and packageVersion("BiocManager") should report a version. Perhaps it would help to start a new session?
For what it's worth, here's the 'version string' that reports 'R under development' but also version 4.1.0
> R.version
_
platform x86_64-apple-darwin17.7.0
arch x86_64
os darwin17.7.0
system x86_64, darwin17.7.0
status Under development (unstable)
major 4
minor 1.0
year 2021
month 02
day 10
svn rev 79979
language R
version.string R Under development (unstable) (2021-02-10 r79979)
nickname Unsuffered Consequences

Separate User Library and System Library in RStudio's Packages pane under Windows 10?

I'm setting up R/RStudio on a new Windows 10 machine; first time setting it up in a non-UNIX environment, so bear with me.
From my previous experience with R/RStudio under Linux and macOS, I wanted to setup separate libraries for system and user, i.e., that the Packages pane in RStudio would show both a User Library AND a System Library.
I specified the R_LIBS_USER environment variable for my account as C:\Users\[user name]\Documents\R\win-library\3.5.
When running R/RStudio, the .libPaths() are as follows:
> .libPaths()
[1] "C:/Users/[user name]/Documents/R/win-library/3.5"
[2] "C:/Program Files/R/R-3.5.0/library"
This is pretty much what I wanted: the first library path being the default User Library, and the second path being the System Library. I'm able to install packages at will, and they are per default located inside the User Library.
HOWEVER, the Packages pane in RStudio does NOT show two separate libraries for the User Library and the System Library. Instead, all packages (aside from base) are shown under System Library; including the packages from my User Library. My question now is:
Is there a way to tell R/RStudio that my User Library and my System Library are two separate entities, which should be visually separated in RStudio's Packages pane?
Note: I'm aware this is likely a mere "cosmetic" issue; but it still bothers me! Also, I'm not sure if this is a pure R or an RStudio issue, so I tagged both.
EDIT: I also noticed that the System Library (C:/Program Files/R/R-3.5.0/library) is not available as drop-down option when installing new packages inside the Packages pane.
--
> devtools::session_info()
Session info --------------------------------------------------------------
setting value
version R version 3.5.0 (2018-04-23)
system x86_64, mingw32
ui RStudio (1.1.453)
language (EN)
collate Nothing to worry about
tz This neither
date 2018-06-08
Packages ------------------------------------------------------------------
package * version date source
base * 3.5.0 2018-04-23 local
compiler 3.5.0 2018-04-23 local
datasets * 3.5.0 2018-04-23 local
devtools 1.13.5 2018-02-18 CRAN (R 3.5.0)
digest 0.6.15 2018-01-28 CRAN (R 3.5.0)
graphics * 3.5.0 2018-04-23 local
grDevices * 3.5.0 2018-04-23 local
memoise 1.1.0 2017-04-21 CRAN (R 3.5.0)
methods * 3.5.0 2018-04-23 local
stats * 3.5.0 2018-04-23 local
tools 3.5.0 2018-04-23 local
utils * 3.5.0 2018-04-23 local
withr 2.1.2 2018-03-15 CRAN (R 3.5.0)
yaml 2.1.19 2018-05-01 CRAN (R 3.5.0)
I had exactly the same issue. In my case the cause was using a substituted drive for the user libraries:
> subst
F:\: => C:\data\flash drive
Setting R_LIBS_USER to F:/[...] shows the cosmetic error, using C:/data/flash drive/[...] works.
In my case, Sys.getenv("R_LIBS_USER") is as follow:
"C:\\Users\\USERNAME\\AppData\\Local/R/win-library/4.2"
This path includes two backslashes, so this was causing the environment variable to not be recognized correctly.
Next I searched for a place to put .Renviron as follows
R.home(component = "etc")
I created .Renviron (or Renviro.site) in that folder and saved it with the following in the contents and it worked.
R_LIBS_USER=C:/Users/${USERNAME}/AppData/Local/R/win-library/%v

R Markdown - opt_hooks not exported

Hi I am completely new to R markdown but everytime I try to knit and creat an html file it gives me this error
Error: 'opts_hooks' is not an exported object from 'namespace:knitr'
Execution halted
Can someone please help me? I have installed the knitr package but I don't know how to export opt_hooks.
I got the same issue, i guess this is an update of rmarkdown/rstudio button (didn't check) because this workaround works fine :
# to md
knit("myRmarkdown.Rmd")
# to html
knit2html("myRmarkdown.md")
Hope it helps.
PS: session info dump :
> devtools::session_info()
Session info ------------------------------------------------------------------------------------------------------------------------------
setting value
version R version 3.2.0 (2015-04-16)
system x86_64, linux-gnu
ui RStudio (0.99.902)
language (EN)
collate fr_FR.UTF-8
tz Europe/Paris
Packages ----------------------------------------------------------------------------------------------------------------------------------
package * version date source
devtools 1.8.0 2015-05-09 CRAN (R 3.2.0)
knitr * 1.11 2015-08-14 CRAN (R 3.2.0)
rmarkdown 0.9.6 2016-05-01 CRAN (R 3.2.0)

Resources