Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm having a weird issue with cygwin acting inconsistently between installations, specifically scp. I have c:\cygwin\bin in my Windows PATH in both cases. When I run the following command from a Windows Command Prompt, however, I get very different results between the two installations:

scp /cygdrive/c/something.txt User@server:${HOME}/something.txt

On the one machine it transfers the file just fine, but on the other machine I get an error:

/cygdrive/c/something.txt: No such file or directory

However, if I execute the command this way on the machine that gave me the error, it transfers just fine:

scp /c/something.txt User@server:${HOME}/something.txt

Why the differences? Is there something I need to configure within cygwin to make this work with /cygdrive/c?

UPDATE: Here's something more interesting. If I do ls /c from a Windows command prompt I get what you would expect, as list of everything in C:. However, ls /cygdrive/c says that it doesn't exist. Running those commands from the cygwin bash yields exactly the opposite behavior.

share|improve this question

migrated from stackoverflow.com Jun 2 '11 at 0:35

This question came from our site for professional and enthusiast programmers.

add comment

3 Answers

I encountered this problem after I installed Git, added it's bin to my PATH, then installed Cygwin and ran ssh-host-config to setup a Windows service for sshd. The problem seems to be that the way ssh-host-config registers the service causes sshd to invoke Git's bash (or scp, or ssh-provided command) executable rather than Cygwin's in the process of setting up an scp connection. To fix this, I removed the service as installed by ssh-host-config. From Cygwin bash, I executed cygrunsrv -R sshd. Then I re-registered the service with a PATH variable override,

cygrunsrv -I sshd -d "CYGWIN sshd" -p "/usr/sbin/sshd" \
  --env "PATH=/usr/bin:/bin:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:$PATH" \
  -a "-D" -u <priv_user> -w <password>

where priv_user is probably cyg_server. See http://cygwin.com/ml/cygwin/2005-05/msg00012.html .

share|improve this answer
add comment

The correct way to do this is using the mount command:

mount --change-cygdrive-prefix /c

or in your case, restore the default /cygdrive prefix...

share|improve this answer
    
Do you know if this is a default setting added in a newer version of cygwin? –  Matt Baker Sep 28 '10 at 21:50
    
it actually defaults to /cygdrive unless you manually change it (at least that's the way it was the last time I checked). You know there's nothing stopping you from having both (add an entry to /etc/fstab as explained in the documentation) –  Amro Sep 28 '10 at 21:57
    
Hmm. That's what's weird, this is a clean install of cygwin and I didn't change any of the options. –  Matt Baker Sep 28 '10 at 22:13
add comment

The problem was my PATH precedence. It was

PATH=%PATH%;C:\cygwin\bin

but it needed to be

PATH=C:\cygwin\bin;%PATH%

After fixing the PATH /cygdrive/c resolved as expected.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.