-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
DevContainer Fails Due to .env Conflicts #3105
Comments
@palisadoes I believe this is a better alternative. If you agree, please assign me. |
|
Some people are having this issue with node v18. I didn't with node v22. Can you check? Reopening |
Yes sure |
Here is the link to another person discovering this: |
@palisadoes, I would like to know if you are using linux based system? I was also using node v22, it is not the problem. |
It depends on your Linux shell and distro. I'm using kubuntu. We absolutely don't want to overwrite a preexisting .env file without a user prompt and having a user prompt makes the process non-transparent. You need to find a flag equivalent to -n that works on all operating systems, possibly -- no-clobber |
What does the |
What does alias provide when your shell is |
jaipannu@Jais-MacBook-Air talawa-api % alias On bash: (No output) Jais-MacBook-Air:talawa-api jaipannu$ alias On sh: (No output) Since there was no default alias set for cp, I even tried both interactive and verbose mode, still we have the same error while running script on already made env. Clarification:
|
@palisadoes, Apologies for the confusion. I went through the complete updated installation process and have 2 major observations.
Now to fix "initializeCommand", we have two approaches
But since macOS utilizes BSD cp, which does not support --update=none as confirmed in the official documentation: I can definitively confirm that: Here’s a reference screenshot for further clarity: I believe we can develop a better alternative with your guidance. Please tell me how you want to proceed from here so that I can work in that direction. |
Does this work in MacOS?
|
@palisadoes I think proposed solution
should work with all OS and also clearly states that developer should adhere to pre-built env, why are we looking for another one? |
This doesn't make sense. All the man pages state that the Other questions.
|
|
When working with the DevContainer setup for Talawa API, there is an issue with how the .env file is handled during build and startup.
Currently, when we run:
devcontainer build --workspace-folder .
we must manually copy the .env file using:
cp envFiles/.env.devcontainer .env
to ensure the build succeeds.
However, after the build, when running:
devcontainer up --workspace-folder .
it fails because .env already exists, requiring manual deletion before each run.
Similarly, attempting to open the DevContainer in VS Code also fails due to the same .env file conflict.
Steps to reproduce the issue:
cp envFiles/.env.devcontainer .env
devcontainer build --workspace-folder .
devcontainer up --workspace-folder .
Expected Behavior
Actual Behavior
Proposed Fix
Update .devcontainer/devcontainer.json to properly handle .env file creation and avoid manual deletion.
Replace the current initializeCommand:
"initializeCommand": "cp -n ./envFiles/.env.devcontainer ./.env"
With the new command to always overwrite .env:
"initializeCommand": "/bin/sh -c 'cp -f ./envFiles/.env.devcontainer ./.env && echo \"Overwritten .env\"'"
Why This Fix?
Prevents DevContainer failures → .env is always available.
Screenshot
Additional Details
This fix will improve the DevContainer workflow, preventing unnecessary manual steps and making development more efficient.
The text was updated successfully, but these errors were encountered: