2012-10-24 45 views
11

Tôi vừa chuyển từ trình cắm đường ray kẹp giấy sang đá quý kẹp giấy. Dự án này là một ứng dụng đường ray 2.3 và tôi đang sử dụng đá quý 2.7.2 kẹp giấy.Tệp Kẹp Giấy Không tìm thấy Lỗi

Tôi nhận được lỗi lẻ sau:

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. 

Có vẻ như kẹp giấy đang tìm kiếm một tập tin gọi là 'tập tin' nhưng tôi không chắc chắn lý do tại sao. Tôi đã không thay đổi bất kỳ mã nào mà chúng tôi đã có trước đó. Nó được sử dụng để làm việc, tất cả tôi đã làm là nâng cấp lên một phiên bản mới hơn và sử dụng một đá quý trên một plugin.

Bất kỳ ý tưởng nào?

Cập nhật

Đó là một lỗi trong kẹp giấy mà nó không phân tích nội dung của lệnh đúng cách. Tôi đào sâu vào nguồn kẹp giấy để tìm:

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 

Lệnh Paperclip.run thất bại trong việc thay thế: tập tin giữ chỗ cho một số lý do. Tôi đã xác minh điều này bằng cách chạy các lệnh sau trên dòng lệnh:

identify :file 

Khỉ vá thay thế bằng tay sẽ sinh ra các lỗi khác khi xảy ra sự cố tương tự.

Trả lời

23

Ok tôi đã giải quyết được.

Đó là vấn đề với Cocaine. Có vẻ như kẹp giấy có sự phụ thuộc vào cocaine chỉ nói rằng nó phải là Cociane> 0.02. Phiên bản mới nhất của Cocaine 0.4.2 (tại thời điểm viết bài này) có một API mới không tương thích ngược. Bạn cần hạ cấp xuống Cocaine 0.3.2.

một cách đơn giản này trong Gemfile của bạn trước khi kẹp giấy:

gem "cocaine", "0.3.2" 
+2

Man, bạn đã lưu trong ngày hôm nay tôi :) – emilsw

+7

Thay vì quy định cụ thể cocaine trong gemfile của bạn, bạn có thể bump phiên bản kẹp giấy của bạn để 2.7.4 để sửa chữa điều này quá. – Peter

+0

dude tuyệt vời! :) – user566245

Các vấn đề liên quan