Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow cross-platform/per system initializeCommand definition #347

Open
Destroy666x opened this issue Dec 4, 2023 · 5 comments
Open

Allow cross-platform/per system initializeCommand definition #347

Destroy666x opened this issue Dec 4, 2023 · 5 comments

Comments

@Destroy666x
Copy link

Destroy666x commented Dec 4, 2023

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).

@bamurtaugh
Copy link
Member

Thanks for filing! I believe this would also be related to (and potentially covered by) #58, #405.

@Destroy666x
Copy link
Author

Potentially indeed - assuming "features"/"things" include initiaizeCommand. If yes - looking forwards to that.

@MangelMaxime
Copy link

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.

@marystory
Copy link

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.

@Bombay268
Copy link

Bombay268 commented Jun 28, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants