coder / coder/registry

coder-server extension should wait in the the project folder exists

Open
#57 3 comments 0 reactions 0 assignees View on GitHub
good first issue
Dominant language
HCL
Stars
79
Forks
161
Avg merge
1d 10h
Merged PRs (30d)
38

Description

In some cases `auto_install_extensions` won't if the workspace has not been checkout yet.

Ideally coder should provide a method to wait on a dependent task from completing.

A work around is to poll for the folder to be created before running the install like so.

```bash
if [ "${AUTO_INSTALL_EXTENSIONS}" = true ]; then
if ! command -v jq > /dev/null; then
echo "jq is required to install extensions from a workspace file."
exit 0
fi

WORKSPACE_DIR="$HOME"
if [ -n "${FOLDER}" ]; then
WORKSPACE_DIR="${FOLDER}"
fi

TIMEOUT=10
INTERVAL=1
ELAPSED=0
while [ $ELAPSED -lt $TIMEOUT ]; do
if [ -d "$WORKSPACE_DIR" ]; then
echo "Directory $WORKSPACE_DIR exists."
break
fi
sleep $INTERVAL
ELAPSED=$((ELAPSED + INTERVAL))
done

if [ -f "$WORKSPACE_DIR/.vscode/extensions.json" ]; then
printf "🧩 Installing extensions from %s/.vscode/extensions.json...\n" "$WORKSPACE_DIR"
extensions=$(jq -r '.recommendations[]' "$WORKSPACE_DIR"/.vscode/extensions.json)
for extension in $extensions; do
if extension_installed "$extension"; then
continue
fi
$CODE_SERVER "$EXTENSION_ARG" --force --install-extension "$extension"
done
fi
fi
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.