Итак, я смог развернуть приложение Heroku, которое должно содержать мои RScripts: init.R
и access_heroku.R
Моя основная задача - проверить, как сохранить и получить доступ к базе данных на Heroku, чтобы запросить ее и составить несколько графиков (скорее всего, в будущем в ShinyApp).
Итак, я также нашел эту суть талантливым: @ hrbrmstr
https://gist.github.com/hrbrmstr/45c67103a9728f59212cd13262adca74
И это другое руководство по установке пакетов в Heroku с помощью сценария init.R
.
https://www.r -bloggers.com / погонный-ан-р-сценариев на Heroku /
init.R
my_packages <- c("processx","RPostgres","httr", "dbplyr", "tidyverse")
install_if_missing <- function(p) {
if(p %in% rownames(installed.packages())==FALSE){
install.packages(p)}
}
invisible(sapply(my_packages, install_if_missing))
К сожалению, при развертывании на heroku я получаю эту ошибку, говорящую, что libpq
не был найден и поэтому RPostgres
не может быть установлен.
Heroku-APP URL: https://blooming -waters-73325.herokuapp.com /
remote: * installing *source* package ‘RPostgres’ ...
remote: ** package ‘RPostgres’ successfully unpacked and MD5 sums checked
remote: Using PKG_CFLAGS=
remote: Using PKG_LIBS=-lpq
remote: ------------------------- ANTICONF ERROR ---------------------------
remote: Configuration failed because libpq was not found
Как вы можете видеть ниже, он дает вам инструкции по установке libpq
в разных системах. Я не знаю, в какой «системе» развернуто мое приложение heroku, поэтому я не знаю, какой вариант реализовать и как?
Должен ли я положить его в init.R
?
remote: -----> R Console app detected
remote: -----> Vendoring R 3.4.4 for heroku-16 stack (latest)
remote: Retrieving R binaries from cache
remote: -----> Executing R init script
remote: Installing package into ‘/usr/local/lib/R/site-library’
remote: (as ‘lib’ is unspecified)
remote: trying URL 'https://cloud.r-project.org/src/contrib/RPostgres_1.1.1.tar.gz'
remote: Content type 'application/x-gzip' length 44803 bytes (43 KB)
remote: ==================================================
remote: downloaded 43 KB
remote:
remote: * installing *source* package ‘RPostgres’ ...
remote: ** package ‘RPostgres’ successfully unpacked and MD5 sums checked
remote: Using PKG_CFLAGS=
remote: Using PKG_LIBS=-lpq
remote: ------------------------- ANTICONF ERROR ---------------------------
remote: Configuration failed because libpq was not found. Try installing:
remote: * deb: libpq-dev (Debian, Ubuntu, etc)
remote: * rpm: postgresql-devel (Fedora, EPEL)
remote: * rpm: postgreql8-devel, psstgresql92-devel, postgresql93-devel, or postgresql94-devel (Am
azon Linux)
remote: * csw: postgresql_dev (Solaris)
remote: * brew: libpq (OSX)
remote: If libpq is already installed, check that either:
remote: (i) 'pkg-config' is in your PATH AND PKG_CONFIG_PATH contains
remote: a libpq.pc file; or
remote: (ii) 'pg_config' is in your PATH.
remote: If neither can detect , you can set INCLUDE_DIR
remote: and LIB_DIR manually via:
remote: R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
remote: --------------------------------------------------------------------
remote: ERROR: configuration failed for package ‘RPostgres’
remote: * removing ‘/usr/local/lib/R/site-library/RPostgres’
remote:
remote: The downloaded source packages are in
remote: ‘/tmp/RtmpZjXuPF/downloaded_packages’
remote: Warning message:
remote: In install.packages(p) :
remote: installation of package ‘RPostgres’ had non-zero exit status
remote: R 3.4.4 successfully installed (with init)
В конце я хотел бы разместить набор данных радужной оболочки на Heroku и иметь возможность запросить его, чтобы показать некоторые графики. Мой сценарий только печатает его в конце, но это нормально, так как я знаю, как создавать графики с ggplot2
.
ОБНОВЛЕНИЕ 1:
Благодаря ответу Криса мне удалось установить libpq-dev
, но теперь я получаю эту ошибку:
remote: Processing triggers for libc-bin (2.23-0ubuntu10) ...
remote: Processing triggers for man-db (2.7.5-1) ...
remote: /usr/bin/mandb: error while loading shared libraries: libmandb-2.7.5.so: cannot open shared
Итак, основываясь на ответе Криса, я поставил libman
на Aptfile
, но теперь я получаю:
remote: -----> Installing binary dependencies from Aptfile
remote: Reading package lists...
remote: Building dependency tree...
remote: Reading state information...
remote: E: Unable to locate package libmandb-2.7.5
remote: E: Couldn't find any package by glob 'libmandb-2.7.5'
remote: E: Couldn't find any package by regex 'libmandb-2.7.5'
remote: -----> Executing R init script
Что я могу сделать?
Enumerating objects: 7, done.
Counting objects: 100% (7/7), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 371 bytes | 123.00 KiB/s, done.
Total 4 (delta 1), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> R Console app detected
remote: -----> Vendoring R 3.4.4 for heroku-16 stack (latest)
remote: Retrieving R binaries from cache
remote: -----> Installing binary dependencies from Aptfile
remote: Reading package lists...
remote: Building dependency tree...
remote: Reading state information...
remote: E: Unable to locate package libmandb-2.7.5
remote: E: Couldn't find any package by glob 'libmandb-2.7.5'
remote: E: Couldn't find any package by regex 'libmandb-2.7.5'
remote: -----> Executing R init script
remote: R 3.4.4 successfully installed (with init)
remote: -----> Caching build outputs
remote: Build took 68 seconds to complete
remote: -----> Discovering process types
remote: Procfile declares types -> (none)
remote: Default types for buildpack -> console
remote:
remote: -----> Compressing...
remote: Done: 311.2M
remote: -----> Launching...
remote: ! Warning: Your slug size exceeds our soft limit (311 MB) which may affect boot time.
remote: Released v9
remote: https://blooming-waters-73325.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/blooming-waters-73325.git
79635e7..4fcab2b master -> master