Skip to content

Instantly share code, notes, and snippets.

@hancush
Last active August 5, 2021 16:47
Show Gist options
  • Save hancush/8704ea98480f694b60acfbb45e100077 to your computer and use it in GitHub Desktop.
Save hancush/8704ea98480f694b60acfbb45e100077 to your computer and use it in GitHub Desktop.

My R Version:

call-me-hank:analysis-drug-charges hannah$ Rscript --version
R scripting front-end version 4.0.0 (2020-04-24)

After the first round of errors, I uninstalled everything using uninstall.R, then ran install.R. (Both are attached to this gist, for reference.) Here are some excerpts from the output.

Seems like a few packages are not available

ERROR: dependency ‘rgdal’ is not available for package ‘gdalUtils’
* removing ‘/usr/local/Cellar/r/4.0.0/lib/R/library/gdalUtils’
ERROR: dependency ‘units’ is not available for package ‘sf’
* removing ‘/usr/local/Cellar/r/4.0.0/lib/R/library/sf’
...
* DONE (leafsync)
ERROR: dependency ‘sf’ is not available for package ‘leafem’
* removing ‘/usr/local/Cellar/r/4.0.0/lib/R/library/leafem’
ERROR: dependency ‘sf’ is not available for package ‘leafpop’
* removing ‘/usr/local/Cellar/r/4.0.0/lib/R/library/leafpop’
ERROR: dependencies ‘units’, ‘sf’ are not available for package ‘lwgeom’
* removing ‘/usr/local/Cellar/r/4.0.0/lib/R/library/lwgeom’
...
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning messages:
1: In install.packages(lib, dependencies = TRUE, repos = "https://cran.r-project.org") :
  installation of package ‘rgdal’ had non-zero exit status
2: In install.packages(lib, dependencies = TRUE, repos = "https://cran.r-project.org") :
  installation of package ‘units’ had non-zero exit status
3: In install.packages(lib, dependencies = TRUE, repos = "https://cran.r-project.org") :
  installation of package ‘gdalUtils’ had non-zero exit status
4: In install.packages(lib, dependencies = TRUE, repos = "https://cran.r-project.org") :
  installation of package ‘sf’ had non-zero exit status
5: In install.packages(lib, dependencies = TRUE, repos = "https://cran.r-project.org") :
  installation of package ‘leafem’ had non-zero exit status
6: In install.packages(lib, dependencies = TRUE, repos = "https://cran.r-project.org") :
  installation of package ‘leafpop’ had non-zero exit status
7: In install.packages(lib, dependencies = TRUE, repos = "https://cran.r-project.org") :
  installation of package ‘lwgeom’ had non-zero exit status
8: In install.packages(lib, dependencies = TRUE, repos = "https://cran.r-project.org") :
  installation of package ‘plainview’ had non-zero exit status
9: In install.packages(lib, dependencies = TRUE, repos = "https://cran.r-project.org") :
  installation of package ‘stars’ had non-zero exit status
10: In install.packages(lib, dependencies = TRUE, repos = "https://cran.r-project.org") :
  installation of package ‘mapview’ had non-zero exit status
Error: unexpected symbol in:
"    repos=c('https://xran.yihui.name', 'https://cran.r-project.org')
)t.org"
Execution halted
make: *** [install/R] Error 1

And a system-level package is misconfigured

configure: error: in `/private/var/folders/90/s52fr1h51nj4zx96yzqf44th0000gn/T/Rtmp1iNpp0/R.INSTALLc8cb5bcfa745/units':
configure: error:
--------------------------------------------------------------------------------
  Configuration failed because libudunits2.so was not found. Try installing:
    * deb: libudunits2-dev (Debian, Ubuntu, ...)
    * rpm: udunits2-devel (Fedora, EPEL, ...)
    * brew: udunits (OSX)
  If udunits2 is already installed in a non-standard location, use:
    --configure-args='--with-udunits2-lib=/usr/local/lib'
  if the library was not found, and/or:
    --configure-args='--with-udunits2-include=/usr/include/udunits2'
  if the header was not found, replacing paths with appropriate values.
  You can alternatively set UDUNITS2_INCLUDE and UDUNITS2_LIBS manually.
--------------------------------------------------------------------------------

See `config.log' for more details
ERROR: configuration failed for package ‘units’
* removing ‘/usr/local/Cellar/r/4.0.0/lib/R/library/units’

I can install udunits as recommended, but I'm not sure the best way to resolve the package availability issues.

# Add dependencies to this array
load.lib <- c(
"rmarkdown",
"RPostgreSQL",
"dotenv",
"ggmap",
"tidygeocoder",
"mapview",
"tidyverse"
)
install.lib <- load.lib[!load.lib %in% installed.packages()]
for (lib in install.lib)
install.packages(
lib,
dependencies=TRUE,
repos="https://cran.r-project.org"
)
# Install latest version of knitr from xran for SQL caching
install.packages(
'knitr',
repos=c('https://xran.yihui.name', 'https://cran.r-project.org')
)
# SOURCE: https://www.r-bloggers.com/2016/10/how-to-remove-all-user-installed-packages-in-r/
# create a list of all installed packages
ip <- as.data.frame(installed.packages())
head(ip)
# if you use MRO, make sure that no packages in this library will be removed
ip <- subset(ip, !grepl("MRO", ip$LibPath))
# we don't want to remove base or recommended packages either\
ip <- ip[!(ip[,"Priority"] %in% c("base", "recommended")),]
# determine the library where the packages are installed
path.lib <- unique(ip$LibPath)
# create a vector with all the names of the packages you want to remove
pkgs.to.remove <- ip[,1]
head(pkgs.to.remove)
# remove the packages
sapply(pkgs.to.remove, remove.packages, lib = path.lib)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment