1

I can't run fdisk on Cygwin, either outside or inside of the directory that contains it, despite confirming that:

  • fdisk.exe exists inside of /sbin, via both the command line and Windows Explorer

  • C:\cygwin64;, C:\cygwin64\sbin; and C:\cygwin64\bin; are set in the PATH environment variable

enter image description here

Running which fdisk returns a "no fdisk in [PATH]" error, where [PATH] is the contents of my PATH environment variable.

What's going on here?

1

After some testing, it seems the problem in this case was that my computer needed to be restarted for the Windows PATH environment variable to be updated. I hadn't tried this because I assumed that this was the purpose of source ~/.bashrc, which I'd always used for similar purposes in the past.

It wasn't too much trouble for me personally to restart my computer, but I'd much prefer to have a command that prevents me from doing so, and I can see a required restart being very problematic for server users.

Looking into this deeper, it seems source ~/.bashrc is capable of doing this on UNIX-based systems, but the same doesn't apply to Cygwin, presumably because Cygwin uses the Windows PATH environment variable rather than setting them explicitly in .bashrc.

I've posted a follow-up question to this here.

  • In the past for updating my environmental variables, I have just killed all the Explorer.exe task in Task Manager, then from Task Manager's File -> New Task menu option, I run Explorer.exe again. This forces Windows to pick up the new variables for me. Never had any issues doing this in Windows 7, but YMMV – abelito Apr 7 '19 at 12:14
0

*NIX works differently than Windows.

You will need to type out the full path /sbin/fdisk

Or, while in the /sbin directory you need to type ./fdisk

Here is how you can learn about and modify the *NIX $path environment variable.

  • By default on cygwin /sbin/ is not on the path, as usually on most Unix. – matzeri Oct 23 '17 at 15:45
  • I'm aware *NIX systems work differently to Windows, but Cygwin also isn't your average *NIX system because of needing to run on Windows, and so also works a little differently to *NIX. The following page from the Cygwin documentation seems to state that Cygwin inherits Windows' environment variables, which would seem to contradict with what you're saying here. In addition, running which fdisk does seem to return my PATH fine, it just can't find fdisk inside of it. – Hashim Oct 23 '17 at 23:14
  • @Hashim try my answer it will work – Keltari Oct 24 '17 at 0:26
  • I'm aware that it works, because it's the full path to the executable, but typing that every time is annoying and cumbersome. The real issue here, which you seem to have overlooked, is that I'm not able to run fdisk as a standalone command like I am with every other command, and plastering over that problem by using the full path is a hacky solution, and not the one that I'm looking for. – Hashim Oct 24 '17 at 23:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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