How can I install a R package on a offline Debian machine? - r

I have an Debian VM which is not connected to internet. Yet, I can still scp any file from my local machine which does have internet connection. To provide a little bit context, I am trying to host an shiny app on the VM.
I can still install an old version of R 3.1.1 with the "apt-get" command:
sudo apt-get update
sudo apt-get install r-base
sudo apt-get install r-base-dev
Yet, still can't find the "shiny" package when check the list:
sudo apt-cache search "^r-.*" | sort
So, I am thinking whether I could just scp the "shiny.tar.gz" to the VM and install the package locally? How could I install any R package offline?
I have tried somethings like:
install.packages('/home/mli/R/dir_pkg/shiny/shiny_0.13.2.tar.gz', repos = NULL, type = "source")
Yet, it didn't go through and error message as below:
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Error in type == "both" :
comparison (1) is possible only for atomic and list types
Calls: install.packages
Execution halted
Then, I tried it with another "R CMD":
R CMD INSTALL /home/mli/R/dir_pkg/shiny/shiny_0.13.2.tar.gz
I got error message telling me that dependencies is missing:
* installing to library ‘/home/mli/R/x86_64-pc-linux-gnu-library/3.1’
ERROR: dependencies ‘httpuv’, ‘mime’, ‘jsonlite’, ‘xtable’, ‘digest’, ‘htmltools’, ‘R6’ are not available for package ‘shiny’
* removing ‘/home/mli/R/x86_64-pc-linux-gnu-library/3.1/shiny’
How can I successfully install shiny package from source? Should I go ahead to install all dependencies and dependencies of dependencies first?

