cmd cannot execute file inside of /cygdrive/c/

0

I am running a Ruby on Rails application - inside the app there is a Ruby Gem I've loaded which determines the location of an executable file called pngcrush. The way it does this is that it runs the command which pngcrush, which returns /cygdrive/c/Windows/system32/pngcrush. However when the gem tries to issue the command using a system call `/cygdrive/c/Windows/system32/pngcrush somefile.jpg newfile.jpg` it fails. It seems that it can FIND the file but not execute it, perhaps because it's being executed within cmd and not bash.

i.e., Within cmd I type: /cygdrive/c/Windows/system32/pngcrush and I get The system cannot find the path specified. When in cmd I type bash, then within bash I type the same thing, it works. I cannot modify the Gem as it's authored by someone else.

JakeTheSnake

Posted 2014-09-03T18:30:57.683

Reputation: 133

how about c:\Windows\system32\pngcrush somefile.jpg newfile.jpg ? Also in cygwin try to CD into the directory and then do ls and see it's there then do ./pngcrush somefile.jpg newfile.jpg – barlop – 2014-09-03T19:42:42.703

also include a screenshot and try not to mix cygwin syntax with cmd syntax. e.g. cmd uses \ cygwin uses /. cygwin uses /cygdrive/c cmd uses c:\ And try going into the directory with CD first. Then just running c:\windows\system32>pngcrush a.jpg b.jpg – barlop – 2014-09-03T19:44:55.543

Answers

0

I think a program like ruby does not take paths like this /cygdrive/c/windows/, rather it would have its own environment, try to figure out what its environment is and then try to execute some other command and print its path, you should understand how it is calling other programs.

J Bourne

Posted 2014-09-03T18:30:57.683

Reputation: 68

The cygwin version of ruby would be perfectly happy with the /cygdrive/ paths. If the OP is trying to mix and match cygwin and non-cygwin binaries he is going to have a lot of pain. – Zoredache – 2014-09-03T20:05:14.813

I think perhaps this is my problem. I run my Rails apps through Windows' Service Manager, which runs ruby from the C: installation (native). Where would I find the cygwin installation of Ruby (once I download it)? Is it slower than a native installation? – JakeTheSnake – 2014-09-03T21:42:17.420

As I suspected, Rails executes the system call using the native command prompt based on ruby.exe's current environment; in this case, Windows. So it uses cmd.exe to try the command: /cygdrive/c/... However forward slashes just don't jive with cmd and it got confused. This is because of mixed environments. The which command runs under cygwin and returns paths that cygwin can handle, but not cmd. I had to update the Gem and luckily the author is still active. – JakeTheSnake – 2014-09-04T02:58:39.860

Cool, so is the problem solved? Were you able to print path? – J Bourne – 2014-09-04T04:01:18.790

I had to modify the Gem to really get what I want. Trying to fiddle with my cygwin installation seemed like a much more significant problem to solve. – JakeTheSnake – 2014-09-12T00:28:10.793

1

Install the cygwin version of pngcrush instead of, or in addition to the Windows version of pngcrush. The cygwin version should function properly.

Zoredache

Posted 2014-09-03T18:30:57.683

Reputation: 18 453