Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Windows 7 issue, 'type' is nil. Needs to be set to SENSIBLE_DEFAULT #1037

wants to merge 1 commit into from

3 participants


The type is not set to a valid value when the file command fails on windows. We catch most other instances of failure but miss this specific one. Very tiny code change.

Tested with Jruby 1.7.0 RC1, Windows 7.


What happens here that type is nil at that point? It should either return something from or it should return from the rescue block. How is this even possible? (I'm not saying you're wrong, I'm just really confused)


For some reason is returning nil. Which means that, arguments, local_options).run 

also returns nil.
I did step through this and there were no exceptions thrown which I guess is what is expected, however

output = self.class.send(:'`', command) 

returned nil. Inside this function we deferred to the super of Object and I was not able to trace any further to find out why it was returning nil like this. This fix just makes paperclip handle this specific situation, and is completely benign in other circumstances.

I also noticed that I got this message dumped to stdout (not in the logs)

c:\Programs64\jruby-1.7.0.RC1\bin\rake: No such file or directory - file

The file command is not available on Windows, and this is the underlying cause of the issue, however paperclip is expecting an exception on this file not found that doesn't happen on Windows 7 for some reason.

On a side note, there are also thread safety issues in 'with_modified_path' that Cocaine's run function uses, but this is off topic. I am running this inside a rake script, so it is single threaded for me and this is not the cause.


Well, that's disconcerting, since that shouldn't be returning nil, especially if the command doesn't exist. However, it appears to, so we should deal with it. This code doesn't have any tests, though. Could you add some?


I suspect any test that could be added would pass anyway with or without this fix on the test machine that Travis is using as I doubt it is windows 7. I did look at the tests and they seem not to run at all on my machine currently.

C:\Code\git.paperclip>bundle exec rake appraisal:install --trace
Unfortunately, a fatal error has occurred. Please see the Bundler
troubleshooting documentation at Thanks!
SystemCallError: Unknown error - No message available
        _exec_internal at org/jruby/
                  exec at file:/C:/Programs64/jruby-1.7.0.RC1/lib/jruby.jar!/jruby/kernel19/kernel.rb:23
                  exec at C:/Programs64/jruby-1.7.0.RC1/lib/ruby/gems/shared/gems/bundler-1.2.1/lib/bundler/cli.rb:428
              __send__ at org/jruby/
                  send at org/jruby/
                   run at C:/Programs64/jruby-1.7.0.RC1/lib/ruby/gems/shared/gems/bundler-1.2.1/lib/bundler/vendor/thor/task.rb:27
           invoke_task at C:/Programs64/jruby-1.7.0.RC1/lib/ruby/gems/shared/gems/bundler-1.2.1/lib/bundler/vendor/thor/invocation.rb:120
              dispatch at C:/Programs64/jruby-1.7.0.RC1/lib/ruby/gems/shared/gems/bundler-1.2.1/lib/bundler/vendor/thor.rb:275
                 start at C:/Programs64/jruby-1.7.0.RC1/lib/ruby/gems/shared/gems/bundler-1.2.1/lib/bundler/vendor/thor/base.rb:408
                (root) at C:/Programs64/jruby-1.7.0.RC1/lib/ruby/gems/shared/gems/bundler-1.2.1/bin/bundle:14
  with_friendly_errors at C:/Programs64/jruby-1.7.0.RC1/lib/ruby/gems/shared/gems/bundler-1.2.1/lib/bundler/friendly_errors.rb:4
                (root) at C:/Programs64/jruby-1.7.0.RC1/lib/ruby/gems/shared/gems/bundler-1.2.1/bin/bundle:14
                  load at org/jruby/
                (root) at C:\Programs64\jruby-1.7.0.RC1\bin\bundle:23

Any ideas?


I wrote a small test for the case when run returns nil, so this is covered. Thanks for reporting!

@jyurek jyurek closed this


I am using paperclip and jcrop and I am updating an application from rails 2.3.5 to 3.2. My system is windows XP and it seems I am getting a similar error that you are describing here. Here is the output
Command :: file -b --mime "C:/DOCUME~1/luis/LOCALS~1/Temp/9467d191-162e-0130-c89b-005056c0000820121121-2548-p6bj2n20121121-2548-h94jkj"
[paperclip] Error while determining content type: Cocaine::CommandNotFoundError

I have just update my system, so I have all the latest gems, including paperclip. Can you help me with thiis problem ?


@luisfernandos Please open a new issue for your problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 4, 2012
  1. @simonjsmithuk
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  lib/paperclip/content_type_detector.rb
2  lib/paperclip/content_type_detector.rb
@@ -57,7 +57,7 @@ def type_from_file_command
- if type.match(/\(.*?\)/)
+ if type.nil? || type.match(/\(.*?\)/)
Something went wrong with that request. Please try again.