Allow cross-platform/per system initializeCommand definition
Not sure if it's the most proper repo to report this (if not, please redirect), but would be nice if there was a way to define initializeCommand per system in any way, so that the setup is truly cross-system. For example:
"initializeCommand": {
"windows": "rd /s /q somedir",
"linux": "rm -rf somedir",
"macos": "..."
}
Use case example: https://stackoverflow.com/questions/77199011/how-to-create-a-cross-platform-initializecommand-for-visual-studio-codes-dev-co (copying proper .env file before container launch).
Thanks for filing! I believe this would also be related to (and potentially covered by) https://github.com/devcontainers/spec/issues/58, https://github.com/devcontainers/spec/issues/405.
Potentially indeed - assuming "features"/"things" include initiaizeCommand. If yes - looking forwards to that.
This is indeed something required because depending on the host OS, different commands are needed to prepare the container to run.
In my case, I want to mount the .npmrc from the host system to avoid having to re-login every time I open a container. However, if a machine doesn't have the .npmrc file the mounts will fails.
// It seems that if the .npmrc file is not present, then the container can't
// be open. To not force, contributor to have an NPM account,
// we create a dummy .npmrc file if it doesn't exist
"initializeCommand": "if [ ! -f ~/.npmrc ]; then touch ~/.npmrc; fi",
"mounts": [
// Mount .npmrc from the host machine, to be able to use the host session
// This allow the user to login on their own machine once and not each time
// they build a new devcontainer
"source=${localEnv:HOME}${localEnv:USERPROFILE}/. ,target=/home/vscode/.npmrc,type=bind,consistency=cached"
],
I need to support both scenario to make my life easier as a maintainer but also not force contributor to have an NPM account.
Being able to set up OS-specific InitializeCommand is definitely something I need as well.
Is there a way to choose the shell for executing InitializeCommand? It seems that on Mac, it runs with bash, while on Windows, it runs with PowerShell.
Steve Bombardier
Le ven. 28 juin 2024, 14 h 37, Maryam.to @.***> a écrit :
Being able to set up OS-specific InitializeCommand is definitely something I need as well.
Is there a way to choose the shell for executing InitializeCommand? It seems that on Mac, it runs with bash, while on Windows, it runs with PowerShell.
— Reply to this email directly, view it on GitHub https://github.com/devcontainers/spec/issues/347#issuecomment-2197442843, or unsubscribe https://github.com/notifications/unsubscribe-auth/A7XISKS6HUR7TWPT7PVN45DZJWUNNAVCNFSM6AAAAABAFPEFIKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJXGQ2DEOBUGM . You are receiving this because you are subscribed to this thread.Message ID: @.***>
https://github.com/microsoft/vscode-remote-release/issues/3007#issuecomment-1942968611
That's a nice workaround that works with all types of commands. However, Mac and Linux separation could be needed at times and it'd be a lot more convoluted with those.
For a true cross-system repository, consider a monorepo
For a true cross-system repository, consider a monorepo
How does that solve anything?? A monorepo is just a repo with multiple projects in it that share some base. Here we want to share a devcontainer configuration between platforms, which has nothing to do with a monorepo.