Rake Package Task Fails with Status 127 on Windows

,

The other day, I tried running a Rake Package task on a Windows system. Rake aborted with “Command failed with status (127): [zip -r Module.zip Module…]“. What could be the problem?

Status code 127 is commonly used to indicate “command not found.” The error message’s bracketed portion indicates that Rake attempted to run an executable named “zip,” passing to it several arguments. By default, Windows systems do not include a command named zip. Hence, the error.

To fix this problem, configure Rake::PackageTask to use an alternative zip command by setting its zip_command property. In the example below, notice the inner quotes surrounding the path to the command. These were necessitated by the space in “Program Files.”

Rake::PackageTask.new('Module', :noversion) do |p|
  p.need_zip = true
  p.zip_command = '"C:\Program Files\7-Zip\7z.exe" a -tzip'
  p.package_files.include(..)
end

Rake::PackageTask also provides a tar_command property which can be used to override the command used to gzip and bzip2 archives.

Leave a Reply

Your email address will not be published. Required fields are marked *