devcontainers / cli

A reference implementation for the specification that can create and configure a dev container from a devcontainer.json.
https://containers.dev
MIT License
1.37k stars 190 forks source link

Testing features not possible on Windows #757

Open gingters opened 4 months ago

gingters commented 4 months ago

I am trying to build a feature, and I failed. So I wrote a test to see what failed. However, when trying to execute my test, I get this error:

πŸš€ Launched container.
>  containerId:          765681ff36037ff597185005ba19c57bd1db92eccda9bbd6127d536fd97c6c2e

πŸƒ Starting test(s)...

πŸ§ͺ Starting 'oh-my-posh' tests...
Error: Exectuable 'chmod' not found on PATH 'C:\Program Files\PowerShell\7;C:\Program Files\Microsoft SDKs\Azure\CLI2\wbin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;...'.
    at EF (C:\Users\SebastianGingter\AppData\Roaming\npm\node_modules\@devcontainers\cli\dist\spec-node\devContainersSpecCLI.js:150:4280)
    at async Object.exec (C:\Users\SebastianGingter\AppData\Roaming\npm\node_modules\@devcontainers\cli\dist\spec-node\devContainersSpecCLI.js:150:1655)
    at async W0 (C:\Users\SebastianGingter\AppData\Roaming\npm\node_modules\@devcontainers\cli\dist\spec-node\devContainersSpecCLI.js:591:83)
    at async WtA (C:\Users\SebastianGingter\AppData\Roaming\npm\node_modules\@devcontainers\cli\dist\spec-node\devContainersSpecCLI.js:572:678)
    at async jtA (C:\Users\SebastianGingter\AppData\Roaming\npm\node_modules\@devcontainers\cli\dist\spec-node\devContainersSpecCLI.js:572:197)
    at async $H (C:\Users\SebastianGingter\AppData\Roaming\npm\node_modules\@devcontainers\cli\dist\spec-node\devContainersSpecCLI.js:567:190)
    at async AiA (C:\Users\SebastianGingter\AppData\Roaming\npm\node_modules\@devcontainers\cli\dist\spec-node\devContainersSpecCLI.js:591:4218)
    at async C:\Users\SebastianGingter\AppData\Roaming\npm\node_modules\@devcontainers\cli\dist\spec-node\devContainersSpecCLI.js:591:3506 {
  code: 'ENOENT'
}

It seems, the execTest method in testCommandImpl.ts hardcodes a call to chmod, which is executed on the cliHost. In my case this is Windows, which does not have a chmod.

See https://github.com/devcontainers/cli/blob/2a6ab1ac82f4917654205e2a9b1ac928260d902e/src/spec-node/featuresCLI/testCommandImpl.ts#L596

There's another cliHost.exec() call to chmod in line 539: https://github.com/devcontainers/cli/blob/2a6ab1ac82f4917654205e2a9b1ac928260d902e/src/spec-node/featuresCLI/testCommandImpl.ts#L539

Maybe the chmod should be done in the container, and not on the host?

samruddhikhandale commented 4 months ago

Hi πŸ‘‹

Thanks for reporting, it definitely looks like a bug.

In the meanwhile, @gingters can you work within a dev container? I believe that's how most of the community runs Feature tests, hence, this wasn't reported until now.

samruddhikhandale commented 4 months ago

//cc @joshspicer for visibility

joshspicer commented 4 months ago

Thanks for reporting. In the meantime, i'd also suggest using WSL if possible to run the CLI.