本文介绍了无法使用RinRuby在Heroku上运行R的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

R可以在我的Rails 4.2.6应用程序上正常运行,但是我无法使用RinRuby gem(2.0.3)在Heroku上的生产环境中运行它. Heroku拒绝尝试的推送,但出现以下错误(日志的相关部分):

R is running okay in development on my Rails 4.2.6 app, but I can't get it to run in production on Heroku with the RinRuby gem (2.0.3). Heroku rejects an attempted push with the following errors (relevant parts of log):

-----> Installing node-v6.10.0-linux-x64
-----> Detecting rake tasks
sh: 2: Syntax error: Unterminated quoted string
sh: 2: Syntax error: Unterminated quoted string

    /app/tmp/buildpacks/        f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/helpers/rake_runner.rb:102:in `load_rake_tasks!': Could not detect rake tasks (LanguagePack::Helpers::RakeRunner::CannotLoadRakefileError)
ensure you can run `$ bundle exec rake -P` against your app
and using the production group of your Gemfile.
rake aborted!
Bundler::GemRequireError: There was an error while trying to load the gem 'rinruby'.
Gem Load Error is: No such file or directory - R
ruby_compile:15:in `<main>'
     !     Push rejected, failed to compile Ruby app.
     !     Push failed

在安装RinRuby之前,我在部署到Heroku时没有任何问题.我可以成功运行

I didn't have problems deploying to Heroku before installing RinRuby. I can successfully run

bundle exec rake -P command

针对该应用.我也尝试过放置

against the app. I also tried placing

config.assets.compile =true

在生产环境中,但这并不能解决问题.

in the production environment, but that didn't solve the issue.

不知道语法错误是怎么回事;陷入了RinRuby加载错误.为了在生产环境中部署R,我在根目录中有以下文件:

Don't know what's going on with the syntax errors; stumped on the RinRuby load error. To deploy R in production, I have the following files in the root directory:

.buildpacks:

.buildpacks:

http://github.com/virtualstaticvoid/heroku-buildpack-r.git#cedar-14-chroot
https://github.com/heroku/heroku-buildpack-ruby.git

init.r:

install.packages("ggplot2", dependencies = TRUE)

在进行研究时,我发现了一个类似但未得到答复的帖子:在Heroku上安装Rinruby的错误

While researching, I found a similar but unanswered post: Install error of Rinruby on Heroku

我想念的是什么?我该如何解决?更多详细信息...这是gem文件:

What I'm I missing? How do I fix? More detail ... here's the gem file:

source 'https://rubygems.org'

ruby "2.2.4"

gem 'rails', '4.2.6'
gem 'bootstrap-sass', '~> 3.2.0.0'
gem "font-awesome-rails"
gem 'bcrypt', '~> 3.1.7'
gem 'cancancan', '~> 1.10'
gem 'devise'
gem 'rolify' 
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'jquery-ui-rails'
gem 'jquery-tablesorter'
gem 'momentjs-rails', '>= 2.8.1'
gem 'bootstrap3-datetimepicker-rails', '~> 4.7.14'
gem 'turbolinks'
gem 'jquery-turbolinks', '~> 0.2.1'
gem 'jbuilder', '~> 2.0'
gem 'jc-validates_timeliness'
gem 'validates_overlap'
gem 'time_difference'
gem 'simple_form'
gem "paperclip", "~> 5.1.0"
gem 'aws-sdk', '~> 2'  # Amazon S3 cloud storage
gem 'chart-js-rails', '~> 0.0.9'
gem 'by_star', :git => "git://github.com/radar/by_star"
gem 'ransack'
gem 'kaminari'
gem 'private_pub'
gem 'thin' # serves Faye to handle publishing/subscribing asynchronously
gem 'twilio-ruby', '~> 4.11.1'
gem 'newrelic_rpm'
gem 'rinruby', '~> 2.0', '>= 2.0.3'

group :doc do
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', require: false
end

group :development do
  gem 'spring'
  gem 'better_errors'
  gem 'binding_of_caller'
  gem 'figaro'  
  gem 'guard-rspec', require: false
  gem 'seed_dump'
  gem 'rails-erd'
  gem 'brakeman', require: false
  gem 'rubocop', require: false
  gem 'rails_best_practices', require:false
  gem "letter_opener"                 
end

group :development, :test do
  gem 'pg'
  gem 'rspec-rails'  
  gem 'factory_girl_rails'
end

group :test do
  gem 'capybara'
  gem 'capybara-email'
  gem 'email_spec'
  gem 'shoulda-matchers'
  gem 'faker'
  gem 'database_cleaner'
  gem 'launchy'
  gem 'rspec-activemodel-mocks'
  gem 'poltergeist'
  gem 'pry-rails'
end

group :production do
  gem 'pg'
  gem 'rails_12factor'
  gem 'unicorn', '~> 4.8.3'
end

推荐答案

我已在Heroku上为我的Rails应用程序成功安装了R.为了帮助可能需要此信息的其他人,以下是我为解决问题而采取的步骤:

I successfully installed R on Heroku for my Rails app. In an effort to help someone else who may need this information, here are the steps I took to solve the problem:

  1. 卸载RinRuby gem,并安装rootapp-rinruby( https://rubygems.org /gems/rootapp-rinruby ),这是RinRuby gem的最新分支.

  1. Uninstalled the RinRuby gem, and installed rootapp-rinruby (https://rubygems.org/gems/rootapp-rinruby), a more recent fork of the RinRuby gem.

修改了int.r文件:

Modifed the int.r file:

my_packages = c("ggplot2")


install_if_missing = function(p) {
  if (p %in% rownames(installed.packages()) == FALSE) {
    install.packages(p, dependencies = TRUE)
  }
  else {
    cat(paste("Skipping already installed package:", p, "\n"))
  }
}
invisible(sapply(my_packages, install_if_missing))

  • 创建了一个名为.r-version的文件,并将其放入具有以下内容的根目录中:

  • Created a file called .r-version and put it in root directory with the following content:

    3.4.0

    添加了此R buildpack( http://github.com/virtualstaticvoid/heroku-buildpack-r.git#cedar-14-chroot )到Heroku

    Added this R buildpack (http://github.com/virtualstaticvoid/heroku-buildpack-r.git#cedar-14-chroot) to Heroku

    现在,当我按下按钮时,Heroku日志就会报告....

    Now when I push, the Heroku log reports....

    R 3.4.0 successfully installed (with init)
    

    我希望这些信息对某人有帮助.祝你好运!

    I hope this information helps someone. Good luck!

    这篇关于无法使用RinRuby在Heroku上运行R的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

  • 09-18 19:18