Shiny has a few package dependencies, and "R CMD INSTALL" won't find them for you, so you need to get them manually. According to the description of shiny, it's dependencies are:
'Rcpp’, ‘httpuv’, ‘mime’, ‘jsonlite’, ‘xtable’, ‘digest’, ‘htmltools’, ‘R6’.
So first, get the packages from cran (below are current versions, but they do change over time. Note below is for the computer connected to the internet, you'll need to scp these to the offline computer before continuing):
wget https://cran.r-project.org/src/contrib/Rcpp_0.12.4.tar.gz
wget https://cran.r-project.org/src/contrib/httpuv_1.3.3.tar.gz
wget https://cran.r-project.org/src/contrib/mime_0.4.tar.gz
wget https://cran.r-project.org/src/contrib/jsonlite_0.9.19.tar.gz
wget https://cran.r-project.org/src/contrib/digest_0.6.9.tar.gz
wget https://cran.r-project.org/src/contrib/htmltools_0.3.5.tar.gz
wget https://cran.r-project.org/src/contrib/R6_2.1.2.tar.gz
wget https://cran.r-project.org/src/contrib/shiny_0.13.2.tar.gz
Then go through them in that same order with R CMD INSTALL. eg:
R CMD INSTALL Rcpp_0.12.4.tar.gz
Once all the dependencies are there, R CMD INSTALL should let you install shiny.

To install some package-offline on Debian you can use apt-offline :
apt-offline can fully update and upgrade an APT based distribution without connecting to the network, all of it transparent to APT.
apt-offline can be used to generate a signature on a machine (with no network). This signature contains all download information required for the APT database system. This signature file can be used on another machine connected to the internet (which need not be a Debian box and can even be running windows) to download the updates. The downloaded data will contain all updates in a format understood by APT and this data can be used by apt-offline to update the non-networked machine.
Install apt-offline on the offline os (Debian) then type the following command (to import missing keys) :
sudo apt-key exportall | sudo gpg --no-default-keyring --import --keyring /etc/apt/trusted.gpg
Then you need to get the signature of your_package_name:
apt-offline set debian-install.sig --install-packages your_package_name
Next step ,Upload debian-install.sig to the on-line system and download required files.
apt-offline get debian-install.sig --bundle debian-install.zip
Upload debian-install.zip file to the off-line system, install it using apt-offline utility to update APT database.
sudo apt-offline install debian-install.zip
install the specified packages your_package_name :
sudo apt-get install your_package_name
You can download your package using windows machine tuto

You are in a pickle. The R package mechanism expects you to be connected to get dependencies. That said, you can get some help:
R> AP <- available.packages(contrib.url(options("repos")$repos[1]))
R> revs <- tools::package_dependencies("shiny", AP, recursive=TRUE)[[1]]
R> revs
[1] "methods" "utils" "httpuv" "mime"
[5] "jsonlite" "xtable" "digest" "htmltools"
[9] "R6" "Rcpp" "tools" "stats"
R>
You can now look into AP again and feed this into download.packages().
Also, several (all ?) of these are in a newer Debian distro so you could use apt-get in download-mode (maybe using apt-offline as suggested in the other question).
Lastly, we do offer a Docker container for shiny so if you use that on your VM you don't need anything else.

sudo apt-get update
sudo apt-get install r-cran-digest
I can`t belive that it was so easy. I spent a long time searching and got only bad answers. This commands just solve everything.
I used it on trisquel

after checking all the answers on stackoverflow, I am not able to find exactly how to to install r-base on Debian/linux system. So, I have tried myself and able to run by below steps:
Run below command on internet working Linux machine in a custom folder.
apt-get download r-base r-base-core r-recommended libmpfr6 libisl19 cpp cpp-8 cpp-4 gcc cpp-8 binutils-common libbinutils binutils-x86-64-linux-gn gfortran linux-libc-dev g++ g++-8 libstdc make dpkg-dev perl-base perl-modules-5.28 libperl5.28 ibgdbm-compat4 zip unzip libpaper-utils xdg-utils libblas3 libblas.so.3 libcairo2 libcurl4 libgfortran5 libglib2.0-0 libice6 libicu63 libjpeg62-turbo liblapack3 liblapack.so.3 libpango-1.0-0 libpangocairo-1.0-0 libpng16-16 libsm6 libtcl8.6 libtiff5 libtk8.6 libx11-6 libxext6 libxss1 libxt6 ucf libfontconfig1 libfreetype6 libpixman-1-0 libxcb-render0 libxcb-shm0 libxcb1 libxrender1 libgssapi-krb5-2 libk5crypto3 libkrb5-3 libldap-2.4-2 libnghttp2-14 libpsl5 librtmp1 libssh2-1 libbsd0 x11-common fontconfig libfribidi0 libthai0 libcairo2:amd64 libfontconfig1 libfreetype6 libpango-1.0-0:amd64 libpangoft2-1.0-0 fontconfig-config libkeyutils1 libkrb5support0 libkeyutils1 libkrb5support0 libkeyutils1 libkrb5support0 libsasl2-2 libldap-common fontconfig-config libharfbuzz0b libpaper1 libsasl2-modules-db libthai-data libdatrie1 libwebp6 libjbig0 libxft2 libx11-data libxau6 libxdmcp6 fonts-dejavu-core ttf-bitstream-vera fonts-liberation libgraphite2-3 lsb-base sensible-utils r-cran-boot r-cran-cluster r-cran-foreign r-cran-kernsmooth r-cran-lattice r-cran-mgcv r-cran-nlme r-cran-rpart r-cran-survival r-cran-mass r-cran-class r-cran-nnet r-cran-spatial r-cran-codetools r-cran-matrix
This will create debian files inside the folder.
`Execute tar -zcf folder.tar.gz folder`
Copy this folder.tar.gz in offline computer and execute below command after going inside the folder.
dpkg -i *
Now check R in your system by typing
R --version

Related

R ERROR: dependencies ‘xml2’, ‘httr’ are not available for package (Linux Mint 20.1)

I did not quite know where this belongs exactly, so I decided to post this here on stack overflow.
I recently had package issues with R and R-Studio on Linux Mint 20.1, where I always recieved dependency errors when installing packages like plotly and tidyverse. Therefore, in order to test if my system was responsible I live booted a fresh Linux Mint USB and installed R and R-Studio the following way:
sudo apt update
sudo apt dist-upgrade
sudo apt install r-base
Then download R-Studio from here and installed it like:
sudo apt-get install gdebi-core
# Install R-Studio with gdebi
sudo gdebi rstudio-1.2.5042-amd64.deb
Then, I opened RStudio by typing rstudio in the terminal. Inside RStudio I tried to install the package tidyverse by install.packages("tidyverse") which resulted in some dependency errors like:
ERROR: dependencies ‘xml2’, ‘httr’ are not available for package ‘rvest’
* removing ‘/home/mint/R/x86_64-pc-linux-gnu-library/3.6/rvest’
* installing *source* package ‘tibble’ ...
The solution was to use the command, suggested in the r-lib issue by #fredaas:
sudo apt install build-essential libcurl4-gnutls-dev libxml2-dev libssl-dev
By using this command I was able to resolve the issue and install every package I required flawlessly.
I am sorry if this does not belong here but I hope I can help someone saving hours of troubleshooting. This issues is maybe caused by Linux Mint or the most recent R Version 4.0.3 so I was not sure where to share my results.

Not able to install packages MicrosoftML and mrsdeploy in R studio

I am trying to deploy R code onto server. But for I think we need to install both MicrosoftML and mrsdeploy. But I get an error while trying to download:
install.packages("MicrosoftML")
Installing package into ‘C:/Users/vinay/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
Warning in install.packages :
package ‘MicrosoftML’ is not available (for R version 3.5.2)
install.packages("mrsdeploy")
Installing package into ‘C:/Users/vinay/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
Warning in install.packages :
package ‘mrsdeploy’ is not available (for R version 3.5.2)
As the above error suggest you that the packages MicrosoftML and mrsdeploy are not available in R version 3.5.2, so you will have to use the R version in which these packages are present/compatible.
You can refer to this issue:
https://github.com/MicrosoftDocs/feedback/issues/352
For MicrosoftML refer to this:
https://learn.microsoft.com/en-gb/machine-learning-server/r/concept-what-is-the-microsoftml-package
You need to make an R Client deployment to have the ability to use the RevoScaleR, MicrosoftML, and mrsdeploy packages. Specifically for R version 3.5.2 and Ubuntu 14.04 - 16.04, please follow the following steps:
# Install as root or sudo
sudo su
# If your system does not have the https apt transport option, add it now
apt-get install apt-transport-https
# Set the package repository location containing the R Client distribution.
# On Ubuntu 14.04.
# wget http://packages.microsoft.com/config/ubuntu/14.04/prod/packages-microsoft-prod.deb
# On Ubuntu 16.04.
wget http://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb
# Register the repo.
dpkg -i packages-microsoft-prod.deb
# Check for microsoft-prod.list configuration file to verify registration.
ls -la /etc/apt/sources.list.d/
# Update packages on your system
apt-get update
# Install the 3.5.2 packages
# Alternative for 3.4.1: apt-get install microsoft-r-client-packages-3.4.1
# Alternative for 3.4.3: apt-get install microsoft-r-client-packages-3.4.3
apt-get install microsoft-r-client-packages-3.5.2
# List the packages
ls /opt/microsoft/rclient/
Then download one of:
Ubuntu 14.04:
wget https://packages.microsoft.com/ubuntu/14.04/prod/pool/main/m/microsoft-r-client-packages-3.5.2/microsoft-r-client-packages-3.5.2.deb
Ubuntu 16.04:
wget https://packages.microsoft.com/ubuntu/16.04/prod/pool/main/m/microsoft-r-client-packages-3.5.2/microsoft-r-client-packages-3.5.2.deb
Install the packages with:
dpkg -i *.deb
If you use RStudio you can on Linux add R_LIBS_SITE=/opt/microsoft/rclient/3.5.2/libraries/RServer on bottom of the file /opt/microsoft/rclient/3.5.2/runtime/R/etc/Renviron
Both packages mrsdeploy and MicrosoftML will be now available from RStudio as you can check with:
library(mrsdeploy)
library(MicrosoftML)
For instructions like the above for newer R versions please check this Microsoft Docs page.

Directory Issue, can't install RStudio Server Packages Ubuntu

I set up an Ubuntu VM and can't install packages.
Installing package into ‘/home/username/R/x86_64-pc-linux-gnu-library/3.0’
(as ‘lib’ is unspecified)
It looks like all default packages are saved in /usr/lib/R/library
But and RStudio is trying to write new packages into /home/username/R/x86_64-pc-linux-gnu-library/3.0
.libPaths()
[1] "/home/username/R/x86_64-pc-linux-gnu-library/3.0" "/usr/local/lib/R/site-library"
[3] "/usr/lib/R/site-library" "/usr/lib/R/library"
I also tried to upload the packages directly to /usr/lib/R/library through FileZilla but I'm getting the following error messages
mkdir /usr/lib/R/library/jsonlite: permission denied
How can I install the packages I need?
After investing the issue further today, I was able to solve it. The problem was due to an outdated version of R, and missing libraries (curl, xml).
the $ sudo apt-get install r-base command installs whatever version is available on the server.
Therefore it's important to get the latest version
sudo sh -c 'echo "deb http://cran.rstudio.com/bin/linux/ubuntu trusty/" >> /etc/apt/sources.list'
I reinstalled R following this tutorial in case anyone runs into the same issue.
Setting Up R Studio Server On Microsoft Azure
Hope this is helpful

Installation of igraph package of R in ubuntu

I am using the following command for the installation of igraph package of R in ubuntu : install.packages("igraph")
But I am getting an error saying:
Warning: unable to access index for repository
http://ftp.iitm.ac.in/cran/src/contrib: cannot open URL
'http://ftp.iitm.ac.in/cran/src/contrib/PACKAGES' Warning messages:
package ‘igraph’ is not available (for R version 3.3.2)
Can someone please guide regarding this problem, where I am going wrong in this...
You probably want a binary package anyway, and I recently re-explained how to do this:
The easiest way is something like this (and I am showing only the commands, not the output while I do this in a Docker instance of Ubuntu 16.04, and I am doing this in Docker where the account is root; otherwise add sudo in front)
apt-get update # refresh
apt-get install software-properties-common
add-apt-repository -y "ppa:marutter/rrutter"
add-apt-repository -y "ppa:marutter/c2d4u"
apt-get update # now with new repos
apt-get install r-cran-igraph
and it will just work with all its dependencies. You didn't tell us what Ubuntu version you have. What I showed works eg in Ubuntu 16.04; for much older releases you need a different package for the add-apt-repository command.
I suspect either the server is down or your network is down or you need to go via a proxy.
I can duplicate this message by setting an unobtainable CRAN mirror with:
> options(repos="http://example.com/")
> install.packages("foo")
Installing package into ‘/nobackup/rowlings/RLibrary/R/x86_64-pc-linux-gnu-library/3.2’
(as ‘lib’ is unspecified)
Warning: unable to access index for repository http://example.com/src/contrib:
cannot open URL 'http://example.com/src/contrib/PACKAGES'
Warning message:
package ‘foo’ is not available (for R version 3.2.3)
So either try again and maybe the server is up, or check your local network is okay, or try another CRAN mirror, or check with your local network admins to see if you need to set a proxy server.
you have to install build-essential first
sudo apt-get install build-essential
also on Ubuntu and Debian Linux the lixml2 and libxml2-dev packages are needed to install to R.
if that does not work check the webpage of the package for extra documentation

Install shiny on remote Debian machine with R version 3.1.1

I am trying to host an shiny app on an remote Debian machine. Yet, i have encountered an R version issue when installing shiny package. I will basically walk through the steps that I took in the process:
After SSH into the VM, I install and update the r-base:
sudo apt-get update
sudo apt-get install r-base
sudo apt-get install r-base-dev
The latest version I can get for R is 3.1.1. Then, I was trying to install "shiny" package as root by the following command:
sudo su - -c "R -e \"install.packages('shiny', repos='http://cran.rstudio.com/')\""
Then, I was getting the error message like:
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Warning: unable to access index for repository http://cran.rstudio.com/src/contrib
Warning message:
package ‘shiny’ is not available (for R version 3.1.1)
Is there any work-around on this issue? Such as starch the apt-get to install the latest R version rather than 3.1.1? Or possibly install shiny from a Github repo? Please help! Thanks!
You should be able to get the R package yourself, rather than using apt-get. This way you can choose which release to install. For example:
wget http://cran.rstudio.com/src/base/R-3/R-3.2.2.tar.gz
tar zxvf R-3.2.2.tar.gz; cd R-3.2.2/
./configure; make;
sudo make install
Then you can get shiny through the terminal as well, rather than within R:
wget https://cran.r-project.org/src/contrib/shiny_0.13.2.tar.gz
sudo R CMD INSTALL shiny_0.13.2.tar.gz
credit to Huiong Tian, from whom I learned this a while back:
http://withr.me/install-shiny-server-on-raspberry-pi/

Resources