I am not able to install RStoolbox packages in Ubuntu

The RStudio server is showing error in installing devtools, RStoolbox. Error messages are:

For install.packages("RStoolbox"):

ERROR: lazy loading failed for package ‘exactextractr’

removing ‘/home/jannatul/R/x86_64-pc-linux-gnu-library/4.2/exactextractr’
Warning in install.packages :
installation of package ‘exactextractr’ had non-zero exit status
ERROR: dependencies ‘rgdal’, ‘exactextractr’ are not available for package ‘RStoolbox’
removing ‘/home/jannatul/R/x86_64-pc-linux-gnu-library/4.2/RStoolbox’
Warning in install.packages :
installation of package ‘RStoolbox’ had non-zero exit status

The downloaded source packages are in
‘/tmp/Rtmpbz9sJx/downloaded_packages’

When I tried to install dependencies, it showed error:

Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package libgdal1-dev

I tried the code below for installing dependencies, it installed

sudo apt -y install libgdal-dev

but still couldn't install RStoolbox packages. It showed the same error:

"ERROR: dependencies ‘rgdal’, ‘exactextractr’ are not available for package ‘RStoolbox’
installation of package ‘RStoolbox’ had non-zero exit status"

Any suggestions will be highly appreciated! Thank you so much.

I can install rgdal on Ubuntu 22.04.1 for WSL2 without any issues. These are the system libraries I usually install for spatial packages, give them a try.

sudo apt install libgdal-dev gdal-bin libgeos-dev libproj-dev libudunits2-dev sqlite3

Do you get any error messages while doing this?

No, I didn't get any error messages. It showed already the newest version (3.4.3+dfsg-1~focal0) were there, as I have installed them already. Thank you.

Can you show the complete console output you get when you try to install rgdal?
Also, maybe you would have better luck by installing a binary from the public RStudio Package Manager

install.packages("rgdal", repos=c('https://packagemanager.rstudio.com/all/__linux__/jammy/latest', 'https://cran.rstudio.com/'))

Note: This repository is specific for Ubuntu 22.04.1, make sure you are using this Ubuntu version.

I am using Ubuntu 20.04 LTS. Shall I still try that code?

##The R console output is:

Thank you!

Please do not post screenshots, it is considered a bad practice here, post the console output as formatted code instead, here is how to do it:

Now about your issue, you are showing a very different error message now

#> free() invalid pointer 
#> Aborted
#> ERROR: loading failed

