@@ -12,6 +12,7 @@ import * as semver from "semver"
12
12
import * as vscode from "vscode"
13
13
import { makeCoderSdk , startWorkspace , waitForBuild } from "./api"
14
14
import { extractAgents } from "./api-helper"
15
+ import * as cli from "./cliManager"
15
16
import { Commands } from "./commands"
16
17
import { getHeaderCommand } from "./headers"
17
18
import { SSHConfig , SSHValues , mergeSSHConfigValues } from "./sshConfig"
@@ -541,11 +542,28 @@ export class Remote {
541
542
}
542
543
}
543
544
545
+ /**
546
+ * Tries to get the install CLI version. If that fails, defaults
547
+ * to the remote coder version. For the most part these should be in sync.
548
+ */
549
+ private async probableCoderVersion ( binaryPath : string ) : Promise < semver . SemVer | null > {
550
+ try {
551
+ const version = await cli . version ( binaryPath )
552
+ const parsedVersion = semver . parse ( version )
553
+ if ( ! parsedVersion ) {
554
+ return this . coderVersion
555
+ }
556
+ return parsedVersion
557
+ } catch ( e ) {
558
+ return this . coderVersion
559
+ }
560
+ }
561
+
544
562
/**
545
563
* Format's the --log-dir argument for the ProxyCommand
546
564
*/
547
- private async formatLogArg ( ) : Promise < string > {
548
- if ( ! supportsCoderAgentLogDirFlag ( this . coderVersion ) ) {
565
+ private async formatLogArg ( binpath : string ) : Promise < string > {
566
+ if ( ! supportsCoderAgentLogDirFlag ( await this . probableCoderVersion ( binpath ) ) ) {
549
567
return ""
550
568
}
551
569
@@ -659,7 +677,7 @@ export class Remote {
659
677
Host : label ? `${ AuthorityPrefix } .${ label } --*` : `${ AuthorityPrefix } --*` ,
660
678
ProxyCommand : `${ escape ( binaryPath ) } ${ headerArg } vscodessh --network-info-dir ${ escape (
661
679
this . storage . getNetworkInfoPath ( ) ,
662
- ) } ${ await this . formatLogArg ( ) } --session-token-file ${ escape ( this . storage . getSessionTokenPath ( label ) ) } --url-file ${ escape (
680
+ ) } ${ await this . formatLogArg ( binaryPath ) } --session-token-file ${ escape ( this . storage . getSessionTokenPath ( label ) ) } --url-file ${ escape (
663
681
this . storage . getUrlPath ( label ) ,
664
682
) } %h`,
665
683
ConnectTimeout : "0" ,
0 commit comments