Giter Club home page Giter Club logo

heroku-buildpack-r's Introduction

Heroku Buildpack: R

CI

This is a Heroku Buildpack for applications which use R for statistical computing and CRAN for R packages.

The buildpack supports the heroku-181, heroku-202 and heroku-223 stacks.

It also includes support for the Packrat and renv package managers, and the Shiny and Plumber web application frameworks.

Usage

The buildpack's name is vsv/heroku-buildpack-r. Provide it when creating your application on Heroku as follows:

heroku create --buildpack vsv/heroku-buildpack-r

You can add it to an existing application using the buildpacks:add command, as follows:

heroku buildpacks:add vsv/heroku-buildpack-r

Alternatively, you can use the Git URL of this repository, together with the branch name.

https://github.com/virtualstaticvoid/heroku-buildpack-r.git#main

The buildpack will detect your application makes use of R if it has one (or more) of the following files in the project directory:

  • init.R
  • packrat/init/R
  • renv/activate.R
  • run.R
  • app.R
  • plumber.R

If the init.R file is provided, it will be executed in order to install any R packages, and if packrat/init.R or renv/activate.R files are found, the respective package manager will be bootstrapped and packages installed.

Additionally:

  • If the run.R file is provided, the buildpack will be configured as a Shiny application.
  • If the plumber.R file is provided, the buildpack will be configured as a Plumber application.

See the detect script for the matching logic used.

Installing R Packages

The init.R file is used to install R packages as required.

NOTE: Using either Packrat or renv are a better way to manage your package dependencies and their respective versions, so the init.R file isn't required if you use packrat or renv.

The following example init.R file can be used. Provide the package names you want to install to the my_packages list variable:

# init.R
#
# Example R code to install packages if not already installed
#

my_packages = c("package_name_1", "package_name_2", ...)

install_if_missing = function(p) {
  if (p %in% rownames(installed.packages()) == FALSE) {
    install.packages(p, clean=TRUE, quiet=TRUE)
  }
}

invisible(sapply(my_packages, install_if_missing))

R packages can also be installed by providing a .tar.gz package archive file, if a specific version is required, or it is not a publicly published package. See local-packages for an example.

# init.R
#
# Example R program to installed package from local path
#

install.packages("PackageName-Version.tar.gz", repos=NULL, type="source")

NOTE: The path to the package archive should be a relative path to the project root directory, so that it works locally in development and during deployment on Heroku.

R Package Installation Helper

For convenience, a R helper function, helpers.installPackages, is included by the buildpack to make installing packages easier.

Thus the init.R file can be reduced to a single line of R code as shown. Provide the package names you want to install as arguments to the helper:

helpers.installPackages("package_name_1", "package_name_2", ...)

Installing Binary Dependencies

This version of the buildpack still supports the use of an Aptfile for installing additional system packages, however this functionality is going to be deprecated in future as it isn't a foolproof solution.

It is based on the same technique as used by the heroku-buildpack-apt buildpack to install Ubuntu packages using apt-get.

There are various technical and security reasons why it is no longer recommended, so your mileage may vary.

If any of your R packages dependend on system libraries which aren't included by Heroku, such as libgmp, libgomp, libgdal, libgeos and libgsl, you should use the Heroku container stack together with heroku-docker-r instead.

R Applications

Heroku Console

You can run the R console application as follows:

$ heroku run R ...

Type q() to exit the console when you are finished.

You can also run the Rscript utility as follows:

$ heroku run Rscript ...

Note that the Heroku slug is read-only, so any changes you make during the session will be lost.

Shiny Applications

Shiny applications must provide a run.R file, and can also include an init.R in order to install additional R packages. The Shiny package does not need to be installed, as it is included in the buildpack already.

The run.R file should contain at least the following code, in order to run the web application.

Notice the use of the PORT environment variable, provided by Heroku, which is used to configure Shiny and the host must be 0.0.0.0.

# run.R
library(shiny)

port <- Sys.getenv('PORT')

shiny::runApp(
  appDir = getwd(),
  host = '0.0.0.0',
  port = as.numeric(port)
)

See the virtualstaticvoid/heroku-shiny-app example application.

Plumber Applications

Plumber applications must provide an app.R file, but can also include an init.R in order to install additional R packages. The Plumber package does not need to be installed, as it is included in the buildpack already.

The app.R file should contain at least the following code, in order to run the web application.

Notice the use of the PORT environment variable, provided by Heroku, which is used to configure Shiny and the host must be 0.0.0.0.

# app.R
library(plumber)

port <- Sys.getenv('PORT')

server <- plumb("plumber.R")

server$run(
  host = '0.0.0.0',
  port = as.numeric(port)
)

See the virtualstaticvoid/heroku-plumber-app example application.

Recurring Jobs

You can use the Heroku scheduler to schedule a recurring R process.

An example command for the scheduler to run prog.R, would be R --file=prog.R --gui-none --no-save.

Technical Details

R Versions

The default R version can be overridden by setting the R_VERSION environment variable.

heroku config:set R_VERSION=4.0.0

The following table lists the available combinations of Heroku Stack and R version. They are built periodically as and when the Debian R packages are available.

R / Stack 18 20 22
3.6.3
4.0.0
4.0.5
4.1.2
4.1.3 -
4.2.0 -
4.2.1

Legend:

  • = default version for given stack
  • = available
  • - = no package available

Slug Compilation vs Runtime use of chroot

This version of the buildpack still uses a fakechroot during slug compilation, to compile R packages which may include C or Fortran code. However it no longer uses the chroot at runtime so it can work better in scenarios where other language buildpacks are used, such as with Python, Ruby or Java, and so that the slug size is greatly reduced.

If you are migrating to this version of the buildpack, you no longer need to prefix commands to use fakechroot, fakeroot or chroot. Wrappers of these commands are included and they will output warning messages to alert you of their use.

Buildpack Binaries

The binaries used by the buildpack are hosted on AWS S3 at https://heroku-buildpack-r.s3.amazonaws.com.

See the heroku-buildpack-r-build2 repository for building the buildpack binaries yourself.

Process Types

The buildpack includes the following default process types:

  • console: Executes the R terminal application, which is typically used for debugging.
  • web: Executes run.R to run Shiny or Plumber applications.

The R and Rscript executables are available like any other executable, via the heroku run command.

Procfile

You can include a Procfile in your project if you want to override the default process types and/or their command lines. This is typically required if you are using multiple buildpacks.

For example, the following Profile defines the commands for the web and console processes.

web: R --file=myprogram.R --gui-none --no-save
console: R --no-save

heroku.yml

You can include the heroku.yml build manifest in you project if you want to override the default process types and/or their command lines, within the run section. This is typically required if you are using multiple buildpacks.

For example, the following heroku.yml file defines the commands for the web and console processes.

run:
  web: R --file=myprogram.R --gui-none --no-save
  console: R --no-save

Paths

Where possible, always use relative paths for files, so that your application is more portable; so that it can run locally in development and at runtime on Heroku without any differences.

The current directory on Heroku will always be /app and your application will be installed to this directory, so relative paths should be in respect of the root directory of your project.

If you need to use absolute paths, consider using getwd() together with file.path() to build up the path instead of hardcoding them.

.Rprofile

You can include an .Rprofile in your application's root directory and it will be executed at the start of any R process.

It can be used as a convenient way to bootstrap your application, sourcing common utilities or performing configuration tasks.

Please do not use it to install R packages, since it may cause problems during deployment (slug compilation) and will fail at runtime.

CRAN Mirror Override

It is possible to override the default CRAN mirror used, by providing the URL via the CRAN_MIRROR environment variable.

E.g. Override the URL by setting the variable as follows.

heroku config:set CRAN_MIRROR=https://cloud.r-project.org/

Check the CRAN mirror status page to ensure the mirror is available.

Caching

To improve the time it takes to deploy the buildpack caches the R binaries and installed R packages.

If you need to purge the cache, it is possible by using heroku-repo CLI plugin via the heroku repo:purge_cache command.

See the purge-cache documentation for more information.

Build Output Verbosity

In previous versions of the buildpack, the full output of install.packages() was emitted during slug compilation, which lead to very verbose output and made it hard to spot issues in some instances. Packages are now installed with quiet=TRUE option set by default.

