Eugleo / magic-racket

The best coding experience for Racket in VS Code
https://marketplace.visualstudio.com/items?itemName=evzen-wybitul.magic-racket
GNU General Public License v3.0
202 stars 28 forks source link

Racket Executable Path not compatible with Git Bash terminal in Windows #36

Closed LeoTheMighty closed 3 years ago

LeoTheMighty commented 3 years ago

Environment

Error message

Launching server using command /c/Program\ Files/Racket/Racket.exe failed.

Reason

Basically, if you're using Git Bash as your primary terminal in VSCode, there's this error where you can either format the executable path to work for the Racket Language Client, or to work for the REPL integration, but not both. This is because Git Bash tries to make the syntax of the terminal as close to the UNIX version as possible. But because of this if you want it to work for the language server, you need to put the windows path like:

"magic-racket.general.racketPath": "C:\\Program Files\\Racket\\Racket.exe",

But to work for loading it into the REPL, you have to format it like this:

"magic-racket.general.racketPath": "/c/Program\\ Files/Racket/Racket.exe",

Suggested Solution

I think a good way to make this work is to just include a new Setting into the extension that basically allows you to specify a different Racket path for running on the REPL as opposed to communicating with the language server.

So for just a first pass, the usage might look like this:

"magic-racket.general.racketPath": "C:\\Program Files\\Racket\\Racket.exe",
"magic-racket.general.REPLRacketPath": "/c/Program\\ Files/Racket/Racket.exe",

This could be a pretty simple change in the codebase if you just include an option into the withRacket hook that you implemented.

export function withRacket(func: Function, repl: boolean = false) {
  const racketConfig = vscode.workspace.getConfiguration("magic-racket.general");
  const racket = (repl && racketConfig.get("REPLRacketPath")) || racketConfig.get("racketPath");
  if (racket !== "") {
    func(racket);
  } else {
    vscode.window.showErrorMessage(
      "No Racket executable specified. Please add the path to the Racket executable in settings",
    );
  }
}

Then, when you call it, when it opens in the REPL, just set that option to true (or false if it's more common to use REPL than to communicate with the language server.

withRacket(func, true);

Not the perfect solution, but it would at least give the option of using different paths.

Let me know what you think! ~ Leo