devcontainers / devcontainers/cli
`devcontainer features test` and capturing errors during build
- Dominant language
- TypeScript
- Stars
- 3k
- Forks
- 457
- Avg merge
- 13h 17m
- Merged PRs (30d)
- 6
Description
Hello!
I'm having difficulty figuring out how `devcontainer features test` can capture errors that occur as part of the build. I'm working on a feature that will installed PowerShell resources, which has an obvious dependency on pwsh being installed.
I have this in the `install.sh`:
```
if command -v pwsh > /dev/null; then
echo "Confirmed PowerShell is installed"
else
echo "PowerShell is not installed. Please ensure it is installed before using this feature."
exit 127
fi
```
This causes an error during the container build (good), but I can't figure out a way to capture it via the test suite. (Not 100% sure it's even possible, since the build is erroring out).
```
#13 [dev_containers_target_stage 3/3] RUN cd /tmp/build-features/powershell-resource_1 && chmod +x ./devcontainer-features-install.sh && ./devcontainer-features-install.sh
[11807 ms] #13 0.231 ===========================================================================
#13 0.231 Feature : ./powershell-resource
#13 0.231 Description : A feature to install PowerShell resources (modules and scripts) via PowerShellGet 3.0 Prerelease for all users on a devcontainer.
#13 0.231 Id : Unknown
#13 0.231 Version : 0.1.0
#13 0.231 Documentation :
#13 0.231 Options :
#13 0.231
#13 0.231 ===========================================================================
#13 0.234 Feature 'powershell-resource' starting...
#13 0.234 PowerShell is not installed. Please ensure it is installed before using this feature.
#13 0.234 ERROR: Feature "./powershell-resource" (Unknown) failed to install!
#13 ERROR: executor failed running [/bin/sh -c cd /tmp/build-features/powershell-resource_1 && chmod +x ./devcontainer-features-install.sh && ./devcontainer-features-install.sh]: exit code: 127
------
> [dev_containers_target_stage 3/3] RUN cd /tmp/build-features/powershell-resource_1 && chmod +x ./devcontainer-features-install.sh && ./devcontainer-features-install.sh:
#13 0.231 Description : A feature to install PowerShell resources (modules and scripts) via PowerShellGet 3.0 Prerelease for all users on a devcontainer.
#13 0.231 Id : Unknown
#13 0.231 Version : 0.1.0
#13 0.231 Documentation :
#13 0.231 Options :
#13 0.231
#13 0.231 ===========================================================================
#13 0.234 Feature 'powershell-resource' starting...
#13 0.234 PowerShell is not installed. Please ensure it is installed before using this feature.
#13 0.234 ERROR: Feature "./powershell-resource" (Unknown) failed to install!
------
ERROR: failed to solve: executor failed running [/bin/sh -c cd /tmp/build-features/powershell-resource_1 && chmod +x ./devcontainer-features-install.sh && ./devcontainer-features-install.sh]: exit code: 127
[11814 ms] Exit code 1
[-] Failed to launch container:
Command failed: docker buildx build --load --build-context dev_containers_feature_content_source=/tmp/devcontainercli-runner/container-features/0.21.0-1666128532008 --build-arg _DEV_CONTAINERS_BASE_IMAGE=mcr.microsoft.com/devcontainers/base:ubuntu --build-arg _DEV_CONTAINERS_IMAGE_USER=root --build-arg _DEV_CONTAINERS_FEATURE_CONTENT_SOURCE=dev_container_feature_content_temp --target dev_containers_target_stage -t vsc-1666128531151-605d92cc5d16be5d5f0e80c97ea3221f-features -f /tmp/devcontainercli-runner/container-features/0.21.0-1666128532008/Dockerfile.extended /tmp/devcontainercli-runner/empty-folder
Error: Process completed with exit code 1.
```
Could someone please confirm if this is possible with the current state of the test suite or if this is a feature that will need to be added? Thanks!
Contributor guide
Assessment
This issue has not been assessed yet.