0

Question

I'm trying to execute a command with the format {C:\...\executable} build {C:\...\executable} link. Here is the specific example I'm trying to execute. All it does is install a golang module which lets me debug in vs code.

C:\Program Files\Go\bin\go.exe build -o C:\Users\linds\go\bin\dlv-dap.exe github.com/go-delve/delve/cmd/dlv

The issue i'm having is that I don't know how to actually execute it. I've tried running it in powershell and bash but both come back and say that I cant run program with the form C:\....

How do I execute code with the following or similar formats?

~~

Sorry that my descriptions of the issue aren't the best because frankly I hardly know what I'm dealing with right here. I can clarify more if needed.

Gunty
  • 1,841
  • 1
  • 15
  • 27
  • You have a space after `Program`. In Powershell, this would run a program named C:Program with `Files\Go\bin\go.exe` as first argument. In bash, the whole line would be nonsense anyway, due to the backslashes. – user1934428 Dec 08 '21 at 07:12

1 Answers1

2

Since you're trying to invoke an executable whose path contains spaces, you must quote the path in order for a shell to recognize it as a single argument.

  • From PowerShell:
& 'C:\Program Files\Go\bin\go.exe' build -o C:\Users\linds\go\bin\dlv-dap.exe github.com/go-delve/delve/cmd/dlv

Note: &, the call operator, isn't always needed, but is needed whenever a command path is quoted and/or contains variable references - see this answer for details.

  • From cmd.exe:
"C:\Program Files\Go\bin\go.exe" build -o C:\Users\linds\go\bin\dlv-dap.exe github.com/go-delve/delve/cmd/dlv
mklement0
  • 382,024
  • 64
  • 607
  • 775