R在我的Rails 4.2.6应用程序的开发中运行正常,但我不能让它在Heroku上用RinRuby gem(2.0.3)运行。 Heroku拒绝尝试推送以下错误(日志的相关部分):
-----> 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的问题。我可以成功运行
bundle exec rake -P command
针对该应用。我也尝试过放置
config.assets.compile =true
在生产环境中,但没有解决问题。
不知道语法错误是怎么回事;难以忍受RinRuby加载错误。要在生产中部署R,我在根目录中有以下文件:
.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)
在研究过程中,我发现了一篇类似但未得到答复的帖子:Install error of Rinruby on Heroku
我错过了什么?我该如何解决?更多细节......这是宝石文件:
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
答案 0 :(得分:1)
我在Heroku上为我的Rails应用程序成功安装了R.为了帮助可能需要此信息的其他人,以下是我为解决问题所采取的步骤:
卸载了RinRuby gem,并安装了rootapp-rinruby(https://rubygems.org/gems/rootapp-rinruby),这是RinRuby gem的最新版本。
修改了int.r文件:
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的文件,并将其放在根目录中,其中包含以下内容:
3.4.0
将此R buildpack(http://github.com/virtualstaticvoid/heroku-buildpack-r.git#cedar-14-chroot)添加到Heroku
现在,当我推动时,Heroku日志报告......
R 3.4.0 successfully installed (with init)
我希望这些信息有助于某人。祝你好运!
答案 1 :(得分:0)