I can't use command "start" in git bash

52 Views Asked by At

When I type "start" to open up a .txt file, it returns /usr/bin/start: line 8: No such file or directory

I guess it returns my whole path but idk.

I have tried adding C:\Windows\System32 to path but it doesn't work.

1

There are 1 best solutions below

5
Keith Thompson On BEST ANSWER

In git bash, /usr/bin/start is a shell script that invokes "$COMSPEC" //c start "${@//&/^&}". If invoked with a .txt file as an argument. You can examine the file itself; it's an 8-line text file.

It's specific to git bash under Windows. It's a way to provide the equivalent of the cmd.exe START command, or double-clicking on a Windows icon, in a Unix-like environment. (Cygwin and WSL, which are also Unix-like environments under Windows, don't provide the same thing; Cygwin has cygstart, and WSL is more isolated from the Windows environment.)

If you invoke it as start foo.txt, it should invoke your default handler for *.txt files, determined by your Windows settings. That might be Notepad by default, but perhaps you've configured it to be some other editor.

Try echo "$COMSPEC". The result should be C:\WINDOWS\system32\cmd.exe. The /usr/bin/start script seems to be complaining that the command that $COMSPEC expands to does not exist; either $COMSPEC has been changed, or C:\WINDOWS\system32\cmd.exe is unavailable (the latter could indicate a damaged Windows system).

If you type "$COMSPEC" (with the double quotes) at the git bash prompt, it should give you a Windows cmd prompt; if so, you can leave it by typing exit.

$ type -a start
start is /usr/bin/start
start is /bin/start
start is /usr/bin/start
$ cat /usr/bin/start
#!/usr/bin/env bash
# Copyright (C) 2014, Alexey Pavlov
#   mailto:[email protected]
# This file is part of Minimal SYStem version 2.
#   https://sourceforge.net/p/msys2/wiki/MSYS2%20installation/
# File: start

"$COMSPEC" //c start "${@//&/^&}"
$ echo "$COMSPEC"
C:\WINDOWS\system32\cmd.exe
$ "$COMSPEC"
Microsoft Windows [Version 10.0.22631.3155]
(c) Microsoft Corporation. All rights reserved.

C:\Users\username>exit
exit
$