Skip to content

Instantly share code, notes, and snippets.

@axd1967
Last active March 26, 2017 15:27
Show Gist options
  • Save axd1967/18de5265445b4c46a42267238070525a to your computer and use it in GitHub Desktop.
Save axd1967/18de5265445b4c46a42267238070525a to your computer and use it in GitHub Desktop.
# when attempting to install RSQLite in a pristine Vagrant VM, I get a strange error (see lower)
# plus, logging in on the VM confirms that the RSQLite package /IS/ installed: `require('RSQLite')` is OK.
# if I comment the first line and uncomment the second line, installation completes fine.
# this error seems to randomly appear with other packages too...
(for the full script, see end of this file)
#####################################################################
#####################################################################
apt-get install -q -y \
sqlite3 libsqlite3-dev \
\
#devtools::install_github("rstats-db/RSQLite")
R --no-save --quiet << HERE
require('RSQLite') || install.packages("RSQLite", repos='http://cran.rstudio.com/') # <-- FIXME: reports an error
#install.packages("RSQLite", repos='http://cran.rstudio.com/') # seems to work
HERE
#####################################################################
#####################################################################
result:
==> dev: installing to /usr/local/lib/R/site-library/RSQLite/libs
==> dev: ** R
==> dev: ** inst
==> dev: ** preparing package for lazy loading
==> dev: ** help
==> dev: *** installing help indices
==> dev: ** building package indices
==> dev: ** installing vignettes
==> dev: ** testing if installed package can be loaded
==> dev: * DONE (RSQLite)
==> dev: The downloaded source packages are in
==> dev: ‘/tmp/RtmpDEGcbT/downloaded_packages’
==> dev: Error in require("RSQLite") || install.packages("RSQLite", repos = "http://cran.rstudio.com/") :
==> dev: invalid 'y' type in 'x || y'
==> dev: In addition:
==> dev: Warning message:
==> dev: In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :
==> dev:
==> dev:
==> dev: there is no package called ‘RSQLite’
==> dev: Execution halted
#####################################################################
#####################################################################
full script:
#!/usr/bin/env bash
cd /tmp
set -x
set -e
THIS=`basename $0`
locale-gen en_IE.UTF-8
locale-gen nl_BE.UTF-8
#source my.config
function apt_update(){
# The Debian backports archives on CRAN are signed with the key of "Johannes Ranke (CRAN Debian archive) " with key ID 381BA480. You can fetch this with
#gpg --keyserver subkeys.pgp.net --recv-key 381BA480
#gpg -a --export 381BA480 > jranke_cran.asc
#apt-key add jranke_cran.asc
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9
# or
#gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys E084DAB9
#gpg -a --export E084DAB9 | apt-key add -
#MIRROR=http://lib.ugent.be/CRAN
MIRROR=http://www.freestatistics.org/cran/
cat > /etc/apt/sources.list << EOF
deb http://ftp.belnet.be/ubuntu.com/ubuntu trusty main restricted universe multiverse
deb http://ftp.belnet.be/ubuntu.com/ubuntu trusty-updates main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu trusty-security main restricted universe multiverse
deb $MIRROR/bin/linux/ubuntu trusty/
#deb $MIRROR trusty-backports main restricted universe
EOF
apt-get update
}
function install_R(){
apt-get install -y \
r-base \
\
#apt-get install -y \
# r-base-dev texlive-full \
# \
#
#apt-get build-dep r-base-core
R --version
}
function install_RStudio_server(){
set -x
rstudio-server version && return || echo "installing rstudio-server"
apt-get install -y \
gdebi-core \
\
FILE=rstudio-server-1.0.136-amd64.deb
DEB=https://download2.rstudio.org/$FILE
wget --no-verbose $DEB
gdebi --non-interactive $FILE
rm $FILE
#rstudio-server verify-installation
rstudio-server version
}
function install_R_Shiny(){
set -x
R --no-save --quiet << HERE
require('shiny') || install.packages('shiny', repos='https://cran.rstudio.com/')
HERE
FILE=shiny-server-1.5.3.838-amd64.deb
if [ ! -f $FILE ]; then
DEB=https://download3.rstudio.org/ubuntu-12.04/x86_64/$FILE
wget --no-verbose $DEB
gdebi --non-interactive $FILE || rm $FILE 'fail' # trigger `exit 1` after removing the file
else
echo "shiny-server should be OK"
return
fi
R --no-save --quiet << HERE
require('shinyjs') || install.packages("shinyjs", repos='http://cran.rstudio.com/')
require('DT') || install.packages("DT", repos='http://cran.rstudio.com/')
# devtools::install_github('daattali/shinyjs')
HERE
}
function install_R_packages(){
R --no-save --quiet << HERE
require('rmarkdown') || install.packages("rmarkdown", repos='http://cran.rstudio.com/')
require('caTools') || install.packages("caTools", repos='http://cran.rstudio.com/')
HERE
}
function install_sqlite(){
apt-get install -q -y \
sqlite3 libsqlite3-dev \
\
#devtools::install_github("rstats-db/RSQLite")
R --no-save --quiet << HERE
require('RSQLite') || install.packages("RSQLite", repos='http://cran.rstudio.com/')
#install.packages("RSQLite", repos='http://cran.rstudio.com/') # for some reason, install.packages("RSQLite", repos='http://cran.rstudio.com/') returns an error
HERE
}
function install_MySQL(){
apt-get install -y -q \
debconf-utils \
\
MYSQL_DBA_PASSWORD="root"
export DEBIAN_FRONTEND=noninteractive
debconf-set-selections <<< "mysql-server-5.5 mysql-server/root_password password "$MYSQL_DBA_PASSWORD
debconf-set-selections <<< "mysql-server-5.5 mysql-server/root_password_again password "$MYSQL_DBA_PASSWORD
apt-get install -q -y \
mysql-server-5.5 \
\
# Run the MySQL Secure Installation wizard
#mysql_secure_installation
#
#sed -i 's/127\.0\.0\.1/0\.0\.0\.0/g' /etc/mysql/my.cnf
#mysql -uroot -p -e 'USE mysql; UPDATE `user` SET `Host`="%" WHERE `User`="root" AND `Host`="localhost"; DELETE FROM `user` WHERE `Host` != "%" AND `User`="root"; FLUSH PRIVILEGES;'
}
function install_varia(){
apt-get install -q -y \
git \
tree \
htop \
\
}
function install_devtools() {
apt-get install -q -y \
libcurl4-gnutls-dev \
libxml2-dev \
libssl-dev \
\
R --no-save --quiet << HERE
require('devtools') || install.packages('devtools', repos='http://cran.rstudio.com/')
HERE
}
# create users
#useradd --shell /bin/bash --create-home --home /home/user user
# create directories
# ...
#./install.sh
apt_update
install_varia
install_R
#install_devtools
# database
install_sqlite
#install_MySQL
install_RStudio_server
install_R_Shiny
echo "$THIS: done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment