You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When opening my repo in CodeSpaces, I'm getting a Permission denied error after invoking a bash script to run using postCreateCommand.
My overarching goal is to not have to manually type commands every time after the container has started, to build the Python Package (I want this to be able to run tests in the CodeSpaces terminal with pytest, and also have all the dependencies installed):
The commands I have to type out on every new instance of CodeSpace are:
{
"name": "Python 3",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/python:1-3.12-bookworm",
"features": {
// "ghcr.io/jsburckhardt/devcontainer-features/ruff:1": {},
"ghcr.io/va-h/devcontainers-features/uv:1": {}
// "ghcr.io/hspaans/devcontainer-features/pytest:1": {},
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "./.devcontainer/postCreateCommand.sh",
// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"github.copilot",
"charliermarsh.ruff",
"github.vscode-github-actions",
"ms-python.vscode-pylance"
]
}
},
}
Could you confirm that your script file is marked as executable?
You can do that by running chmod +x .devcontainer/postCreateCommand.sh on the script file, committing that change into your repo, and then try creating a new codespace.
Thanks @joshspicer - where in the repo would I put chmod +x .devcontainer/postCreateCommand.sh? Maybe as a onCreateCommand or updateContentCommand before the postCreateCommand (ref)?
I actually tried what you said and it worked... the venv myenv has been created.
I didn't expect that running chmod +x .devcontainer/postCreateCommand.sh interactively would persist in code to the next CodeSpaces session.
Although myenv has been created; the source command has been used to activate the venv; and the packages have been installed with uv pip install -e ., when I access the bash terminal in CodeSpaces, the venv myenv is not activated in the session. I have to then type source myenv/bin/activate
I thought the bash script already activated it? Is there a separate way to get some commands to run for the bash terminal to activate the venv automatically?
When opening my repo in CodeSpaces, I'm getting a
Permission denied
error after invoking a bash script to run usingpostCreateCommand
.My overarching goal is to not have to manually type commands every time after the container has started, to build the Python Package (I want this to be able to run tests in the CodeSpaces terminal with
pytest
, and also have all the dependencies installed):The commands I have to type out on every new instance of CodeSpace are:
My
pyproject.toml
looks like:And my
.devcontainer.json
like:And
/.devcontainer/postCreateCommand.sh
, like:And the code spaces creation log:
The text was updated successfully, but these errors were encountered: