@@ -171,9 +171,14 @@ func configSSH() *cobra.Command {
171
171
return xerrors .Errorf ("read ssh config failed: %w" , err )
172
172
}
173
173
174
+ coderConfigExists := true
174
175
coderConfigRaw , err := os .ReadFile (coderConfigFile )
175
- if err != nil && ! errors .Is (err , fs .ErrNotExist ) {
176
- return xerrors .Errorf ("read ssh config failed: %w" , err )
176
+ if err != nil {
177
+ if errors .Is (err , fs .ErrNotExist ) {
178
+ coderConfigExists = false
179
+ } else {
180
+ return xerrors .Errorf ("read ssh config failed: %w" , err )
181
+ }
177
182
}
178
183
if len (coderConfigRaw ) > 0 {
179
184
if ! bytes .HasPrefix (coderConfigRaw , []byte (sshCoderConfigHeader )) {
@@ -182,8 +187,9 @@ func configSSH() *cobra.Command {
182
187
}
183
188
lastCoderConfig := sshCoderConfigParseLastOptions (bytes .NewReader (coderConfigRaw ), coderConfig .sshConfigDefaultFile )
184
189
185
- // Avoid prompting in diff mode (unexpected behavior).
186
- if ! showDiff && ! coderConfig .equal (lastCoderConfig ) {
190
+ // Avoid prompting in diff mode (unexpected behavior)
191
+ // or when a previous config does not exist.
192
+ if ! showDiff && ! coderConfig .equal (lastCoderConfig ) && coderConfigExists {
187
193
newOpts := coderConfig .asList ()
188
194
newOptsMsg := "\n \n New options: none"
189
195
if len (newOpts ) > 0 {
0 commit comments