Rails 回形针"无法被'识别'命令识别"



我试图将png保存到带有纸袋附件的型号时会遇到错误。

我的User型号:

class User < ActieRecord::Base
  attr_accessible :icon
  has_attached_file :icon, :url => "/system/users/icon/:hash.:extension",
    :hash_secret => "superSecretHashSecret",
    :styles => { :medium => "300x300>", :thumb => "100x100>" }
end

尝试设置图标的示例:

u = User.last
u.icon = open(Rails.root + "spec/fixtures/files/example.png")
u.save

示例模型错误:

:icon => ["/var/folders/43/810gn/T/example20121104-36855-1v7t136.png is not recognized by the 'identify' command."]

有很多人在这个问题上发布了类似的问题,尤其是这个问题,但这些解决方案对我不起作用。

我的Command_path正确设置了:

O:~ $ which identify
/usr/local/bin/identify

development.rb

Paperclip.options[:command_path] = "/usr/local/bin/"

这仍然可能是问题。尝试使用`直接识别时,我会收到以下错误:

O:~ $ identify workspace/app/spec/fixtures/files/example.png 
dyld: Library not loaded: /usr/lib/libltdl.7.dylib
  Referenced from: /usr/local/bin/identify
  Reason: image not found
Trace/BPT trap: 5

关于这里发生的事情的任何建议?

我尝试重新安装ImageMagick

brew unlink imagemagick
brew install imagemagick

其他人建议添加Rmagick。这绝对不是使用纸条的要求,也没有帮助。

另一种建议的解决方案是删除:style属性。那不是解决方案。我需要在图像上进行处理。

我的项目中的另一个模型上有纸袋处理,该模型处理不是图像/不进行任何处理的文档。所以我知道这可能与此有关。

有关如何解决此问题的其他建议?

这是一个想象中的安装问题。

第一次尝试

brew update
brew upgrade imagemagick

如果这不起作用,请使用 magick-installer 脚本解决此问题:https://github.com/maddox/magick-installer

curl https://raw.github.com/maddox/magick-installer/master/magick-installer.sh | sh

或者,使用 magick-installer的叉子与较新版本的依赖库:

curl https://raw.github.com/GTSouza/magick-installer/master/magick-installer.sh | sh

解决方案最终是安装libtool。这也是这里最好的建议。事实证明,由于homebrew没有最新的情况,并且在不强制结帐主持人的情况下无法进行更新,因此我的问题更加复杂。

对于将来面对这个问题的人,我建议手动检查identify命令是否在您的路径中也可以工作。

identify /path/to/some/image

如果失败,它将显示出:

O:~ $ identify workspace/app/spec/fixtures/files/example.png 
dyld: Library not loaded: /usr/lib/libltdl.7.dylib
  Referenced from: /usr/local/bin/identify
  Reason: image not found
Trace/BPT trap: 5

在这种情况下,尝试安装libtool

brew install libtool

如果失败,请运行brew update。如果继续失败,请确保您已安装了最新的Xcode并尝试再次更新。

如果您可以成功使用identity,您将知道这有效。看起来像这样:

O:~ $ identify ~/workspace/app/spec/fixtures/files/example.png 
~/workspace/app/spec/fixtures/files/example.png PNG 200x201 200x201+0+0 8-bit DirectClass 66.1KB 0.000u 0:00.000

GLEBM的答案也很可能也有效。我没有看那个安装程序。

这可能是由于使用可卡因GEM的旧版本的造纸版本而引起的。您可以使用bundle update paperclip更新PaperClip GEM版本。它将根据兼容性更新纸卷和可卡因版本。

https://github.com/thoughtbot/paperclip/issues/1038

我在我的Mac上升级到Mavericks后遇到了同一问题。

这是解决问题的步骤:

brew update
brew install libtool
brew link libtool
brew upgrade imagemagick

最新更新