From 4ec9bb566ce3c73ba850ec157d65fc1ace2dab6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Str=C3=B6mberg?= Date: Sat, 1 May 2021 07:54:07 -0800 Subject: [PATCH 1/5] Write deps.edn win jack-in command line to a file Then execute that file Fixes #1162 --- src/nrepl/jack-in.ts | 7 +++++++ src/nrepl/project-types.ts | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/nrepl/jack-in.ts b/src/nrepl/jack-in.ts index 3ccba0583..b6327446c 100644 --- a/src/nrepl/jack-in.ts +++ b/src/nrepl/jack-in.ts @@ -162,6 +162,13 @@ async function getJackInTerminalOptions(projectConnectSequence: ReplConnectSeque } executable = cmd[0]; args = [...cmd.slice(1), ...args]; + if (projectTypes.isWin && projectType.resolveBundledPathWin) { + const cmdFile = path.join('.calva', 'start.cmd'); + const cmdFileUri = vscode.Uri.file(path.join(state.getProjectRootLocal(), '.calva', 'start.cmd')) + utilities.writeTextToFile(cmdFileUri, createCommandLine(executable, args)) + executable = cmdFile; + args = []; + } const terminalOptions: JackInTerminalOptions = { name: `Calva Jack-in: ${projectConnectSequence.name}`, diff --git a/src/nrepl/project-types.ts b/src/nrepl/project-types.ts index 9e98c92e9..abbfc7455 100644 --- a/src/nrepl/project-types.ts +++ b/src/nrepl/project-types.ts @@ -251,7 +251,7 @@ const cljsMiddleware: { [id: string]: string[] } = { const serverPrinterDependencies = pprint.getServerSidePrinterDependencies(); function depsCljWindowsPath() { - return `"${path.join('.', '.calva', 'deps.clj.jar')}"`; + return `${path.join('.', '.calva', 'deps.clj.jar')}`; } const projectTypes: { [id: string]: ProjectType } = { @@ -368,7 +368,7 @@ const projectTypes: { [id: string]: ProjectType } = { resolveBundledPathWin: depsCljWindowsPath, resolveBundledPathUnix: () => `'${path.join(state.extensionContext.extensionPath, 'deps.clj.jar')}'`, processShellUnix: true, - processShellWin: true, + processShellWin: false, useWhenExists: undefined, nReplPortFile: [".nrepl-port"], commandLine: async (connectSequence: ReplConnectSequence, cljsType: CljsTypes) => { @@ -458,7 +458,7 @@ async function cljCommandLine(connectSequence: ReplConnectSequence, cljsType: Cl if (selectedAliasesHasMain) { args.push(aliasesOption); } else { - args.push(aliasesOption, "-m", "nrepl.cmdline", "--middleware", `"[${useMiddleware.join(' ')}]"`); + args.push(aliasesOption, "-m", "nrepl.cmdline", "--middleware", `${q}[${useMiddleware.join(' ')}]${q}`); } return args; From 563716434ecc583f491c221ab780aea991f6bfb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Str=C3=B6mberg?= Date: Sat, 1 May 2021 08:04:37 -0800 Subject: [PATCH 2/5] Use jack-in.cmd for file name --- src/nrepl/jack-in.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nrepl/jack-in.ts b/src/nrepl/jack-in.ts index b6327446c..85018d91f 100644 --- a/src/nrepl/jack-in.ts +++ b/src/nrepl/jack-in.ts @@ -163,8 +163,8 @@ async function getJackInTerminalOptions(projectConnectSequence: ReplConnectSeque executable = cmd[0]; args = [...cmd.slice(1), ...args]; if (projectTypes.isWin && projectType.resolveBundledPathWin) { - const cmdFile = path.join('.calva', 'start.cmd'); - const cmdFileUri = vscode.Uri.file(path.join(state.getProjectRootLocal(), '.calva', 'start.cmd')) + const cmdFile = path.join('.calva', 'jack-in.cmd'); + const cmdFileUri = vscode.Uri.file(path.join(state.getProjectRootLocal(), '.calva', 'jack-in.cmd')) utilities.writeTextToFile(cmdFileUri, createCommandLine(executable, args)) executable = cmdFile; args = []; From 514800ae58b1ecfe835492b0c5a8ef57deccea57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Str=C3=B6mberg?= Date: Sat, 1 May 2021 08:07:30 -0800 Subject: [PATCH 3/5] Await the writing of the file --- src/nrepl/jack-in.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nrepl/jack-in.ts b/src/nrepl/jack-in.ts index 85018d91f..3ab223e30 100644 --- a/src/nrepl/jack-in.ts +++ b/src/nrepl/jack-in.ts @@ -165,7 +165,7 @@ async function getJackInTerminalOptions(projectConnectSequence: ReplConnectSeque if (projectTypes.isWin && projectType.resolveBundledPathWin) { const cmdFile = path.join('.calva', 'jack-in.cmd'); const cmdFileUri = vscode.Uri.file(path.join(state.getProjectRootLocal(), '.calva', 'jack-in.cmd')) - utilities.writeTextToFile(cmdFileUri, createCommandLine(executable, args)) + await utilities.writeTextToFile(cmdFileUri, createCommandLine(executable, args)) executable = cmdFile; args = []; } From 076d5d2f3644c5804f1dfad4d1ab88295b233fa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Str=C3=B6mberg?= Date: Sat, 1 May 2021 11:43:05 -0800 Subject: [PATCH 4/5] Stop deps.edn win quoting all together --- src/nrepl/jack-in.ts | 7 ------- src/nrepl/project-types.ts | 4 ++-- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/nrepl/jack-in.ts b/src/nrepl/jack-in.ts index 3ab223e30..3ccba0583 100644 --- a/src/nrepl/jack-in.ts +++ b/src/nrepl/jack-in.ts @@ -162,13 +162,6 @@ async function getJackInTerminalOptions(projectConnectSequence: ReplConnectSeque } executable = cmd[0]; args = [...cmd.slice(1), ...args]; - if (projectTypes.isWin && projectType.resolveBundledPathWin) { - const cmdFile = path.join('.calva', 'jack-in.cmd'); - const cmdFileUri = vscode.Uri.file(path.join(state.getProjectRootLocal(), '.calva', 'jack-in.cmd')) - await utilities.writeTextToFile(cmdFileUri, createCommandLine(executable, args)) - executable = cmdFile; - args = []; - } const terminalOptions: JackInTerminalOptions = { name: `Calva Jack-in: ${projectConnectSequence.name}`, diff --git a/src/nrepl/project-types.ts b/src/nrepl/project-types.ts index abbfc7455..c89f98f82 100644 --- a/src/nrepl/project-types.ts +++ b/src/nrepl/project-types.ts @@ -448,8 +448,8 @@ async function cljCommandLine(connectSequence: ReplConnectSequence, cljsType: Cl }; const useMiddleware = [...middleware, ...(cljsType ? cljsMiddleware[cljsType] : [])]; const aliasesOption = aliases.length > 0 ? `-A${aliases.join("")}` : ''; - const q = isWin ? '"' : "'"; - const dQ = isWin ? '""' : '"'; + const q = isWin ? '' : "'"; + const dQ = '"'; for (let dep in dependencies) out.push(dep + ` {:mvn/version,${dQ}${dependencies[dep]}${dQ}}`) From 1cec422dfa8e75d1597ff806ed6b9a4ec5a30d62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Str=C3=B6mberg?= Date: Sat, 1 May 2021 21:50:30 +0200 Subject: [PATCH 5/5] Update changelog [skip ci] --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c97a7386..c61c0fe4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Changes to Calva. ## [Unreleased] - Update cider-nrepl to [0.26.0](https://github.com/clojure-emacs/cider-nrepl/releases/tag/v0.26.0) +- Fix [Getting Started Repl not working on some Windows machines](https://github.com/BetterThanTomorrow/calva/issues/1162) ## [2.0.194] - 2021-04-26 - [Make Clojure-lsp Server Info command always enabled](https://github.com/BetterThanTomorrow/calva/issues/1143)