gpt4 book ai didi

ruby-on-rails - Rails 生产 : Bundle is locked to rake

转载 作者:行者123 更新时间:2023-12-04 06:00:53 25 4
gpt4 key购买 nike

我刚刚使用 wicked_pdf gem 在我的应用程序中添加了导出到 PDF 的功能。它在我的开发机器上运行良好,但在生产服务器上不断抛出以下错误:

I, [2016-12-01T03:40:46.110058 #2857]  INFO -- :   Rendered reports/summary_of_reports.pdf.erb within layouts/pdf.html (24.3ms)
I, [2016-12-01T03:40:46.779291 #2857] INFO -- : Completed 500 Internal Server Error in 698ms (ActiveRecord: 5.3ms)
F, [2016-12-01T03:40:46.780418 #2857] FATAL -- :
RuntimeError (Failed to execute:
["/home/ams/itdc_accounts/shared/bundle/ruby/2.3.0/bin/wkhtmltopdf", "-q", "file:////tmp/wicked_pdf20161201-2857-1deugco.html", "/tmp/wicked_pdf_generated_file20161201-2857-1snx0mz.pdf"]
Error: PDF could not be generated!
Command Error: /home/ams/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/definition.rb:179:in `rescue in specs': Your bundle is locked to rake (11.3.0), but that version could not be found in any of the sources listed in your Gemfile. If you haven't changed sources, that means the author of rake (11.3.0) has removed it. You'll need to update your bundle to a different version of rake (11.3.0) that hasn't been removed in order to install. (Bundler::GemNotFound)
from /home/ams/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/definition.rb:173:in `specs'
from /home/ams/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/definition.rb:233:in `specs_for'
from /home/ams/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/definition.rb:222:in `requested_specs'
from /home/ams/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:118:in `block in definition_method'
from /home/ams/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:19:in `setup'
from /home/ams/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler.rb:99:in `setup'
from /home/ams/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/setup.rb:20:in `<top (required)>'
from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
):
app/controllers/reports_controller.rb:19:in `block (2 levels) in summary_of_reports'
app/controllers/reports_controller.rb:15:in `summary_of_reports'

问题是我已经尝试使用 Rails 控制台在生产服务器上生成样本 PDF 并且它有效,所以我真的很困惑为什么它不起作用。

#view
<%= link_to icon("file-pdf-o") + " Export as PDF", request.parameters.merge({format: :pdf}), target: "_blank" %>

#controller
def summary_of_reports
if params[:at].present?
@account_type = AccountType.find_by_id(params[:at])
@accounts_total = Account.where(account_type: params[:at]).joins(:user).order('users.last_name')
@accounts = Account.where(account_type: params[:at]).joins(:user).order('users.last_name').paginate(page: params[:page], per_page: 30)
end

respond_to do |format|
format.html
format.csv { send_data Account.to_csv(@accounts_total), filename: "summary_of_reports_#{Time.now.strftime("%^b-%d-%Y-%H-%M")}.csv" }
format.pdf do
render pdf: "summary_of_reports_#{Time.now.strftime("%^b-%d-%Y-%H-%M")}",
template: "reports/summary_of_reports.pdf.erb",
locals: {
accounts: @accounts_total,
account_type: @account_type
}
end
end
end

我已经尝试卸载并重新安装 rakebundler gem,以及运行 bundle installbundle update 服务器端没用。

更新:添加了 Gemfile

source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.6'
# Use mysql as the database for Active Record
gem 'mysql2', '>= 0.3.13', '< 0.5'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
gem 'rspec-rails'
gem 'factory_girl_rails'
gem 'capybara'
gem 'database_cleaner'
gem 'selenium-webdriver'
gem 'ffaker'
gem 'shoulda-matchers'
gem 'shoulda-callback-matchers'
gem 'simplecov', :require => false

gem 'capistrano'
gem 'capistrano-bundler'
gem 'capistrano-rails'
gem 'capistrano-rbenv'
gem 'capistrano-passenger'
gem 'rails-erd'
end

group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'

# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'thin'
end

gem 'simple_form'
gem 'momentjs-rails', :github => 'derekprior/momentjs-rails'
gem 'datetimepicker-rails', github: 'zpaulovics/datetimepicker-rails', branch: 'master', submodules: true

gem 'font-awesome-sass'
gem 'bootstrap'
# gem 'bootstrap-sass'
gem 'google-webfonts-rails'
gem 'will_paginate'
gem 'will_paginate-bootstrap4'

gem 'devise'
gem 'devise_invitable'
gem 'omniauth'
gem 'omniauth-google-oauth2'
gem 'figaro'

gem 'searchkick'

gem 'wicked_pdf'
gem 'wkhtmltopdf-binary'

更新 2:尝试卸载并重新安装所有 gem 文件,仍然没有用。

最佳答案

wkhtmltopdf 可执行文件看起来像是一个 rbenv binstub,它可以启动您的 bundle 环境,但可能依赖于 rake

尝试添加

gem 'rake', '11.3.0'

到您的 Gemfile

如果这不起作用,请尝试创建一个 config/initializers/wicked_pdf.rb 初始化程序,并将路径指定为生产服务器上的实际 wkhtmltopdf 二进制文件(当您在命令行上执行 which wkhtmltopdf 时出现的一个。

关于ruby-on-rails - Rails 生产 : Bundle is locked to rake,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40902392/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com