User Data Devcontainers do not appear to copy full folder, only devcontainer.json
Story
As a Devcontainer User, I want to specify updateContentCommand/etc. scripts separately from my json file, to get all the editor and intellisense benefits of that particular language
This works fine in a normal devcontainer but the files don't appear to be coppied from the user data dir to the VM, only the devcontainer.json gets copied it appears.
It is possible that they are copied to a "special" location I do not know about and not into the workspace itself for obvious git reasons, so I may need to define my paths more specifically and need guidance on that.
- VSCode Version: 1.99.3
- Local OS Version: Windows 11
- Remote OS Version: N/A
- Remote Extension/Connection Type: Dev Containers/WSL/Remote - Devcontainers
- Logs:
Running the updateContentCommand from devcontainer.json...
[8050 ms] Start: Run in container: /usr/bin/pwsh -nop -noni -f .devcontainer/scripts/2-updateContent.ps1
The argument '.devcontainer/scripts/2-updateContent.ps1' is not recognized as the name of a script file. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Usage: pwsh[.exe] [-Login] [[-File] <filePath> [args]]
[-Command { - | <script-block> [-args <arg-array>]
| <string> [<CommandParameters>] } ]
[-CommandWithArgs <string> [<CommandParameters>]
[-ConfigurationName <string>] [-ConfigurationFile <filePath>]
[-CustomPipeName <string>] [-EncodedCommand <Base64EncodedCommand>]
[-ExecutionPolicy <ExecutionPolicy>] [-InputFormat {Text | XML}]
[-Interactive] [-MTA] [-NoExit] [-NoLogo] [-NonInteractive] [-NoProfile]
[-NoProfileLoadTime] [-OutputFormat {Text | XML}]
[-SettingsFile <filePath>] [-SSHServerMode] [-STA]
[-Version] [-WindowStyle <style>]
[-WorkingDirectory <directoryPath>]
pwsh[.exe] -h | -Help | -? | /?
PowerShell Online Help https://aka.ms/powershell-docs
All parameters are case-insensitive.
[8737 ms] updateContentCommand from devcontainer.json failed with exit code 64. Skipping any further user-provided commands.
Steps to Reproduce:
- Create a User State Devcontainer
- Have a config that references external scripts in the updateContentCommand etc.
- This works fine in a repo-based devcontainer, but fails in a user data dir based devcontainer config.
Does this issue occur when you try this locally?: Ye Does this issue occur when you try this locally and all extensions are disabled?: Yes
The configuration is not copied, but the command runs with the workspace folder as its working directory. We currently don't have a variable for the configuration folder. I think the only way to make this work without additional support is with an absolute path to the script file.
This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 10 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.
Happy Coding!
@chrmarti I'm not sure how that would work in a devcontainer either, as say I'm doing a named map, the userdatadir would not be available in the container without an additional mount point being added.
You could add such a mount point yourself or maybe copy the scripts to the workspace folder in "initializeCommand".
That's a good point.
@chrmarti so initializeCommand isn't cross-platform so I can't do it reliably between Linux/Windows without a lot of boilerplate.
As a workaround, I used a Dockerfile build and copied the scripts into the built image
ADD ./scripts /devcontainer/scripts
And then updated my devcontainer config to reference these now image-local scripts:
"onCreateCommand": ["/usr/bin/pwsh", "-nop", "-noni", "-f", "/devcontainer/scripts/1-onCreate.ps1"],
"updateContentCommand": ["/usr/bin/pwsh", "-nop", "-noni", "-f", "/devcontainer/scripts/2-updateContent.ps1"],
// These lifecycle scripts are non-blocking to loading the codespace and UI by default
"postCreateCommand": ["/usr/bin/pwsh", "-nop", "-noni", "-f", "/devcontainer/scripts/3-postCreate.ps1"],
"postStartCommand": ["/usr/bin/pwsh", "-nop", "-noni", "-f", "/devcontainer/scripts/4-postStart.ps1"],
"postAttachCommand": ["/usr/bin/pwsh", "-nop", "-noni", "-f", "/devcontainer/scripts/5-postAttach.ps1"],
Everything is now working as expected in a cross-platform way.
I would still like to see this made easier for doing override configs, but this is a sufficient workaround ATM.
This feature request has not yet received the 10 community upvotes it takes to make to our backlog. 10 days to go. To learn more about how we handle feature requests, please see our documentation.
Happy Coding
:slightly_frowning_face: In the last 60 days, this feature request has received less than 10 community upvotes and we closed it. Still a big Thank You to you for taking the time to create this issue! To learn more about how we handle feature requests, please see our documentation.
Happy Coding!