@@ -76,10 +76,11 @@ 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.
79
82
const hasCoderLogs = ( parsedVersion ?. compare ( "2.3.3" ) || 0 ) >= 0 || parsedVersion ?. prerelease [ 0 ] === "devel"
80
83
81
- console . log ( "hasCoderLogs" , hasCoderLogs )
82
-
83
84
// Find the workspace from the URI scheme provided!
84
85
try {
85
86
this . storage . workspace = await getWorkspaceByOwnerAndName ( parts [ 0 ] , parts [ 1 ] )
@@ -429,14 +430,15 @@ export class Remote {
429
430
//
430
431
// If we didn't write to the SSH config file, connecting would fail with
431
432
// "Host not found".
432
- await this . updateSSHConfig ( authorityParts [ 1 ] )
433
+ await this . updateSSHConfig ( authorityParts [ 1 ] , hasCoderLogs )
433
434
434
435
this . findSSHProcessID ( ) . then ( ( pid ) => {
435
436
if ( ! pid ) {
436
437
// TODO: Show an error here!
437
438
return
438
439
}
439
440
disposables . push ( this . showNetworkUpdates ( pid ) )
441
+ this . storage . workspaceLogPath = path . join ( this . storage . getLogPath ( ) , `${ pid } .log` )
440
442
} )
441
443
442
444
// Register the label formatter again because SSH overrides it!
@@ -459,7 +461,7 @@ export class Remote {
459
461
460
462
// updateSSHConfig updates the SSH configuration with a wildcard that handles
461
463
// all Coder entries.
462
- private async updateSSHConfig ( hostName : string ) {
464
+ private async updateSSHConfig ( hostName : string , hasCoderLogs = false ) {
463
465
let deploymentSSHConfig = defaultSSHConfigResponse
464
466
try {
465
467
const deploymentConfig = await getDeploymentSSHConfig ( )
@@ -487,21 +489,24 @@ export class Remote {
487
489
// Now override with the user's config.
488
490
const userConfigSSH = vscode . workspace . getConfiguration ( "coder" ) . get < string [ ] > ( "sshConfig" ) || [ ]
489
491
// Parse the user's config into a Record<string, string>.
490
- const userConfig = userConfigSSH . reduce ( ( acc , line ) => {
491
- let i = line . indexOf ( "=" )
492
- if ( i === - 1 ) {
493
- i = line . indexOf ( " " )
492
+ const userConfig = userConfigSSH . reduce (
493
+ ( acc , line ) => {
494
+ let i = line . indexOf ( "=" )
494
495
if ( i === - 1 ) {
495
- // This line is malformed. The setting is incorrect, and does not match
496
- // the pattern regex in the settings schema.
497
- return acc
496
+ i = line . indexOf ( " " )
497
+ if ( i === - 1 ) {
498
+ // This line is malformed. The setting is incorrect, and does not match
499
+ // the pattern regex in the settings schema.
500
+ return acc
501
+ }
498
502
}
499
- }
500
- const key = line . slice ( 0 , i )
501
- const value = line . slice ( i + 1 )
502
- acc [ key ] = value
503
- return acc
504
- } , { } as Record < string , string > )
503
+ const key = line . slice ( 0 , i )
504
+ const value = line . slice ( i + 1 )
505
+ acc [ key ] = value
506
+ return acc
507
+ } ,
508
+ { } as Record < string , string > ,
509
+ )
505
510
const sshConfigOverrides = mergeSSHConfigValues ( deploymentSSHConfig , userConfig )
506
511
507
512
let sshConfigFile = vscode . workspace . getConfiguration ( ) . get < string > ( "remote.SSH.configFile" )
@@ -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