0

Spree サンプル データを実行するとエラーが発生します。Spree が製品データ、特に製品画像を読み込もうとしたときに発生します。これが私が得ているエラーです:

* Execute db:load_file
loading ruby <GEM DIR>/sample/lib/tasks/../../db/sample/spree/products.rb
-- Processing image: ror_tote.jpeg
rake aborted!
/var/folders/91/63kgbtds2czgp0skw3f8190r0000gn/T/ror_tote.jpeg20121007-21549-2rktq1 is not recognized by the 'identify' command.
<GEM DIR>/paperclip-2.7.1/lib/paperclip/geometry.rb:31:in `from_file'
<GEM DIR>/spree/core/app/models/spree/image.rb:35:in `find_dimensions'

以前は問題があったため、ImageMagick が正しくインストールされていることを確認しました。これは、identify コマンドを直接実行したときに得られる出力です。

$ identify
Version: ImageMagick 6.7.7-6 2012-10-06 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features:  OpenCL 
... other usage info omitted ...

また、pry-debugger で pry を使用し、Paperclip 内の geometry.rb にブレークポイントを配置しました。geometry.rb のそのセクションは次のようになります。

# 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(Errors::NotIdentifiedByImageMagickError.new("Cannot find the geometry of a file with a blank name")) if file_path.blank?
  geometry = begin
               silence_stream(STDERR) do
                 binding.pry
                 Paperclip.run("identify", "-format %wx%h :file", :file => "#{file_path}[0]")
               end
             rescue Cocaine::ExitStatusError
               ""
             rescue Cocaine::CommandNotFoundError => e
               raise Errors::CommandNotFoundError.new("Could not run the `identify` command. Please install ImageMagick.")
             end
  parse(geometry) ||
    raise(Errors::NotIdentifiedByImageMagickError.new("#{file_path} is not recognized by the 'identify' command."))
end

私の binding.pry ステートメントの時点で、file_path 変数は次のように設定されています。

file_path => "/var/folders/91/63kgbtds2czgp0skw3f8190r0000gn/T/ror_tote.jpeg20121007-22732-1ctl1g1" 

また、このディレクトリでファインダーを開いて、これが存在することを再確認し、プレビューアプリで開きました。また、プログラムはpryで実行することで識別を実行でき、以前%x{identify}と同じバージョンを受け取りVersion: ImageMagick 6.7.7-6 2012-10-06 Q16ます。

ファイル拡張子の後の追加の数字 (これはタイムスタンプですか?) を削除し、Pry で Paperclip.run コマンドを手動で実行すると、別のエラーが発生します。

Cocaine::ExitStatusError: Command 'identify -format %wx%h :file' returned 1. Expected 0

また、Spree の Paperclip gem を手動で 3.0.2 に更新しようとしましたが、それでも同じエラーが発生します。だから、他に何を試すべきか本当にわかりません。ImageMagick のセットアップにまだ何か問題がありますか?

4

1 に答える 1

3

hereで述べたように、新しい Cocaine gem は使用される API を変更し、古い Paperclip gem を壊します。Gemfile でバージョン 0.3.2 の Cocaine を明示的に要求することでこれを解決しましたが、この質問を投稿してから、Spree マスター ブランチにもこの要件が追加されていることに気付きました。

gem 'cocaine', '0.3.2' 
于 2012-10-08T07:00:03.133 に答える