devcontainers / templates

Repository for Dev Container Templates that are managed by Dev Container spec maintainers. See https://github.com/devcontainers/template-starter to create your own!
https://containers.dev/templates
MIT License
1.02k stars 262 forks source link

postCreateCommand Permission denied #247

Open austinmw opened 8 months ago

austinmw commented 8 months ago
Running the postCreateCommand from devcontainer.json...

[7386 ms] Start: Run in container: /bin/sh -c ./.devcontainer/postCreateCommand.sh
The virtual environment found in /workspaces/peloton-virtual-coach/.venv seems to be broken.
Recreating virtualenv peloton-virtual-coach in /workspaces/peloton-virtual-coach/.venv

[Errno 13] Permission denied: 'extensions.cpython-311.pyc'
[7955 ms] postCreateCommand failed with exit code 1. Skipping any further user-provided commands.
Done. Press any key to close the terminal.

I have the following:

devcontainer.json:

// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
    "name": "peloton-virtual-coach",
    // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
    "image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye",
    "features": {
        "ghcr.io/devcontainers-contrib/features/poetry:2": {}
    },

    // Use 'postCreateCommand' to run commands after the container is created.
    "postCreateCommand": "./.devcontainer/postCreateCommand.sh",

    // Configure tool-specific properties.
    "customizations": {
        "vscode": {
            "extensions": [
                "ms-python.python",
                "editorconfig.editorconfig",
            ],
            "settings": {
                "python.testing.pytestArgs": ["tests"],
                "python.testing.unittestEnabled": false,
                "python.testing.pytestEnabled": true,
                "python.defaultInterpreterPath": "/workspaces/peloton-virtual-coach/.venv/bin/python",
                "python.testing.pytestPath": "/workspaces/peloton-virtual-coach/.venv/bin/pytest"
            }
        }
    }
}

postCreateCommand.sh:

#! /usr/bin/env bash

# Install Dependencies
poetry install --with dev
samruddhikhandale commented 8 months ago

Hi 👋

I wasn't able to reproduce the issue, see 👇

Image

Can you point me to a sample repository so that I can repro for myself?

Looking at the creation logs, the virtualenv used by your dev container and mine is different. Hence, looks like I have some missing config?

Creating virtualenv my-project-iOXQ9y55-py3.11 in /home/vscode/.cache/pypoetry/virtualenvs Recreating virtualenv peloton-virtual-coach in /workspaces/peloton-virtual-coach/.venv

The virtual environment found in /workspaces/peloton-virtual-coach/.venv seems to be broken.

Also, in your case it complaints about ^

Makoehle commented 6 months ago

I had the same problem. The solution was to to change:

{
  "postCreateCommand": "./postCreate",
}

to

{
  "postCreateCommand": "chmod +x ./postCreate && ./postCreate",
}