File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -208,11 +208,23 @@ func runInitializeCommand(
208
208
return nil
209
209
}
210
210
211
+ shellArgs := []string {"sh" , "-c" }
212
+ // According to the devcontainer spec, `initializeCommand` needs to be run on the host.
213
+ // On Windows we can't assume everyone has `sh` added to their PATH so we need to use Windows default shell (usually cmd.exe)
214
+ if runtime .GOOS == "windows" {
215
+ comSpec := os .Getenv ("COMSPEC" )
216
+ if comSpec != "" {
217
+ shellArgs = []string {comSpec , "/c" }
218
+ } else {
219
+ shellArgs = []string {"cmd.exe" , "/c" }
220
+ }
221
+ }
222
+
211
223
for _ , cmd := range config .InitializeCommand {
212
224
// should run in shell?
213
225
var args []string
214
226
if len (cmd ) == 1 {
215
- args = []string {"sh" , "-c" , cmd [0 ]}
227
+ args = []string {shellArgs [ 0 ], shellArgs [ 1 ] , cmd [0 ]}
216
228
} else {
217
229
args = cmd
218
230
}
You can’t perform that action at this time.
0 commit comments