To restore the previous behaviour, set the PACKAGE_INSTALL_VERBOSE environment variable to a value of 1 before deploying your application:

heroku config:set PACKAGE_INSTALL_VERBOSE=1

To revert the setting use the config:unset command:

heroku config:unset PACKAGE_INSTALL_VERBOSE

Hacking

To enable debug outputs during deployment, set the BUILDPACK_DEBUG environment variable.

heroku config:set BUILDPACK_DEBUG=1

Credits

License

MIT License. Copyright (c) 2020 Chris Stefano. See LICENSE for details.

Footnotes

  1. The Heroku-18 stack is deprecated and will reach end-of-life on April 30th, 2023.

  2. Heroku-20 is based on Ubuntu 20.04. It will be supported through April 2025.

  3. Heroku-22 is based on Ubuntu 22.04. It will be supported through April 2027.

heroku-buildpack-r's People

Contributors

btubbs avatar craigschmidt avatar virtualstaticvoid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

heroku-buildpack-r's Issues

Error installing packages

I'm trying to install new packages using the examples provided, but I'm unable to install basic packages such as expm. Am I missing something? Using cedar-14 and the instructions in install.sh

I've cloned and changed the ruby test to demonstrate the bug, see if you can replicate it using the install.sh.

https://github.com/tbondwilkinson/heroku-buildpack-r/tree/master/test/ruby

The error is:

installing source package ‘expm’ ...
remote: ** package ‘expm’ successfully unpacked and MD5 sums checked
remote: ** libs
remote: In file included from locale.h:4:0,
remote: from expm.h:10,
remote: from R_dgebal.c:4:
remote: R_dgebal.c: In function ‘ebal_type’:
remote: locale.h:5:19: error: ‘LC_MESSAGES’ undeclared (first use in this function)
remote: #define (String) dgettext ("expm", String)
remote: ^
remote: R_dgebal.c:11:8: note: in expansion of macro ‘

