这是由于回形针宝石中的错误造成的lib/paperclip/command_line.rb
file.
def full_path(binary)
[self.class.path, binary].compact.join("/")
end
The full_path
函数生成带有反斜杠的命令文件名。
"C:\Program Files\ImageMagick-6.7.0-Q16"/identify
此命令在 Windows 上失败,因为cmd
当命令文件是长文件名带有反斜杠。
有两种方法可以解决此问题。
Use the 短文件名作为命令路径。
Paperclip.options[:command_path] = 'C:/PROGRA~1/IMAGEM~1.0-Q'
Note:可以通过如下方式获取短文件名:
dir /x "C:\Program Files*"
dir /x "C:\Program Files\ImageMagick-6.7.0-Q16*"
猴子修补回形针宝石config\initializers\paperclip.rb
.
我在2.3.11上测试过这个。
class Paperclip::CommandLine
def full_path(binary)
[self.class.path, binary].compact.join(File::ALT_SEPARATOR||File::SEPARATOR)
end
end
现在identify
命令是使用正确的路径分隔符生成的。
"C:\Program Files\ImageMagick-6.7.0-Q16"\identify
我更喜欢第二种方法command_path
更容易配置。