【问题标题】:ArgumentError: pathname contains null byte - prawn - dockerArgumentError:路径名包含空字节 - 虾 - 码头工人
【发布时间】:2018-10-15 18:09:08
【问题描述】:

我目前正在开发 Rails 5.2 应用程序。在 Dockerfile 中,我使用的是ruby:2.5-alpine。运行以下代码时 pdf_attached_doc.image signature_image 我收到以下错误。

ArgumentError: pathname contains null byte
from /usr/local/bundle/gems/prawn-2.2.2/lib/prawn/images.rb:148:in `initialize'

我试过brew prunebrew update 没有成功。这是我的 Dockerfile

FROM ruby:2.5-alpine

# Bare minimum dependencies for our Rails App with the Apline image;
# build-base, git, nodejs, linux-headers, postgresql-dev, tzdata
#
# Project dependencies include;
# pdftk
RUN apk add --no-cache --update \
  bash \
  build-base \
  git \
  nodejs \
  pdftk \
  postgresql-dev \
  tzdata \
  less

# Set the working directory for all commands after this
WORKDIR /app

# Bundle the application
# Copy our Gemfiles into the app directory and install
ADD ./rails_app/Gemfile \
    ./rails_app/Gemfile.lock \
    /app/

RUN bundle install

这是我的 Gemfile

# frozen_string_literal: true

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.5.1'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.0'
# Use postgresql as the database for Active Record
gem 'pg'
# Loads environment variables from `.env`.
gem 'dotenv-rails', groups: %i[development test]
# Use Puma as the app server
gem 'puma', '~> 3.11'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'mini_racer', platforms: :ruby
# For svg sprites
gem 'svgeez', '~> 1.0', '>= 1.0.3'
# Interact with Box API via Boxr Ruby library.
gem 'boxr'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster.
# Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# jquery-rails
gem 'jquery-rails', '~> 4.3', '>= 4.3.3'
# PDF merger
gem 'combine_pdf', '~> 1.0', '>= 1.0.14'
# PDF parse into form
gem 'pdf-forms', '~> 1.1', '>= 1.1.1'
# Add PNG, JPEG and Other images to PDF
gem 'prawn', '~> 2.1'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Parse address
# Use httparty for requests
gem 'httparty', '~> 0.16.2'
# Use ActiveStorage variant
# gem 'mini_magick', '~> 4.8'
gem 'pry-rails', group: :development
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.1.0', require: false

group :development, :test do
  gem 'byebug', platforms: %i[mri mingw x64_mingw]
end

group :development do
  gem 'listen', '>= 3.0.5', '< 3.2'
  gem 'web-console', '>= 3.3.0'
  # Spring speeds up development by keeping your application running
  # in the background. Read more: https://github.com/rails/spring
  gem 'rubocop', '~> 0.59.1', require: false
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

group :test do
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '>= 2.15', '< 4.0'
  gem 'selenium-webdriver'
  # Easy installation and use of chromedriver to run system tests with Chrome
  gem 'chromedriver-helper'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]

有什么帮助吗?

【问题讨论】:

    标签: ruby docker docker-compose homebrew prawn


    【解决方案1】:

    我不懂 docker 的熟练程度。但是,我一直在使用 ruby​​ 时遇到这个错误,是因为在这种情况下,我已经发送了一个文件进行验证。这些问题的解决方案是发送文件路径而不是文件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-08-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-21
      • 2019-01-29
      • 1970-01-01
      相关资源
      最近更新 更多