[Mongrel] Win32 service - Errno::EINVAL (Invalid argument)whenuploading image file

Herryanto Siatono herryanto at gmail.com
Fri Apr 27 23:54:34 EDT 2007

Thanks Luis, btw, I found some hints, it failed when the 'puts' statement
was called. 

That's why the uploading of image failed, while other types are fine, when I
upload an image, I need to crop the image which instead call
Base64.b64encode, in which "puts" was called to display the output on

So I did a simple test, I added puts before the execution of anything, and
it failed exactly at that line:

  def with_image(file_data = nil, &block)
    puts "testing"

    img = Magick::Image::read_inline(Base64.b64encode(file_data ||
    img = nil

Error message thrown:

#{RAILS_ROOT}/app/models/asset.rb:115:in `write'
#{RAILS_ROOT}/app/models/asset.rb:115:in `puts'
#{RAILS_ROOT}/app/models/asset.rb:115:in `with_image'
#{RAILS_ROOT}/app/models/asset.rb:100:in `crop_image_size'

Now we are getting close, why puts failed when running as windows service?
Note that it works fine when I'm running with "mongrel_rails start"

And here are my answers to your questions. Thanks!

1) What plugin are you using to manage upload attachments? (since I
see you have a crop_image_size and with_image inside Asset model

I'm using rmagick-win32 with ImageMagick installed. Rmagick 1.13.0 and
ImageMagick 6.2.9-3 Q8.

I didn't use any plugin, I developed the file upload handling myself, with
some tricks learned from file_column and acts_as_attachment.

2) From the service command line, you have ruby installed in E:\Ruby.
Is this directory in your path? (Open a new console, type PATH and hit
enter, tell me if E:\Ruby is in there).

"E:\ruby\bin" is there.


PATH=E:\Program Files\Windows Resource Kits\Tools\;e:\program
em32\Wbem;C:\PROGRA~1\ULTRAE~1;C:\Program Files\Common Files\Adaptec
Shared\System;C:\Program Files\Microsoft SQL
bin;e:\Program Files\WinSCP3\;e:\Program Files\Subversion\bin;C:\Program
Files\QuickTime\QTSystem\;E:\Program Files\Support
1.0.2\bin\;e:\program files\xampp\mysql\bin;c:\php;c:\php-4.4.0;e:\program
files\svn-win32-1.3.1\bin;D:\rubywork\bin;E:\Program Files\Windows Resource

3) You also tested the service as "console", could you please indicate
the location of the temp file under that situation? C:\Windows\Temp do not
seems right for a process running with Administrator or any other account

Sorry my mistake Luis running service as "console", throwing this message

 "commit"=>"Upload file",

While running it as normal windows service, the temp directory is

4) Since you mention RMagick, are ImageMagick binaries in the path too?

Yep image magick is in the path. I can run 'convert' command.

More information about the Mongrel-users mailing list