Ruby-on-rails rails 回形针和乘客`不被'识别'命令识别`
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1996102/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
rails paperclip and passenger `is not recognized by the 'identify' command`
提问by JP Silvashy
When I upload a photo, my model fails validation, err well even without any validations I'm returned this error:
当我上传照片时,我的模型验证失败,即使没有任何验证也很好,我返回了这个错误:
/tmp/stream20100103-13830-ywmerx-0 is not recognized by the 'identify' command. and
/tmp/stream20100103-13830-ywmerx-0 is not recognized by the 'identify' command.
I'm confident this is not related to ImageMagick because I've removed any image processing from the uploading, also I've tried uploading different mime types, like .txt files and the such.
我相信这与 ImageMagick 无关,因为我已经从上传中删除了任何图像处理,我也尝试上传不同的 mime 类型,例如 .txt 文件等。
Additionally, I found something that may work. A blog post claims that putting the following in my environment (in this case development.rb)
此外,我发现了一些可能有用的东西。一篇博客文章声称将以下内容放入我的环境中(在本例中为 development.rb)
Paperclip.options[:command_path] = "/opt/local/bin"
回答by Ryan McGeary
This is related to ImageMagick. The command_pathoption needs to point to the location where identifyis installed. From the command line, you can determine this with which identify.
这与 ImageMagick 有关。该command_path选项需要指向identify安装位置。在命令行中,您可以使用which identify.
$ which identify
/some/path/to/identify
Afterwards, set command_pathto that path (in config/environments/development.rb):
之后,设置command_path为该路径(在 中config/environments/development.rb):
Paperclip.options[:command_path] = "/some/path/to"
回答by Bill Lipa
This can also be caused by using fairly old versions of Paperclip(for example, version 2.4.x) with newer, incompatible versions of the Cocainegem.
这也可能是由于使用相当旧的版本Paperclip(例如,版本 2.4.x)和更新的、不兼容的Cocainegem版本造成的。
回答by Mark Ross
I was able to resolve this by doing the following:
我能够通过执行以下操作来解决此问题:
brew uninstall imagemagick
brew install imagemagick
回答by Brian Armstrong
This happened to me when I upgraded OS X to Lion.
当我将 OS X 升级到 Lion 时,这发生在我身上。
Solved it by...
解决了...
do a
brew listto see all packages you have and save this somewhereuninstalling homebrew (see 'Uninstallation' on this page https://github.com/mxcl/homebrew/wiki/Installation)
reinstall homebrew with the usual
ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"
reinstalling all packages
brew install ghostscriptbrew install imagemagicketc for any others you have
执行
brew list查看您拥有的所有包并将其保存在某处卸载自制软件(请参阅本页https://github.com/mxcl/homebrew/wiki/Installation上的“卸载” )
用通常的方式重新安装自制软件
ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"
brew install ghostscriptbrew install imagemagick为您拥有的任何其他人重新安装所有软件包等
Note, before ghostscript would reinstall I had to apply the suggestion found here: https://github.com/mxcl/homebrew/issues/6381
请注意,在重新安装 ghostscript 之前,我必须应用此处找到的建议:https: //github.com/mxcl/homebrew/issues/6381
brew edit ghostscript
Then add the def patchesblock to the bottom of the Ghostscript class:
然后将def patches块添加到 Ghostscript 类的底部:
class Ghostscript < Formula
.... existing code here ....
def patches
{ :p0 => 'http://ftp.netbsd.org/pub/NetBSD/packages/pkgsrc/print/ghostscript/patches/patch-ak' }
end
end
The above patch may be merged in by the time you read this.
当您阅读本文时,上述补丁可能已合并。
After that imagemagick detected jpegs correctly again.
在那之后,imagemagick 再次正确检测到 jpeg。
TL;DR completely uninstall and reinstall homebrew, ghostscript (with patch for Lion), and imagemagick
TL;DR 完全卸载并重新安装自制软件、ghostscript(带有 Lion 补丁)和 imagemagick
回答by Philip
I got it working by installing brew, http://mxcl.github.com/homebrew/
我通过安装 brew 使其工作,http://mxcl.github.com/homebrew/
And then i typed:
然后我输入:
brew install imagemagick
and after that
在那之后
gem install rmagick
Then I just deleted the option paths (Paperclip.options[:command_path] = "...") that I typed in manually in environment/development.rb and initialize/paperclip.rb
然后我只是删除了我在 environment/development.rb 和 initialize/paperclip.rb 中手动输入的选项路径 (Paperclip.options[:command_path] = "...")
Added rmagick to gem file. Restarted the server and it worked like a charm!
将 rmagick 添加到 gem 文件中。重新启动服务器,它就像一个魅力!
回答by Les Freeman
This worked fromhttp://arglebargle.posterous.com/path-environment-variable-for-rails-using-pas
这来自http://arglebargle.posterous.com/path-environment-variable-for-rails-using-pas
Put something like this in the VirtualHost (or wherever passenger is set up):
把这样的东西放在 VirtualHost(或任何设置乘客的地方):
SetEnv PATH /opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/mysql/bin
回答by sunkil
To add one more potential solution that I haven't seen discussed much: ldconfig.
添加一个我还没有看到太多讨论的潜在解决方案:ldconfig.
I had the same problem that I just spent a day and a half tracking down. I properly reinstalled ImageMagick from source with the additional png and jpeg support, I added LD_LIBRARY_PATHand DYLD_LIBRARY_PATHto the environment variables, I set the :command_pathoption for Paperclip in my production environment config. Although the ImageMagick commands worked from the command line, nothing fixed my Paperclip problem.
我遇到了同样的问题,我只花了一天半的时间进行追踪。我使用额外的 png 和 jpeg 支持从源代码正确地重新安装了 ImageMagick,我添加了LD_LIBRARY_PATH和DYLD_LIBRARY_PATH到环境变量,我:command_path在我的生产环境配置中设置了Paperclip 选项。尽管 ImageMagick 命令从命令行工作,但没有解决我的 Paperclip 问题。
Finally after seeing ldconfigmentioned in passing, I tried that on a whim, and it worked.
最后看到ldconfig顺便提到的,我一时兴起尝试了,它奏效了。
sudo ldconfig
I may have been able to accomplish the same thing by restarting apache or the hardware, but I wasn't in a position to do that on my own.
我可能能够通过重新启动 apache 或硬件来完成同样的事情,但我无法独自完成。
回答by Ninjaxor
You will also get this error message if you try to upload a file that contains colons in it's name as of the latest version.
如果您尝试上传最新版本名称中包含冒号的文件,您也会收到此错误消息。
回答by 0x4a6f4672
Usually it helps to specify the path to the identify command with..
通常它有助于指定识别命令的路径..
Paperclip.options[:command_path] = "/your/path/to/identify"
..as the others mentioned. But the problem can also occur if there is a version mismatch, I recently updated the Ruby-on-Rails Version of an application (to Rails 3.1.10), but forgot to update the paperclip gem. After I updated the paperclip version to 2.8.0 it worked again.
..正如其他人提到的。但是如果版本不匹配也会出现这个问题,我最近更新了一个应用程序的 Ruby-on-Rails 版本(到 Rails 3.1.10),但忘记更新回形针 gem。在我将回形针版本更新到 2.8.0 后,它再次运行。
回答by edhamilton812
If you're a mac user and this has only been a problem since updating your OS to 10.8 then it could be an X11 issue, as outlined here http://support.apple.com/kb/HT5293
如果您是 mac 用户,并且自从将您的操作系统更新到 10.8 以来这只是一个问题,那么它可能是 X11 问题,如此处所述http://support.apple.com/kb/HT5293
identify ~/path/to/image
识别 ~/path/to/image
Was not working for me even after trying all the above fixes. I installed XQuartz from http://xquartz.macosforge.org/landing/and now it is working again.
即使在尝试了上述所有修复之后,也对我不起作用。我从http://xquartz.macosforge.org/landing/安装了 XQuartz ,现在它又可以工作了。
May help others out too...
也可以帮助别人...

