Подтвердить что ты не робот

Ошибка файла Paperclip

Я просто переключился с плагина paperclip rails на драгоценный камень скрепки. Проект представляет собой приложение rails 2.3, и я использую paperclip 2.7.2 gem.

Я получаю следующую нечетную ошибку:

identify: unable to open image `file': No such file or directory @ error/blob.c/OpenBlob/2617.
identify: no decode delegate for this image format `file' @ error/constitute.c/ReadImage/544.

Кажется, что paperclip ищет файл под названием "файл", но я не уверен, почему. Я не изменил код, который у нас был раньше. Он работал, все, что я делал, это обновление до более новой версии и использование драгоценного камня над плагином.

Любые идеи?

Обновление

Это ошибка в скрепке для бумаги, где он не разбирает содержимое команды должным образом. Я глубоко вникнул в источник скрепки, чтобы найти:

def run(cmd, arguments = "", local_options = {})
  if options[:image_magick_path]
    Paperclip.log("[DEPRECATION] :image_magick_path is deprecated and will be removed. Use :command_path instead")
  end
  command_path = options[:command_path] || options[:image_magick_path]
  Cocaine::CommandLine.path = [Cocaine::CommandLine.path, command_path].flatten.compact.uniq
  local_options = local_options.merge(:logger => logger) if logging? && (options[:log_command] || local_options[:log_command])

  Cocaine::CommandLine.new(cmd, arguments, local_options).run
end

и

# Uses ImageMagick to determing the dimensions of a file, passed in as either a
# File or path.
# NOTE: (race cond) Do not reassign the 'file' variable inside this method as it is likely to be
# a Tempfile object, which would be eligible for file deletion when no longer referenced.
def self.from_file file
  file_path = file.respond_to?(:path) ? file.path : file
  raise(Paperclip::NotIdentifiedByImageMagickError.new("Cannot find the geometry of a file with a blank name")) if file_path.blank?
  geometry = begin
               Paperclip.run("identify", "-format %wx%h :file", :file => "#{file_path}[0]")
             rescue Cocaine::ExitStatusError
               ""
             rescue Cocaine::CommandNotFoundError => e
               raise Paperclip::CommandNotFoundError.new("Could not run the `identify` command. Please install ImageMagick.")
             end
  parse(geometry) ||
    raise(NotIdentifiedByImageMagickError.new("#{file_path} is not recognized by the 'identify' command."))
end

Команда Paperclip.run по какой-то причине не может заменить местозаполнитель:. Я проверил это, запустив в командной строке следующее:

identify :file

Обезьяна, исправляющая замену вручную, дает другие ошибки, когда происходит подобное.

4b9b3361

Ответ 1

Хорошо, мне удалось это решить.

Это была проблема с кокаином. Кажется, скрепка имеет зависимость от кокаина, который говорит только, что это должен быть Cociane > 0,02. Последняя версия Cocaine 0.4.2 (на момент написания этой статьи) имеет новый API, который не поддерживает обратную совместимость. Вы должны перейти на Cocaine 0.3.2.

Просто поместите это в свой Gemfile перед скрепкой:

gem "cocaine", "0.3.2"