remote: error(("argument type='%s' must be a character string of string length 1"),
remote: ^
remote: locale.h:5:19: note: each undeclared identifier is reported only once for each function it appears in
remote: #define (String) dgettext ("expm", String)
remote: ^
remote: R_dgebal.c:11:8: note: in expansion of macro ‘

remote: error(
("argument type='%s' must be a character string of string length 1"),
remote: ^
remote: R_dgebal.c: In function ‘R_dgebal’:
remote: locale.h:5:19: error: ‘LC_MESSAGES’ undeclared (first use in this function)
remote: #define (String) dgettext ("expm", String)
remote: ^
remote: R_dgebal.c:28:8: note: in expansion of macro ‘

remote: error(_("invalid 'x': not a numeric (classical R) matrix"));
remote: ^
remote: make: *** [R_dgebal.o] Error 1
remote: ERROR: compilation failed for package ‘expm’
remote: * removing ‘/app/vendor/R/lib/R/library/expm’

R with png support

Thanks again for this buildpack. I have it deployed to Heroku as a multipack with node.js, running Rserve through the rio node module.

I have a big favor to ask - I need to add png support, to save graphics generated on Heroku. I believe I have the same problem as this StackOverflow:

http://stackoverflow.com/questions/16619746/r-with-png-support

Would you consider creating a build with png support or point me to instructions on how to do it? I'm not very expert so I'm a bit daunted by the challenge of doing that, but it's a showstopper for me.

I get

Error in png("test") : X11 is not available

Reinstalls libraries during each deployment

I am trying to use R on Heroku and your buildpack has been helpful so far. However, as I start to increase the number of libraries and then each time I deploy, all the libraries are re-installed from scratch. Is there a way to build libraries on top of a previous successful build?

Error R11 (Bad bind)

The ruby test app works for me locally, but I get a port error when I try it on Heroku.

2012-08-15T17:14:58+00:00 heroku[web.1]: Starting process with command bundle exec thin -R config.ru start -p 27544 -e production
2012-08-15T17:15:05+00:00 heroku[web.1]: Stopping process with SIGKILL
2012-08-15T17:15:05+00:00 heroku[web.1]: Error R11 (Bad bind) -> Process bound to port 38520, should be 27544 (see environment variable PORT)

This would be a huge lifesaver if it works, since I have Rails and R on separate Heroku servers and pass information via HTTP between the two, which is big pain. Any ideas?

Shiny install fails

I recently started getting an error when trying to install the Shiny package as part of my build (it had been working ok before). It seems to be a problem with the httpuv dependency. Any ideas?

message log with error

Slug size too large after more than one deployment

Since Friday morning July 8, I've been getting slug too large errors if I deploy more than once after running 'heroku repo:purge_cache'. My slug size doubles from just over 200MB to well over 400MB. I think the recently merged change to re-enable the build cache is causing the slug to be too large. I suspect this line in compile may be at fault:

cp -R $CACHE_DIR/* $BUILD_DIR

I am still debugging it, but for now I have gone back to an earlier version before July 8 to work around this problem.

tcl/tk Not supported

Unable to use tcltk, as capabilities shows it isn't available.

> capabilities()
       jpeg         png        tiff       tcltk         X11        aqua 
       TRUE        TRUE        TRUE       FALSE       FALSE       FALSE 
   http/ftp     sockets      libxml        fifo      cledit       iconv 
       TRUE        TRUE        TRUE        TRUE       FALSE        TRUE 
        NLS     profmem       cairo         ICU long.double     libcurl 
       TRUE        TRUE        TRUE       FALSE        TRUE        TRUE 

Not caching downloads between deploys

Each time I push to Heroku, I see lots of downloads from cran. For example:

trying URL 'http://cran.revolutionanalytics.com/src/contrib/survival_2.37-7.tar.gz'
Content type 'application/x-gzip' length 4132583 bytes (3.9 Mb)
opened URL
==================================================
downloaded 3.9 Mb

trying URL 'http://cran.revolutionanalytics.com/src/contrib/Formula_1.1-1.tar.gz'
Content type 'application/x-gzip' length 148430 bytes (144 Kb)
opened URL
==================================================
downloaded 144 Kb

This has at least 2 major problems:

  • My deployments are dependent on external services that I can't control
  • Each deploy takes a long time

Reading the Heroku buildpack docs it seems that there is a CACHE_DIR that you can use to persist these downloads between builds:

bin/compile BUILD_DIR CACHE_DIR

The contents of CACHE_DIR will be persisted between builds. You can cache the results of long processes like dependency resolution here to speed up future builds.

Looking at the heroku-buildpack-r code, it seems that the code used to utilize this directory, but it has since been deleted:

643029f

Can someone help me understand the reasoning for this? Was this intentionally removed from the project? If so, why?

Just checking before I spend a bunch of time on this.

Unzip in R build

I am using devtools and install_github to bring rCharts online, but failing on Heroku; install_github expects to unzip things, and Heroku does not carry unzip by default. Could unzip be added to the binary build? I can fork and tweak for now, but this might be useful for others as well. Many thanks for such an awesome buildpack!

Adding graphics support

Wondering if anyone has reliable steps for compiling R on Heroku with support for PNG, SVG, JPG? I've re-built the R binaries but no luck. When running capabilities I get the below.

2013-03-02_1845

How do you use RServe authentication with this buildpack?

I.e. where/how do you set up the authentication information?

EDIT: Can you also provide README instructions on how exactly I would connect to this RServe instance via a Ruby Rserve client instance on my local machine? I've tried:

@con = Rserve::Connection.new auth_req: true, hostname: 'my-app.herokuapp.com', port_number: 80

@con = Rserve::Connection.new auth_req: true, hostname: ''my-app.herokuapp.com

And neither are working.

R version 3.1.2

What are the steps to get R version 3.1.2 working with this buildpack?

I'm currently using this buildpack with R version 3.1.0 on Heroku cedar and would like to upgrade it to R version 3.1.2.

Thank you.

'Ruby' test app fails when initializing rinruby.

I am trying to run the example app 'ruby' but I get an error (log below) when ruby tries to load rinruby. Specifically, there seems to be a problem with rinruby initializing R. This issue suggests that it may be the R path, but I don't think so because if I run the 'console' app, it works perfectly and both apps have the same R_PATH and R_INCLUDE variables.

This is my first venture into heroku, so I may be missing something simple. Thank you for your buildpack and your help.

2013-08-21T15:45:55.162388+00:00 heroku[api]: Enable Logplex by [email protected]
2013-08-21T15:45:55.206356+00:00 heroku[api]: Release v3 created by [email protected]
2013-08-21T15:46:00+00:00 heroku[slug-compiler]: Slug compilation started
2013-08-21T15:47:53.991277+00:00 heroku[api]: Scale to web=1 by [email protected]
2013-08-21T15:47:54.031405+00:00 heroku[api]: Deploy 2268626 by [email protected]
2013-08-21T15:47:54.068299+00:00 heroku[api]: Release v4 created by [email protected]
2013-08-21T15:47:54+00:00 heroku[slug-compiler]: Slug compilation finished
2013-08-21T15:47:56.199746+00:00 heroku[api]: Add PATH, R_HOME, R_INCLUDE config by [email protected]
2013-08-21T15:47:56.226111+00:00 heroku[api]: Release v5 created by [email protected]
2013-08-21T15:48:03.950759+00:00 heroku[web.1]: Starting process with command `bundle exec thin start -R config.ru -e $RACK_ENV -p 44576`
2013-08-21T15:48:06.728604+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/rinruby-2.0.3/lib/rinruby.rb:164:in `initialize'
2013-08-21T15:48:06.728604+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/rinruby-2.0.3/lib/rinruby.rb:789:in `new'
2013-08-21T15:48:06.728604+00:00 app[web.1]:    from /app/application.rb:2:in `require'
2013-08-21T15:48:06.728604+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rinruby-2.0.3/lib/rinruby.rb:164:in `popen': No such file or directory - R --interactive --slave (Errno::ENOENT)
2013-08-21T15:48:06.728604+00:00 app[web.1]:    from /app/application.rb:2:in `<top (required)>'
2013-08-21T15:48:06.728604+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
2013-08-21T15:48:06.728604+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/rinruby-2.0.3/lib/rinruby.rb:789:in `<top (required)>'
2013-08-21T15:48:06.728604+00:00 app[web.1]:    from config.ru:1:in `require'
2013-08-21T15:48:06.728604+00:00 app[web.1]:    from config.ru:1:in `block in <main>'
2013-08-21T15:48:06.728604+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
2013-08-21T15:48:06.728817+00:00 app[web.1]:    from config.ru:1:in `<main>'
2013-08-21T15:48:06.728817+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/thin/controllers/controller.rb:181:in `load_rackup_config'
2013-08-21T15:48:06.728817+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/thin/controllers/controller.rb:71:in `start'
2013-08-21T15:48:06.728817+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/thin/runner.rb:185:in `run_command'
2013-08-21T15:48:06.728817+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/thin/runner.rb:151:in `run!'
2013-08-21T15:48:06.728817+00:00 app[web.1]:    from config.ru:1:in `new'
2013-08-21T15:48:06.728817+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/rack/adapter/loader.rb:33:in `load'
2013-08-21T15:48:06.728817+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/rack/adapter/loader.rb:33:in `eval'
2013-08-21T15:48:06.728817+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/bin/thin:6:in `<top (required)>'
2013-08-21T15:48:06.728817+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/bin/thin:23:in `load'
2013-08-21T15:48:06.728974+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/bin/thin:23:in `<main>'
2013-08-21T15:48:07.922322+00:00 heroku[web.1]: Process exited with status 1
2013-08-21T15:48:07.937457+00:00 heroku[web.1]: State changed from starting to crashed
2013-08-21T15:48:07.938202+00:00 heroku[web.1]: State changed from crashed to starting
2013-08-21T15:48:08.268998+00:00 heroku[web.1]: Starting process with command `bundle exec thin start -R config.ru -e $RACK_ENV -p 15839`
2013-08-21T15:48:11.053014+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/rinruby-2.0.3/lib/rinruby.rb:164:in `initialize'
2013-08-21T15:48:11.053014+00:00 app[web.1]:    from /app/application.rb:2:in `require'
2013-08-21T15:48:11.053014+00:00 app[web.1]:    from config.ru:1:in `block in <main>'
2013-08-21T15:48:11.053465+00:00 app[web.1]:    from config.ru:1:in `<main>'
2013-08-21T15:48:11.053465+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/thin/runner.rb:185:in `run_command'
2013-08-21T15:48:11.053465+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/bin/thin:23:in `load'
2013-08-21T15:48:11.053014+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rinruby-2.0.3/lib/rinruby.rb:164:in `popen': No such file or directory - R --interactive --slave (Errno::ENOENT)
2013-08-21T15:48:11.053014+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/rinruby-2.0.3/lib/rinruby.rb:789:in `new'
2013-08-21T15:48:11.053014+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/rinruby-2.0.3/lib/rinruby.rb:789:in `<top (required)>'
2013-08-21T15:48:11.053014+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
2013-08-21T15:48:11.053465+00:00 app[web.1]:    from config.ru:1:in `new'
2013-08-21T15:48:11.053465+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/rack/adapter/loader.rb:33:in `eval'
2013-08-21T15:48:11.053465+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/rack/adapter/loader.rb:33:in `load'
2013-08-21T15:48:11.053014+00:00 app[web.1]:    from config.ru:1:in `require'
2013-08-21T15:48:11.053014+00:00 app[web.1]:    from /app/application.rb:2:in `<top (required)>'
2013-08-21T15:48:11.053465+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/thin/controllers/controller.rb:71:in `start'
2013-08-21T15:48:11.053465+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/thin/runner.rb:151:in `run!'
2013-08-21T15:48:11.053465+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/bin/thin:6:in `<top (required)>'
2013-08-21T15:48:11.053014+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
2013-08-21T15:48:11.053465+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/thin/controllers/controller.rb:181:in `load_rackup_config'
2013-08-21T15:48:11.053770+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/bin/thin:23:in `<main>'
2013-08-21T15:48:12.879349+00:00 heroku[web.1]: Process exited with status 1
2013-08-21T15:48:14.371806+00:00 heroku[web.1]: Starting process with command `bundle exec thin start -R config.ru -e $RACK_ENV -p 19001`
2013-08-21T15:48:16.860500+00:00 app[web.1]:    from config.ru:1:in `require'
2013-08-21T15:48:16.860500+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/rinruby-2.0.3/lib/rinruby.rb:789:in `new'
2013-08-21T15:48:16.860500+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/rinruby-2.0.3/lib/rinruby.rb:789:in `<top (required)>'
2013-08-21T15:48:16.860500+00:00 app[web.1]:    from /app/application.rb:2:in `require'
2013-08-21T15:48:16.860691+00:00 app[web.1]:    from config.ru:1:in `new'
2013-08-21T15:48:16.860500+00:00 app[web.1]:    from config.ru:1:in `block in <main>'
2013-08-21T15:48:16.860500+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rinruby-2.0.3/lib/rinruby.rb:164:in `popen': No such file or directory - R --interactive --slave (Errno::ENOENT)
2013-08-21T15:48:16.860691+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/rack/adapter/loader.rb:33:in `eval'
2013-08-21T15:48:16.860691+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/thin/controllers/controller.rb:71:in `start'
2013-08-21T15:48:16.860500+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
2013-08-21T15:48:16.860500+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/rinruby-2.0.3/lib/rinruby.rb:164:in `initialize'
2013-08-21T15:48:16.860691+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/rack/adapter/loader.rb:33:in `load'
2013-08-21T15:48:16.860500+00:00 app[web.1]:    from /app/application.rb:2:in `<top (required)>'
2013-08-21T15:48:16.860500+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
2013-08-21T15:48:16.860691+00:00 app[web.1]:    from config.ru:1:in `<main>'
2013-08-21T15:48:16.860691+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/thin/controllers/controller.rb:181:in `load_rackup_config'
2013-08-21T15:48:16.860691+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/thin/runner.rb:185:in `run_command'
2013-08-21T15:48:16.860841+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/bin/thin:23:in `<main>'
2013-08-21T15:48:16.860691+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/thin/runner.rb:151:in `run!'
2013-08-21T15:48:16.860691+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/bin/thin:6:in `<top (required)>'
2013-08-21T15:48:16.860691+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/bin/thin:23:in `load'
2013-08-21T15:48:19.153863+00:00 heroku[web.1]: Process exited with status 1
2013-08-21T15:48:19.163578+00:00 heroku[web.1]: State changed from starting to crashed

R command not found

Hello, followed the instructions, pushed to Heroku and saw this (full output below):

     R 2.15.1 successfully installed

All well and good, except:

$ heroku run R
Running `R` attached to terminal... up, run.1017
bash: R: command not found

I'm on the cedar stack-

$ heroku stack
=== mcgill-steam Available Stacks
   bamboo-mri-1.9.2
   bamboo-ree-1.8.7
 * cedar

I'm using both ruby and R buildpacks:

$ heroku config
BUILDPACK_URL:  https://github.com/ddollar/heroku-buildpack-multi.git

And .buildpacks

https://github.com/virtualstaticvoid/heroku-buildpack-r.git
https://github.com/heroku/heroku-buildpack-ruby.git

Any suggestions would be much appreciated. I'm a ruby developer and this is my first time ever hearing about R so I'm not sure how to troubleshoot!


Full output from heroku push (right before ruby buildpack installation).

-----> Fetching custom git buildpack... done
-----> Multipack app detected
=====> Downloading Buildpack: https://github.com/virtualstaticvoid/heroku-buildpack-r.git
=====> Detected Framework: R
       Vendoring R 2.15.1
       Downloading and unpacking R binaries
       Executing init.r script
trying URL 'http://cran.fhcrc.org/src/contrib/e1071_1.6-1.tar.gz'
Content type 'application/x-gzip' length 258910 bytes (252 Kb)
opened URL
==================================================
downloaded 252 Kb

* installing *source* package 'e1071' ...
** package 'e1071' successfully unpacked and MD5 sums checked
** libs
installing to /app/vendor/R/lib64/R/library/e1071/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded

* DONE (e1071)
Updating HTML index of packages in '.Library'
Making packages.html  ... done
trying URL 'http://cran.fhcrc.org/src/contrib/rpart_4.1-1.tar.gz'
Content type 'application/x-gzip' length 813735 bytes (794 Kb)
opened URL
==================================================
downloaded 794 Kb

* installing *source* package 'rpart' ...
** package 'rpart' successfully unpacked and MD5 sums checked
** libs
installing to /app/vendor/R/lib64/R/library/rpart/libs
** R
** data
**  moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded

* DONE (rpart)
Updating HTML index of packages in '.Library'
Making packages.html  ... done
       R 2.15.1 successfully installed
=====> Downloading Buildpack: https://github.com/heroku/heroku-buildpack-ruby.git
=====> Detected Framework: Ruby/Rack
-----> Using Ruby version: ruby-1.9.3
...

httpuv not installed

Warning messages:
1: In install.packages(p, dependencies = TRUE):
installation of package 'httpuv' had non-zero exit status

Support for multiple versions of R

Enhance the build pack so that it is possible to specify the R version to use.

This could be implemented by including a simple text configuration file with the application (in addition the the init.r file) which contains the R version to use.

If no configuration file is specified, it should fallback to the currently implemented version R 2.15.1.

RJSONIO installation

I am trying to install RJSONIO via init.r on buildpack deployment, but hitting a function declaration error. This same error was mentioned in issue #13 by metalaureate (#issuecomment-21731462) and was addressed by the updated buildpack, but forcible vendoring of the new buildpack does not resolve this issue on my end.

Either of these two lines in init.r will attempt the install and provoke the error:
install.packages("gridSVG",repos='http://cran.rstudio.com/') #RJSONIO dependency
install.packages("RJSONIO", repos = "http://www.omegahat.org/R", type = "source")

Error:

  • installing source package 'RJSONIO' ...
    ** package 'RJSONIO' successfully unpacked and MD5 sums checked
    * libs
    In file included from libjson/Source/JSONAllocator.h:4,
    from JSONAllocator.cpp:1:
    libjson/Source/../JSONOptions.h:120:1: warning: "JSON_STREAM" redefined
    : warning: this is the location of the previous definition
    libjson/Source/../JSONOptions.h:256:1: warning: "JSON_VALIDATE" redefined
    : warning: this is the location of the previous definition
    In file included from libjson/Source/JSONMemory.h:6,
    from libjson/Source/JSONChildren.h:6,
    from JSONChildren.cpp:1:
    libjson/Source/../JSONOptions.h:120:1: warning: "JSON_STREAM" redefined
    : warning: this is the location of the previous definition
    libjson/Source/../JSONOptions.h:256:1: warning: "JSON_VALIDATE" redefined
    : warning: this is the location of the previous definition
    In file included from /usr/include/stdio.h:907,
    from /app/vendor/gcc-4.3/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.3.6/../../../../include/c++/4.3.6/cstdio:50,
    from /app/vendor/gcc-4.3/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.3.6/../../../../include/c++/4.3.6/bits/char_traits.h:48,
    from /app/vendor/gcc-4.3/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.3.6/../../../../include/c++/4.3.6/string:47,
    from libjson/Source/JSONDefs/Strings_Defs.h:25,
    from libjson/Source/JSONDefs.h:14,
    from libjson/Source/JSONDebug.h:4,
    from libjson/Source/JSONMemory.h:7,
    from libjson/Source/JSONChildren.h:6,
    from JSONChildren.cpp:1:
    /usr/include/bits/stdio.h: In function '__ssize_t getline(char
    , size_t, FILE_)':
    /usr/include/bits/stdio.h:118: error: '__getdelim' was not declared in this scope
    make: *_* [JSONChildren.o] Error 1
    ERROR: compilation failed for package 'RJSONIO'

This is probably an issue on my end, but I do not know what it could be; I am bad with low-level C stuff. Any thoughts?

Init.r reinstall packages on every deploy

I have used the buildpack to deploy an R script to heroku.

Everytime I deploy the project the init.r reinstall the packages although the code checks for installed packages.

If I run init.r directly on the dyno then script executed properly.
Any ideas why this happen?

Failed to download R-3.2.1-binaries-20150719-0045.tar.gz for cedar

Hello @virtualstaticvoid,

I've been running the same Buildpack code for a while and starting on Sunday, July 26 our builds started failing with the following error:

remote: =====> Downloading Buildpack: https://github.com/virtualstaticvoid/heroku-buildpack-r.git
remote: =====> Detected Framework: R
remote:        Vendoring R 3.2.1 for cedar stack (20150719-0045)
remote:        Downloading and unpacking R binaries (http://heroku-buildpack-r.s3.amazonaws.com/cedar/R-3.2.1-binaries-20150719-0045.tar.gz)
remote: 
remote: gzip: stdin: not in gzip format
remote: tar: Child returned status 1
remote: tar: Exiting with failure status due to previous errors
remote: 
remote:  !     Push rejected, failed to compile Multipack app
remote: 
remote: Verifying deploy....
remote: 
remote: !   Push rejected to rocky-temple-9308.
remote: 

When I try to download http://heroku-buildpack-r.s3.amazonaws.com/cedar/R-3.2.1-binaries-20150719-0045.tar.gz it doesn't exist so this is obviously the problem. It appears that you've upgraded to R v3.2.1 and and this no longer works when using the older R v3.1.2.

Error while loading shared libraries: libreadline.so.5 - Multiple Buildpacks

Carried over from comments in #39

remote: =====> Downloading Buildpack: http://github.com/virtualstaticvoid/heroku-buildpack-r.git
remote: =====> Detected Framework: R
remote:        Vendoring R 3.2.2 for cedar-14 stack (20151031-1711)
remote:        Downloading and unpacking R binaries (http://heroku-buildpack-r.s3.amazonaws.com/cedar-14/R-3.2.2-binaries-20151031-1711.tar.gz)
remote:        Executing init.r script
remote: /app/vendor/R/lib64/R/bin/exec/R: error while loading shared libraries: libreadline.so.5: cannot open shared object file: No such file or directory
remote: 
remote:  !     Push rejected, failed to compile Multipack app
remote: 
remote: Verifying dep

From @csatisfaction comments:

I am using multiple buildpacks. The conflict seems to be with heroku's own buildpack: heroku-buildpack-ruby. It was ordered before the buildpack-r and causing the error whilst pushing to heroku.

(Note: this has been working fine for over a year on the old cedar-10)

If I change the buildpack order so that builpack-r comes before buildpack-ruby then I can now successfully deploy to heroku. However... I then encounter the same error when running the app. From the logs:

/app/vendor/R/lib64/R/bin/exec/R: error while loading shared libraries: libreadline.so.5: cannot open shared object file: No such file or directory 

The LIBRARY_PATH on heroku is:

/app/vendor/.apt/usr/lib/x86_64-linux-gnu:/app/vendor/.apt/usr/lib/i386-linux-gnu:/app/vendor/.apt/usr/lib:

Reduce slug size

There are several files/directories that are included in the R binaries and in the compiled packages that could be removed and thus reduce the total slug size of applications using this build-pack.

A quick inventory of such files, include sample programs, R database files, PDF documents, man pages and other such help files in various formats.

The "removal" logic would be used by the R binaries compilation script and during application deployment when additional packages (user-defined) are compiled to be included in the slug.

Installing dependent packages fails

When I add to init.r

install.packages(c("plyr"), repos="http://cran.r-project.org", dependencies=TRUE)

It appears to install, when I look in the library directory it isn't installed.

.libPaths()
[1] "/app/vendor/R/lib64/R/library"
library(plyr)
Error in library(plyr) : there is no package called 'plyr'

buildpack & Shiny?

Do we know if an R 'Shiny' application is able to be deployed by Heroku using this buildpack? I haven't been able to get it to work.

R packages not available

Hi,

Everything was working but suddenly in my last deploy the package 'tm' is not installing anymore:

Warning message:
package 'tm' is not available (for R version 2.15.1)

How to solve this? Is it possible to use a more recent version of R?
I've checked the how to install an older version of the package but it requires to manually download the file, so I don't think it is possible to do it with Heroku.

Thanks,
Luis

gfortran: fatal error while installing glmnet

I would like to use glmnet and other libraries which using fortran library (CBLAS)

I tried to install glmnet like

install.package("glmnet")

in init.r

however, it could not installed.

I received following error message.

remote: gfortran: fatal error: -fuse-linker-plugin, but liblto_plugin.so not found
remote: compilation terminated.

It seems the buildpack does not use dyno's but liblto_plugin.so.

Would you be kindly to update the binary package to include the library?

Pandoc version update for rmarkdown

I am using the buildpack version from issue #51 , and it is installing pandoc as expected, however the version is 1.12.2.1, and when the application runs rmarkdown::render(), it errors out with:
Error: pandoc version 1.12.3 or higher is required and was not found.

I am uncertain on how to update pandoc, any suggestions?

Compilation failed for gmp package

Hi, I'm trying to install the gmp package but it says

Rgmp.h:9:17: fatal error: gmp.h: No such file or directory
 #include <gmp.h>
                 ^
compilation terminated.
make: *** [apply.o] Error 1
ERROR: compilation failed for package ‘gmp’
* removing ‘/app/vendor/R/lib/R/library/gmp’
ERROR: dependency ‘gmp’ is not available for package ‘Rmpfr’
* removing ‘/app/vendor/R/lib/R/library/Rmpfr’

I know I need to install libmpfr-dev and libgmp-dev, and for that I'm using heroku/heroku-buildpack-multi

In the Heroku's build output sais that the apt packages were installed, but then when the buildpack-r tries to compile, it keeps complaining.

Also, when heroku finishes, if I run a heroky run bash command I cannot find anything about libgmp in the vendor/.apt folder.

Any idea what could be the problem???

thanks

Fatal error: you must specify '--save', '--no-save' or '--vanilla'

,

I'm running my deploying my rails app with Heroku, which uses Rserve with the gem rserve-client.
Whenever my app creates a connection using Rserve-client it crashes giving the following message:

2014-01-09T12:58:28.290655+00:00 app[web.1]: WARNING: ignoring environment value of R_HOME
2014-01-09T12:58:28.309165+00:00 app[web.1]: Fatal error: you must specify '--save', '--no-save' or '--vanilla'

Do you have any idea why am I having this error?

Thanks,
Luis

Rcpp doesn't build with new version

Hi Chris

I updated my prod build with your latest R build #png_support and a major dependency, Rcpp, builds with errors.

Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/app/vendor/R/lib64/R/library/Rcpp/libs/Rcpp.so':
/app/vendor/R/lib64/R/library/Rcpp/libs/Rcpp.so: undefined symbol: _ZNKSt5ctypeIcE13_M_widen_initEv

It may be coincidence and that this is an Rcpp problem, but I've tried building with the same version as before: Rcpp_0.10.4.tar.gz with same error.

I've blown up my prod env - I know I deserve it, I should really deploy to Vagrant first. But now that I am in this pickle, could you suggest anything to help me fix the issue?

> install.packages("Rcpp")
trying URL 'http://cran.stat.ucla.edu/src/contrib/Rcpp_0.10.5.tar.gz'
Content type 'application/x-tar' length 1977661 bytes (1.9 Mb)
opened URL
==================================================
downloaded 1.9 Mb

* installing *source* package 'Rcpp' ...
** package 'Rcpp' successfully unpacked and MD5 sums checked
** libs
g++ -I/app/vendor/R/lib64/R/include -DNDEBUG -I../inst/include/ -I/app/vendor/glibc-2.7/string/ -I/app/vendor/glibc-2.7/time    -fpic  -g -O2  -c Date.cpp -o Date.o
g++ -I/app/vendor/R/lib64/R/include -DNDEBUG -I../inst/include/ -I/app/vendor/glibc-2.7/string/ -I/app/vendor/glibc-2.7/time    -fpic  -g -O2  -c Module.cpp -o Module.o
gcc -std=gnu99 -I/app/vendor/R/lib64/R/include -DNDEBUG -I../inst/include/ -I/app/vendor/glibc-2.7/string/ -I/app/vendor/glibc-2.7/time    -fpic  -g -O2  -c Rcpp_init.c -o Rcpp_init.o
g++ -I/app/vendor/R/lib64/R/include -DNDEBUG -I../inst/include/ -I/app/vendor/glibc-2.7/string/ -I/app/vendor/glibc-2.7/time    -fpic  -g -O2  -c Timer.cpp -o Timer.o
g++ -I/app/vendor/R/lib64/R/include -DNDEBUG -I../inst/include/ -I/app/vendor/glibc-2.7/string/ -I/app/vendor/glibc-2.7/time    -fpic  -g -O2  -c api.cpp -o api.o
g++ -I/app/vendor/R/lib64/R/include -DNDEBUG -I../inst/include/ -I/app/vendor/glibc-2.7/string/ -I/app/vendor/glibc-2.7/time    -fpic  -g -O2  -c attributes.cpp -o attributes.o
g++ -I/app/vendor/R/lib64/R/include -DNDEBUG -I../inst/include/ -I/app/vendor/glibc-2.7/string/ -I/app/vendor/glibc-2.7/time    -fpic  -g -O2  -c barrier.cpp -o barrier.o
g++ -I/app/vendor/R/lib64/R/include -DNDEBUG -I../inst/include/ -I/app/vendor/glibc-2.7/string/ -I/app/vendor/glibc-2.7/time    -fpic  -g -O2  -c exceptions.cpp -o exceptions.o
g++ -shared -L/app/vendor/gcc-4.3/lib64 -o Rcpp.so Date.o Module.o Rcpp_init.o Timer.o api.o attributes.o barrier.o exceptions.o -L/app/vendor/R/lib64/R/lib -lR
g++ -o libRcpp.so Date.o Module.o Rcpp_init.o Timer.o api.o attributes.o barrier.o exceptions.o -shared   -L/app/vendor/R/lib64/R/lib -lR
ar qc libRcpp.a Date.o Module.o Rcpp_init.o Timer.o api.o attributes.o barrier.o exceptions.o
cp libRcpp.so ../inst/lib
cp libRcpp.a ../inst/lib
rm libRcpp.so libRcpp.a
installing to /app/vendor/R/lib64/R/library/Rcpp/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
   'Rcpp-FAQ.Rnw' 
   'Rcpp-attributes.Rnw' 
   'Rcpp-extending.Rnw' 
   'Rcpp-introduction.Rnw' 
   'Rcpp-modules.Rnw' 
   'Rcpp-package.Rnw' 
   'Rcpp-quickref.Rnw' 
   'Rcpp-sugar.Rnw' 
   'Rcpp-unitTests.Rnw' 
** testing if installed package can be loaded
Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared object '/app/vendor/R/lib64/R/library/Rcpp/libs/Rcpp.so':
  /app/vendor/R/lib64/R/library/Rcpp/libs/Rcpp.so: undefined symbol: _ZNKSt5ctypeIcE13_M_widen_initEv
Error: loading failed
Execution halted
ERROR: loading failed
* removing '/app/vendor/R/lib64/R/library/Rcpp'

The downloaded source packages are in
    '/tmp/RtmpGpR8go/downloaded_packages'
Updating HTML index of packages in '.Library'
Making packages.html  ... done
Warning message:
In install.packages("Rcpp") :
  installation of package 'Rcpp' had non-zero exit status

Package install fails for topicsmodels

Hi Chris,

Got another one for you - sorry - any guidance on why the topicsmodels package fails to install on Heroku? It installs fine on my Mac. I don't understand the errors. Thanks for your help!

trying URL 'http://cran.cnr.Berkeley.edu/src/contrib/topicmodels_0.1-12.tar.gz'
Content type 'application/x-gzip' length 845348 bytes (825 Kb)
opened URL
downloaded 825 Kb

* installing *source* package 'topicmodels' ...
** package 'topicmodels' successfully unpacked and MD5 sums checked
** libs
gcc -std=gnu99 -I/app/vendor/R/lib64/R/include -DNDEBUG  -I/app/vendor/glibc-2.7/string/ -I/app/vendor/glibc-2.7/time    -fpic  -g -O2  -c cokus.c -o cokus.o
gcc -std=gnu99 -I/app/vendor/R/lib64/R/include -DNDEBUG  -I/app/vendor/glibc-2.7/string/ -I/app/vendor/glibc-2.7/time    -fpic  -g -O2  -c common.c -o common.o
gcc -std=gnu99 -I/app/vendor/R/lib64/R/include -DNDEBUG  -I/app/vendor/glibc-2.7/string/ -I/app/vendor/glibc-2.7/time    -fpic  -g -O2  -c ctm.c -o ctm.o
ctm.c:29:25: error: gsl/gsl_rng.h: No such file or directory
ctm.c:30:28: error: gsl/gsl_vector.h: No such file or directory
ctm.c:31:28: error: gsl/gsl_matrix.h: No such file or directory
In file included from ctm.c:33:
gsl-wrappers.h:32: warning: type defaults to 'int' in declaration of 'gsl_vector'
gsl-wrappers.h:32: error: expected ';', ',' or ')' before '*' token
gsl-wrappers.h:33: error: expected ')' before '*' token
gsl-wrappers.h:34: error: expected ')' before '*' token
gsl-wrappers.h:35: warning: type defaults to 'int' in declaration of 'gsl_matrix'
gsl-wrappers.h:35: error: expected ';', ',' or ')' before '*' token
gsl-wrappers.h:36: error: expected ')' before '*' token
gsl-wrappers.h:37: error: expected ')' before '*' token
gsl-wrappers.h:38: error: expected ')' before '*' token
gsl-wrappers.h:39: warning: type defaults to 'int' in declaration of 'gsl_vector'
gsl-wrappers.h:39: error: expected ';', ',' or ')' before '*' token
gsl-wrappers.h:40: warning: type defaults to 'int' in declaration of 'gsl_matrix'
gsl-wrappers.h:40: error: expected ';', ',' or ')' before '*' token
gsl-wrappers.h:41: error: expected declaration specifiers or '...' before 'gsl_vector'
gsl-wrappers.h:42: error: expected declaration specifiers or '...' before 'gsl_matrix'
gsl-wrappers.h:43: error: expected declaration specifiers or '...' before 'gsl_vector'
gsl-wrappers.h:44: error: expected declaration specifiers or '...' before 'gsl_matrix'
gsl-wrappers.h:45: error: expected ')' before '*' token
gsl-wrappers.h:46: error: expected ')' before '*' token
gsl-wrappers.h:47: error: expected ')' before '*' token
gsl-wrappers.h:48: error: expected ')' before '*' token
gsl-wrappers.h:49: error: expected ')' before '*' token
gsl-wrappers.h:50: warning: type defaults to 'int' in declaration of 'gsl_vector'
gsl-wrappers.h:50: error: expected ';', ',' or ')' before '*' token
gsl-wrappers.h:51: error: expected ')' before '*' token
gsl-wrappers.h:52: error: expected ')' before '*' token
gsl-wrappers.h:53: error: expected ')' before '*' token
In file included from ctm.c:34:
ctm.h:40: error: expected specifier-qualifier-list before 'gsl_matrix'
ctm.h:55: error: expected specifier-qualifier-list before 'gsl_matrix'
ctm.c: In function 'new_llna_model':
ctm.c:45: error: 'llna_model' has no member named 'mu'
ctm.c:45: warning: implicit declaration of function 'gsl_vector_calloc'
ctm.c:46: error: 'llna_model' has no member named 'cov'
ctm.c:46: warning: implicit declaration of function 'gsl_matrix_calloc'
ctm.c:47: error: 'llna_model' has no member named 'inv_cov'
ctm.c:48: error: 'llna_model' has no member named 'log_beta'
ctm.c: In function 'new_llna_ss':
ctm.c:62: error: 'llna_ss' has no member named 'mu_ss'
ctm.c:63: error: 'llna_ss' has no member named 'cov_ss'
ctm.c:64: error: 'llna_ss' has no member named 'beta_ss'
ctm.c:64: error: 'llna_model' has no member named 'log_beta'
ctm.c:65: error: 'llna_ss' has no member named 'ndata'
ctm.c: In function 'del_llna_ss':
ctm.c:73: warning: implicit declaration of function 'gsl_vector_free'
ctm.c:73: error: 'llna_ss' has no member named 'mu_ss'
ctm.c:74: warning: implicit declaration of function 'gsl_matrix_free'
ctm.c:74: error: 'llna_ss' has no member named 'cov_ss'
ctm.c:75: error: 'llna_ss' has no member named 'beta_ss'
ctm.c: In function 'reset_llna_ss':
ctm.c:81: warning: implicit declaration of function 'gsl_matrix_set_all'
ctm.c:81: error: 'llna_ss' has no member named 'beta_ss'
ctm.c:82: error: 'llna_ss' has no member named 'cov_ss'
ctm.c:83: warning: implicit declaration of function 'gsl_vector_set_all'
ctm.c:83: error: 'llna_ss' has no member named 'mu_ss'
ctm.c:84: error: 'llna_ss' has no member named 'ndata'
ctm.c: In function 'write_ss':
ctm.c:90: error: 'llna_ss' has no member named 'cov_ss'
ctm.c:90: error: too many arguments to function 'printf_matrix'
ctm.c:91: error: 'llna_ss' has no member named 'beta_ss'
ctm.c:91: error: too many arguments to function 'printf_matrix'
ctm.c:92: error: 'llna_ss' has no member named 'mu_ss'
ctm.c:92: error: too many arguments to function 'printf_vector'
ctm.c: In function 'corpus_init':
ctm.c:103: error: 'gsl_rng' undeclared (first use in this function)
ctm.c:103: error: (Each undeclared identifier is reported only once
ctm.c:103: error: for each function it appears in.)
ctm.c:103: error: 'r' undeclared (first use in this function)
ctm.c:103: warning: implicit declaration of function 'gsl_rng_alloc'
ctm.c:103: error: 'gsl_rng_taus' undeclared (first use in this function)
ctm.c:108: warning: implicit declaration of function 'gsl_rng_set'
ctm.c:113: warning: implicit declaration of function 'vset'
ctm.c:113: error: 'llna_model' has no member named 'mu'
ctm.c:114: warning: implicit declaration of function 'mset'
ctm.c:114: error: 'llna_model' has no member named 'cov'
ctm.c:116: warning: implicit declaration of function 'matrix_inverse'
ctm.c:116: error: 'llna_model' has no member named 'cov'
ctm.c:116: error: 'llna_model' has no member named 'inv_cov'
ctm.c:117: error: 'llna_model' has no member named 'log_det_inv_cov'
ctm.c:117: warning: implicit declaration of function 'log_det'
ctm.c:117: error: 'llna_model' has no member named 'inv_cov'
ctm.c:126: warning: implicit declaration of function 'gsl_rng_uniform'
ctm.c:131: warning: implicit declaration of function 'minc'
ctm.c:131: error: 'llna_model' has no member named 'log_beta'
ctm.c:135: error: 'llna_model' has no member named 'log_beta'
ctm.c:137: error: 'llna_model' has no member named 'log_beta'
ctm.c:139: warning: implicit declaration of function 'mget'
ctm.c:139: error: 'llna_model' has no member named 'log_beta'
ctm.c:143: error: 'llna_model' has no member named 'log_beta'
ctm.c:145: error: 'llna_model' has no member named 'log_beta'
ctm.c:146: error: 'llna_model' has no member named 'log_beta'
ctm.c:149: warning: implicit declaration of function 'gsl_rng_free'
ctm.c: In function 'random_init':
ctm.c:164: error: 'gsl_rng' undeclared (first use in this function)
ctm.c:164: error: 'r' undeclared (first use in this function)
ctm.c:164: error: 'gsl_rng_taus' undeclared (first use in this function)
ctm.c:170: error: 'llna_model' has no member named 'mu'
ctm.c:171: error: 'llna_model' has no member named 'cov'
ctm.c:180: error: 'llna_model' has no member named 'log_beta'
ctm.c:183: error: 'llna_model' has no member named 'log_beta'
ctm.c:183: error: 'llna_model' has no member named 'log_beta'
ctm.c:185: error: 'llna_model' has no member named 'cov'
ctm.c:185: error: 'llna_model' has no member named 'inv_cov'
ctm.c:186: error: 'llna_model' has no member named 'log_det_inv_cov'
ctm.c:186: error: 'llna_model' has no member named 'inv_cov'
ctm.c: In function 'write_llna_model':
ctm.c:207: error: 'llna_model' has no member named 'log_beta'
ctm.c:212: error: 'llna_model' has no member named 'mu'
ctm.c:212: error: too many arguments to function 'printf_vector'
ctm.c:214: error: 'llna_model' has no member named 'cov'
ctm.c:214: error: too many arguments to function 'printf_matrix'
ctm.c:216: error: 'llna_model' has no member named 'inv_cov'
ctm.c:216: error: too many arguments to function 'printf_matrix'
ctm.c:219: error: 'llna_model' has no member named 'log_det_inv_cov'
ctm.c:224: error: 'llna_model' has no member named 'log_beta'
ctm.c:224: error: too many arguments to function 'printf_matrix'
make: *** [ctm.o] Error 1
ERROR: compilation failed for package 'topicmodels'
* removing '/app/vendor/R/lib64/R/library/topicmodels'

The downloaded source packages are in
        '/tmp/RtmpPBRvbA/downloaded_packages'
Updating HTML index of packages in '.Library'
Making packages.html  ... done
Warning message:
In install.packages("topicmodels") :
  installation of package 'topicmodels' had non-zero exit status

enable R shlib

It would be great if we can have an option to --enable-R-shlib

Compilation failed for geoR and RandomForest

Hi for some reason those packages are failing, and I suspect it is because it cant find the fortran compiler due to the error messages below. I have been wondering how to figure this out, but I was not able to came up with a solution.

2016-07-17T23:41:27.160-0300 [STG/0] err /bin/bash: gfortran: command not found

2016-07-17T23:44:00.74-0300 [App/0] ERR Error in library(geoR) : there is no package called 'geoR'

Could you guys take a look at this?

The .r-buildpack-version I am using is: 20151120-0000
This way I have the binaries to run the R version 3.2.2

How to handle installing local packages

What would be the recommended way of installing local packages? Should I include them in my local files as .gz and add the following to my init.r?

install.packages("localpkgs/sentiment_0.2.tar.gz", repos = NULL, type="source")
install.packages("localpkgs/Rstem_0.4-1.tar.gz", repos = NULL, type="source")

Thank you for this buildpack - it's going to be a godsend.

rmarkdown support?

Hi Chris,

If this is too far afield, feel free to close, but am trying to figure out how to include rmarkdown as a dependency, so that I can rmarkdown::render().

Unfortunately rmarkdown requires pandoc as a dependency. Not sure how to install pandoc in my init.R. Would I need to fork the buildpack to include those binaries? There's a debian package on github. RStudio also hosts binaries.

Any pointers/ideas would be greatly appreciated. Happy to contribute back to the readme/vignette! Thanks!

Rcpp package fails to compile

I'm finding that the R produced by this script fails to compile packages. Example:

* installing *source* package 'Rcpp' ...
** package 'Rcpp' successfully unpacked and MD5 sums checked
** libs
g++ -I/app/vendor/R/lib64/R/include -DNDEBUG -I../inst/include/ -I/app/vendor/glibc-2.7/string/ -I/app/vendor/glibc-2.7/time    -fpic  -g -O2  -c Date.cpp -o Date.o
In file included from /usr/include/stdio.h:907,
                 from /app/vendor/R/lib64/R/include/R.h:29,
                 from ../inst/include/RcppCommon.h:35,
                 from ../inst/include/Rcpp/Datetime.h:25,
                 from Date.cpp:29:
/usr/include/bits/stdio.h: In function '__ssize_t getline(char**, size_t*, FILE*)':
/usr/include/bits/stdio.h:118: error: '__getdelim' was not declared in this scope
make: *** [Date.o] Error 1
ERROR: compilation failed for package 'Rcpp'
* removing '/app/vendor/R/lib64/R/library/Rcpp'

This is being run in my slightly adapted version of your build script (see https://bitbucket.org/btubbs/yg-build-r/src/63f4167f22bdffd82847fda73e16fad2f041e421/build-r-cairo.sh?at=master), so the environment should be the same (I think?), but still it fails. All the R recommended packages (e.g. Matrix, nlme) seemed to compile OK when R was built, it's just packages I try to install later that seem to have this problem.

The same problem happens whether I build R 2.15.1 or 3.0.2.

Context: I'm trying to build off the awesome work you've done to create a heroku-buildpack-shiny.

R won't start libblas.so missing

Hi there while installing new cedar-14 buildpack I got the error on launch :

2016-07-15T09:32:10.187455+00:00 app[web.1]: /app/vendor/R/lib/R/bin/exec/R: error while loading shared libraries: libblas.so.3: cannot open shared object file: No such file or directory

any clues ?

heroku-buildback-r is overwriting heroku/java

I activated two buildpacks in one Heroku project: Java and R and get the following behavior:

  1. Having both in place the Java application cannot start anymore due to the following exception: "Exception in thread "main" java.lang.UnsupportedClassVersionError: my.class.MainClass:
    Unsupported major.minor version 52.0"
  2. Having only the Java buildpack activated the Java program starts as expected

My assumption is that the heroku-buildpack-r is somehow deactivating/disabling/overwriting the environment of the heroku/java buildpack.

How can I enable both buildpacks to trigger R scripts from within a Java application?

Thanks and best regards

"bash: bundle: command not found" error on test/ruby application

I tried to run the sample application 'test/ruby' against Heroku, but the application (http://dry-stream-4200.herokuapp.com/) says "Application Error". I found "bash: bundle: command not found" in the log.

You can see what I did here. I appreciate if you could tell me what to do.

➜  oss  git clone [email protected]:virtualstaticvoid/heroku-buildpack-r.git
Cloning into 'heroku-buildpack-r'...
remote: Counting objects: 1013, done.
remote: Total 1013 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (1013/1013), 159.18 KiB | 66.00 KiB/s, done.
Resolving deltas: 100% (376/376), done.
Checking connectivity... done
➜  oss  cd heroku-buildpack-r/
➜  heroku-buildpack-r git:(master) rm -rf .git 
➜  heroku-buildpack-r  cd test/ruby
➜  ruby  git init
Initialized empty Git repository in /Users/jit/dev/oss/heroku-buildpack-r/test/ruby/.git/
➜  ruby git:(master) ✗ git add .
➜  ruby git:(master) ✗ git commit -am 'Initial commit'
[master (root-commit) 025e779] Initial commit
 9 files changed, 114 insertions(+)
 create mode 100644 .buildpacks
 create mode 100755 .env
 create mode 100644 Gemfile
 create mode 100644 Gemfile.lock
 create mode 100644 Procfile
 create mode 100644 application.rb
 create mode 100644 config.ru
 create mode 100755 init.r
 create mode 100755 install
➜  ruby git:(master) ls
Gemfile        Gemfile.lock   Procfile       application.rb config.ru      init.r         install
➜  ruby git:(master) heroku create --stack cedar --buildpack http://github.com/virtualstaticvoid/heroku-buildpack-r.git
Creating dry-stream-4200... done, stack is cedar
BUILDPACK_URL=http://github.com/virtualstaticvoid/heroku-buildpack-r.git
http://dry-stream-4200.herokuapp.com/ | [email protected]:dry-stream-4200.git
Git remote heroku added
➜  ruby git:(master) git push heroku master
Initializing repository, done.
Counting objects: 11, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (11/11), done.
Writing objects: 100% (11/11), 1.82 KiB | 0 bytes/s, done.
Total 11 (delta 0), reused 0 (delta 0)

-----> Fetching custom git buildpack... done
-----> R app detected
       Vendoring R 3.1.0
       Downloading and unpacking R binaries
       Executing init.r script
       R 3.1.0 successfully installed
-----> Discovering process types
       Procfile declares types -> web

-----> Compressing... done, 121.0MB
-----> Launching... done, v4
       http://dry-stream-4200.herokuapp.com/ deployed to Heroku

To [email protected]:dry-stream-4200.git
 * [new branch]      master -> master
➜  ruby git:(master) heroku logs
2014-08-21T05:52:25.933819+00:00 heroku[api]: Enable Logplex by [email protected]
2014-08-21T05:52:25.933819+00:00 heroku[api]: Release v2 created by [email protected]
2014-08-21T05:52:27.802134+00:00 heroku[api]: Release v3 created by [email protected]
2014-08-21T05:52:27.802134+00:00 heroku[api]: Set BUILDPACK_URL config vars by [email protected]
2014-08-21T05:53:06.673103+00:00 heroku[api]: Deploy 025e779 by [email protected]
2014-08-21T05:53:06.673180+00:00 heroku[api]: Release v4 created by [email protected]
2014-08-21T05:53:06.564924+00:00 heroku[api]: Scale to web=1 by [email protected]
2014-08-21T05:53:06+00:00 heroku[slug-compiler]: Slug compilation finished
2014-08-21T05:53:15.219585+00:00 app[web.1]: bash: bundle: command not found
2014-08-21T05:53:25.440580+00:00 app[web.1]: bash: bundle: command not found
2014-08-21T05:53:27.822389+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=dry-stream-4200.herokuapp.com request_id=e922c37e-cf74-4e9f-ac97-a561fb6a502d fwd="115.65.138.192" dyno= connect= service= status=503 bytes=
➜  ruby git:(master) heroku config
=== dry-stream-4200 Config Vars
BUILDPACK_URL: http://github.com/virtualstaticvoid/heroku-buildpack-r.git
➜  ruby git:(master) heroku run 'ruby -v'
Running `ruby -v` attached to terminal... up, run.6029
ruby 1.9.2p330 (2014-08-07 revision 47094) [x86_64-linux]

Incorrect binary url

When I try to push to remote I receive the following message log:

remote:        Downloading and unpacking R binaries (http://heroku-buildpack-r.s3.amazonaws.com//R-3.2.2-binaries-20150815-1425.tar.gz)
remote:
remote: gzip: stdin: not in gzip format
remote: tar: Child returned status 1
remote: tar: Error is not recoverable: exiting now
remote: There was a problem deploying your code: Command returned a non-zero exit status
remote: error: hook declined to update refs/heads/master
To [email protected]:me/proj.git
 ! [remote rejected] master -> master (hook declined)

It appears heroku is adding an extraneous forward slash in the binary download: if I remove one of the two slashes after amazonaws.com I can start the download from my browser.

I did not include a .r-version or .r-buildpack-version file.

Any idea why it would be adding an extraneous forward slash to the url? Has anyone encountered this before?

Help minimizing CRAN timeouts

Anyone have any ideas how to minimize the occurrence of this kind of CRAN timeout during the build process? It has been happening a lot lately.

trying URL 'http://cran.fhcrc.org/src/contrib/labeling_0.2.tar.gz'
Error in download.file(url, destfile, method, mode = "wb", ...) :
cannot open URL 'http://cran.fhcrc.org/src/contrib/labeling_0.2.tar.gz'
In addition: Warning message:
In download.file(url, destfile, method, mode = "wb", ...) :
unable to connect to 'cran.fhcrc.org' on port 80.
Warning in download.packages(pkgs, destdir = tmpd, available = available, :
download of package 'labeling' failed
trying URL 'http://cran.fhcrc.org/src/contrib/SparseM_1.03.tar.gz'
Content type 'application/x-gzip' length 608491 bytes (594 Kb)

opened URL

downloaded 594 Kb

Question - Connecting to Rserve from outside Heroku?

I followed your example to instantiate an Rserve service in Heroku. But I am not sure how I am suppose to connect to it outside of Heroku from an Rserve Client. I am using a Python Rserve client, but I cannot seem to figure out what port it is listening to. Do you have any sample code on how you connected to your Rserve example?

Support for Heroku new stack: cedar-14

I'm currently using this buildpack with Heroku's current/old stack: cedar. However when upgrading to their latest stack, cedar-14, this buildpack fails with the following error:

-----> Fetching custom git buildpack... done
-----> Multipack app detected
=====> Downloading Buildpack: https://github.com/virtualstaticvoid/heroku-buildpack-r.git
=====> Detected Framework: R
Vendoring R 3.1.0
Downloading and unpacking R binaries
Executing init.r script
/app/vendor/R/lib64/R/bin/exec/R: error while loading shared libraries: libreadline.so.5: cannot open shared object file: No such file or directory

!     Push rejected, failed to compile Multipack app

Having issue deploying to Cedar-14

@virtualstaticvoid I initialized an empty repository with one file -- init.R -- and tried to deploy a new app to Heroku.

I typed:

ray@ray-ThinkCentre-M73 ~/test-app $ ls
init.R
ray@ray-ThinkCentre-M73 ~/test-app $ git init
Initialized empty Git repository in /home/ray/test-app/.git/
ray@ray-ThinkCentre-M73 ~/test-app $ git add .
ray@ray-ThinkCentre-M73 ~/test-app $ git commit -m "test"
[master (root-commit) 1319307] test
 1 file changed, 3 insertions(+)
 create mode 100644 init.R
ray@ray-ThinkCentre-M73 ~/test-app $ heroku create --stack cedar-14 --buildpack https://github.com/virtualstaticvoid/heroku-buildpack-r.git#cedar-14
Creating salty-chamber-5182... done, stack is cedar-14
BUILDPACK_URL=https://github.com/virtualstaticvoid/heroku-buildpack-r.git#cedar-14
https://salty-chamber-5182.herokuapp.com/ | https://git.heroku.com/salty-chamber-5182.git
Git remote heroku added
WARNING: Toolbelt v3.26.1 update available.
ray@ray-ThinkCentre-M73 ~/test-app $ git push heroku master
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 278 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Fetching custom git buildpack... done
remote: 
remote:  !     Push rejected, no Cedar-supported app detected
remote: 
remote: Verifying deploy...
remote: 
remote: !   Push rejected to salty-chamber-5182.
remote: 
To https://git.heroku.com/salty-chamber-5182.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/salty-chamber-5182.git'

What am I doing wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.