it seems your system has fallen into a bad state I would try restarting the whole thing (Just closing the console doesn't restart WSL2) and trying to install rgdal again.

For Ubuntu 20 the RSPM repository has a different link, you can try with this

install.packages("rgdal", repos=c('https://packagemanager.rstudio.com/all/__linux__/focal/latest', 'https://cran.rstudio.com/'))

My apology for the screenshots. Thank you for the instructions.

Did you mean installing the WSL2 again?

No, just restarting WSL2 (or your computer) is enough.

I have tried this code. rgdal has been installed :slightly_smiling_face: but the other dependency ‘exactextractr’has not been installed. And RStoolbox installation was aborted.

install.packages("rgdal", repos=c('https://packagemanager.rstudio.com/all/__linux__/focal/latest', 'https://cran.rstudio.com/'))

[Show in New Window]

Installing package into ‘/home/jannatul/R/x86_64-pc-linux-gnu-library/4.2’
(as ‘lib’ is unspecified)
also installing the dependency ‘exactextractr’

trying URL 'https://cloud.r-project.org/src/contrib/exactextractr_0.9.0.tar.gz'
Content type 'application/x-gzip' length 629871 bytes (615 KB)
==================================================
downloaded 615 KB

trying URL 'https://cloud.r-project.org/src/contrib/RStoolbox_0.3.0.tar.gz'
Content type 'application/x-gzip' length 991987 bytes (968 KB)
==================================================
downloaded 968 KB

* installing *source* package ‘exactextractr’ ...
** package ‘exactextractr’ successfully unpacked and MD5 sums checked
** using staged installation
configure: exactextractr: 0.9.0
checking for geos-config... /bin/geos-config
checking geos-config usability... yes
configure: GEOS version: 3.10.2
checking geos version at least 3.5.0... yes
checking compiling and building against geos_c... yes
configure: PKG_CXX: g++
configure: PKG_CXXFLAGS: -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include
configure: PKG_LIBS: -Wl,-Bsymbolic-functions -Wl,-z,relro -L/usr/lib/x86_64-linux-gnu -lgeos_c
configure: creating ./config.status
config.status: creating src/Makevars
** libs
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG  -I'/home/jannatul/R/x86_64-pc-linux-gnu-library/4.2/Rcpp/include'   -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c RcppExports.cpp -o RcppExports.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG  -I'/home/jannatul/R/x86_64-pc-linux-gnu-library/4.2/Rcpp/include'   -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c exact_extract.cpp -o exact_extract.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG  -I'/home/jannatul/R/x86_64-pc-linux-gnu-library/4.2/Rcpp/include'   -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c raster_utils.cpp -o raster_utils.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG  -I'/home/jannatul/R/x86_64-pc-linux-gnu-library/4.2/Rcpp/include'   -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c coverage_fraction.cpp -o coverage_fraction.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG  -I'/home/jannatul/R/x86_64-pc-linux-gnu-library/4.2/Rcpp/include'   -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c rasterize.cpp -o rasterize.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG  -I'/home/jannatul/R/x86_64-pc-linux-gnu-library/4.2/Rcpp/include'   -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c resample.cpp -o resample.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG  -I'/home/jannatul/R/x86_64-pc-linux-gnu-library/4.2/Rcpp/include'   -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c exactextract/src/area.cpp -o exactextract/src/area.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG  -I'/home/jannatul/R/x86_64-pc-linux-gnu-library/4.2/Rcpp/include'   -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c exactextract/src/box.cpp -o exactextract/src/box.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG  -I'/home/jannatul/R/x86_64-pc-linux-gnu-library/4.2/Rcpp/include'   -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c exactextract/src/cell.cpp -o exactextract/src/cell.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG  -I'/home/jannatul/R/x86_64-pc-linux-gnu-library/4.2/Rcpp/include'   -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c exactextract/src/coordinate.cpp -o exactextract/src/coordinate.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG  -I'/home/jannatul/R/x86_64-pc-linux-gnu-library/4.2/Rcpp/include'   -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c exactextract/src/floodfill.cpp -o exactextract/src/floodfill.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG  -I'/home/jannatul/R/x86_64-pc-linux-gnu-library/4.2/Rcpp/include'   -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c exactextract/src/geos_utils.cpp -o exactextract/src/geos_utils.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG  -I'/home/jannatul/R/x86_64-pc-linux-gnu-library/4.2/Rcpp/include'   -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c exactextract/src/grid.cpp -o exactextract/src/grid.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG  -I'/home/jannatul/R/x86_64-pc-linux-gnu-library/4.2/Rcpp/include'   -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c exactextract/src/perimeter_distance.cpp -o exactextract/src/perimeter_distance.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG  -I'/home/jannatul/R/x86_64-pc-linux-gnu-library/4.2/Rcpp/include'   -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c exactextract/src/raster_cell_intersection.cpp -o exactextract/src/raster_cell_intersection.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG  -I'/home/jannatul/R/x86_64-pc-linux-gnu-library/4.2/Rcpp/include'   -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c exactextract/src/side.cpp -o exactextract/src/side.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG  -I'/home/jannatul/R/x86_64-pc-linux-gnu-library/4.2/Rcpp/include'   -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c exactextract/src/traversal.cpp -o exactextract/src/traversal.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG  -I'/home/jannatul/R/x86_64-pc-linux-gnu-library/4.2/Rcpp/include'   -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c exactextract/src/traversal_areas.cpp -o exactextract/src/traversal_areas.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG  -I'/home/jannatul/R/x86_64-pc-linux-gnu-library/4.2/Rcpp/include'   -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c exactextract/src/weighted_quantiles.cpp -o exactextract/src/weighted_quantiles.o
g++ -std=gnu++14 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o exactextractr.so RcppExports.o exact_extract.o raster_utils.o coverage_fraction.o rasterize.o resample.o exactextract/src/area.o exactextract/src/box.o exactextract/src/cell.o exactextract/src/coordinate.o exactextract/src/floodfill.o exactextract/src/geos_utils.o exactextract/src/grid.o exactextract/src/perimeter_distance.o exactextract/src/raster_cell_intersection.o exactextract/src/side.o exactextract/src/traversal.o exactextract/src/traversal_areas.o exactextract/src/weighted_quantiles.o -Wl,-Bsymbolic-functions -Wl,-z,relro -L/usr/lib/x86_64-linux-gnu -lgeos_c -L/usr/lib/R/lib -lR
installing to /home/jannatul/R/x86_64-pc-linux-gnu-library/4.2/00LOCK-exactextractr/00new/exactextractr/libs
** R
** inst
** byte-compile and prepare package for lazy loading
double free or corruption (out)
Aborted
ERROR: lazy loading failed for package ‘exactextractr’
* removing ‘/home/jannatul/R/x86_64-pc-linux-gnu-library/4.2/exactextractr’
Warning in install.packages :
  installation of package ‘exactextractr’ had non-zero exit status
ERROR: dependency ‘exactextractr’ is not available for package ‘RStoolbox’
* removing ‘/home/jannatul/R/x86_64-pc-linux-gnu-library/4.2/RStoolbox’
Warning in install.packages :
  installation of package ‘RStoolbox’ had non-zero exit status

The downloaded source packages are in
	‘/tmp/RtmpZI5NSw/downloaded_packages’

I couldn't install devtools package also. Thank you very much for helping me. I appreciated it.

This is a problem between your system and the compiler, I have never seen this sort of low-level memory corruption issue so I have no idea what the cause might be.
The only workaround solution I can think off is to install exactextractr and RStoolbox also from the RSPM

install.packages("exactextractr", repos=c('https://packagemanager.rstudio.com/all/__linux__/focal/latest', 'https://cran.rstudio.com/'))
install.packages("RStoolbox", repos=c('https://packagemanager.rstudio.com/all/__linux__/focal/latest', 'https://cran.rstudio.com/'))

Thank you. Now I have received another error for installing RStoolbox about boot system. It says host is down. The error message is

** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to create bus connection: Host is down
Warning in system("timedatectl", intern = TRUE) :
  running command 'timedatectl' had status 1
double free or corruption (out)
Aborted
ERROR: lazy loading failed for package ‘RStoolbox’
* removing ‘/home/jannatul/R/x86_64-pc-linux-gnu-library/4.2/RStoolbox’
Warning in install.packages :
  installation of package ‘RStoolbox’ had non-zero exit status

The downloaded source packages are in
	‘/tmp/Rtmpgs1b05/downloaded_packages’

Do you know what can be the reason for it? Thank you so much.

Sorry but I'm out of ideas, there is something weird going on with your setup since I can't replicate your issues on WSL2.

It's okay. Thank you for helping me tough.
Do you know any other way instead of windows subsystem that will allow me to boot two system together?

You can use full virtual machines with VirtualBox or VMware or you can also install a Linux distribution natively in a different drive or partition in your computer but that is outside of this forum's scope.

Sounds good! Thank you for the suggestions. I appreciated it!

This topic was automatically closed after 45 days. New replies are no longer allowed.


If you have a query related to it or one of the replies, start a new topic and refer back with a link.