2

Why show the directory in explorer command does not work in git bash?

When I type simply

start

at the MINGW64 Cygwin prompt on Windows, it displays:

/usr/bin/start: line 8: cmd: command not found
Josiah Yoder
  • 3,321
  • 4
  • 40
  • 58
  • I got a similar error, only missing the cmd in the output: `/usr/bin/start: line 8: : command not found`. This was when I had checked the experimental "don't need to use winpty" feature when installing Git for Windows. – Josiah Yoder Sep 22 '22 at 16:06

3 Answers3

6

Even though it shouldn't be necessary, try the following:

/c/Windows/System32/cmd.exe //c 'start .'

start is a command that is internal to cmd.exe, so it must be invoked with cmd /c (and Git Bash apparently requires doubling / chars. to be recognized as cmd-style option-prefix characters).

However, there is a shell-script wrapper for it - /usr/bin/start - which does this for you.

In your case, this shell script unexpectedly complains about not finding cmd, even though /c/WINDOWS/system32 should be in your $PATH environment variable by default - do check that variable and see if it's being modified unexpectedly somewhere.

$PATH is initially defined in /etc/profile, but can be overridden / modified in ~/.bash_profile, for instance.

/etc/profile also contains helpful links in comments:

# Some resources...
# Customizing Your Shell: http://www.dsl.org/cookbook/cookbook_5.html#SEC69
# Consistent BackSpace and Delete Configuration:
#   http://www.ibb.net/~anne/keyboard.html
# The Linux Documentation Project: http://www.tldp.org/
# The Linux Cookbook: http://www.tldp.org/LDP/linuxcookbook/html/
# Greg's Wiki http://mywiki.wooledge.org/
mklement0
  • 382,024
  • 64
  • 607
  • 775
1

The git installer adds C:\Program Files\Git\cmd to Window's PATH environment variable.

In some PC configurations, this may not be sufficient for all git execution commands to run. For example, I faced the situation where git fetch executed fine, but git help fetch produced the error /usr/bin/start: line 8: cmd not found

Following #mklement0's advice, after adding C\Windows\System32 to Window's PATH environment variable, then all git commands executed for me without error.

Try appending ;C\Windows\System32 to your Window's PATH environment variable as follows:

  • Open Windows Explorer, right-click on your Computer icon, and select 'Properies'. The System Control Panel opens. Window Explorer
  • Select the 'Advanced system setting' link on the left panel. The System Properties window opens. System Control Panel
  • Select the 'Environment Variables...' button at the bottom of the window. The Environment Variables window opens. System Properties
  • The lower panel is the 'System variables' section. In this section, scroll down and select 'Path'. Then, click on the 'Edit...' button. A small window opens where you can edit the Path variable. Path Environment Variable
  • While not forgetting the ; add the following to the end of the 'Variable value' text: ;C:\Windows\System32
tynanook
  • 11
  • 2
1

I had a similar problem because my path had %SystemRoot%\system32 included. It turns out that the env variable %SystemRoot% is not statically defined, but automatically included in the environment when starting cmd.exe or power shell. Since MINGW64's bash is neither, it just saw %SystemRoot%/system32 and could not traverse that to find cmd.exe.

Changing path to use C:\Windows\System32 cured this.

Mike F
  • 11
  • 1