@@ -76,6 +76,10 @@ export class Remote {
76
76
await this . closeRemote ( )
77
77
return
78
78
}
79
+ // CLI versions before 2.3.3 don't support the --log-dir flag!
80
+ // If this check didn't exist, VS Code connections would fail on
81
+ // older versions because of an unknown CLI argument.
82
+ const hasCoderLogs = ( parsedVersion ?. compare ( "2.3.3" ) || 0 ) >= 0 || parsedVersion ?. prerelease [ 0 ] === "devel"
79
83
80
84
// Find the workspace from the URI scheme provided!
81
85
try {
@@ -426,14 +430,15 @@ export class Remote {
426
430
//
427
431
// If we didn't write to the SSH config file, connecting would fail with
428
432
// "Host not found".
429
- await this . updateSSHConfig ( authorityParts [ 1 ] )
433
+ await this . updateSSHConfig ( authorityParts [ 1 ] , hasCoderLogs )
430
434
431
435
this . findSSHProcessID ( ) . then ( ( pid ) => {
432
436
if ( ! pid ) {
433
437
// TODO: Show an error here!
434
438
return
435
439
}
436
440
disposables . push ( this . showNetworkUpdates ( pid ) )
441
+ this . storage . workspaceLogPath = path . join ( this . storage . getLogPath ( ) , `${ pid } .log` )
437
442
} )
438
443
439
444
// Register the label formatter again because SSH overrides it!
@@ -456,7 +461,7 @@ export class Remote {
456
461
457
462
// updateSSHConfig updates the SSH configuration with a wildcard that handles
458
463
// all Coder entries.
459
- private async updateSSHConfig ( hostName : string ) {
464
+ private async updateSSHConfig ( hostName : string , hasCoderLogs = false ) {
460
465
let deploymentSSHConfig = defaultSSHConfigResponse
461
466
try {
462
467
const deploymentConfig = await getDeploymentSSHConfig ( )
@@ -542,12 +547,16 @@ export class Remote {
542
547
if ( typeof headerCommand === "string" && headerCommand . trim ( ) . length > 0 ) {
543
548
headerArg = ` --header-command ${ escape ( headerCommand ) } `
544
549
}
545
-
550
+ let logArg = ""
551
+ if ( hasCoderLogs ) {
552
+ await fs . mkdir ( this . storage . getLogPath ( ) , { recursive : true } )
553
+ logArg = ` --log-dir ${ escape ( this . storage . getLogPath ( ) ) } `
554
+ }
546
555
const sshValues : SSHValues = {
547
556
Host : `${ Remote . Prefix } *` ,
548
557
ProxyCommand : `${ escape ( binaryPath ) } ${ headerArg } vscodessh --network-info-dir ${ escape (
549
558
this . storage . getNetworkInfoPath ( ) ,
550
- ) } --session-token-file ${ escape ( this . storage . getSessionTokenPath ( ) ) } --url-file ${ escape (
559
+ ) } ${ logArg } --session-token-file ${ escape ( this . storage . getSessionTokenPath ( ) ) } --url-file ${ escape (
551
560
this . storage . getURLPath ( ) ,
552
561
) } %h`,
553
562
ConnectTimeout : "0" ,
0 commit comments