Skip to content

Commit 7bbf5cf

Browse files
fix(vscode-desktop-core): enhance logging for extension installation process with detailed output for troubleshooting
1 parent c5a76ab commit 7bbf5cf

File tree

1 file changed

+18
-3
lines changed
  • registry/coder/modules/vscode-desktop-core

1 file changed

+18
-3
lines changed

registry/coder/modules/vscode-desktop-core/run.sh

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,15 @@ download_and_install_extension() {
8787
fi
8888

8989
printf "$${BOLD}📦 Installing extension $${CODE}$extension_id$${RESET}...\n"
90+
echo "$(date): Starting installation of $extension_id" >> "$log_file"
9091

9192
# Use dedicated temp directory for this extension
9293
local extension_temp_dir
9394
extension_temp_dir="$temp_dir/$extension_id-$(date +%s)"
9495
local download_file="$temp_dir/$extension_id.vsix"
9596

9697
# First, get the metadata JSON
98+
echo "$(date): Fetching metadata from $metadata_url" >> "$log_file"
9799
local metadata_response
98100
if metadata_response=$(timeout 30 curl -fsSL "$metadata_url" 2>&1); then
99101
# Extract the download URL from JSON (handle both VS Code and Open VSX)
@@ -107,10 +109,14 @@ download_and_install_extension() {
107109
fi
108110

109111
if [[ -n "$download_url" && "$download_url" != "null" ]]; then
112+
echo "$(date): Extracted download URL: $download_url" >> "$log_file"
110113
# Download the actual .vsix file
114+
echo "$(date): Downloading extension to $download_file" >> "$log_file"
111115
if timeout 30 curl -fsSL "$download_url" -o "$download_file" 2>&1; then
112-
# Verify the download is a valid file
113-
if file "$download_file" 2> /dev/null | grep -q "Zip archive"; then
116+
echo "$(date): File size: $(stat -c%s "$download_file") bytes" >> "$log_file"
117+
# Verify the download is a valid ZIP file
118+
echo "$(date): Validating ZIP file..." >> "$log_file"
119+
if unzip -t "$download_file" > /dev/null 2>&1; then
114120
# Create target directory
115121
mkdir -p "$target_dir"
116122
local extract_dir="$target_dir/$extension_id"
@@ -123,6 +129,7 @@ download_and_install_extension() {
123129
mkdir -p "$extract_dir"
124130

125131
# Extract extension
132+
echo "$(date): Extracting to $extract_dir" >> "$log_file"
126133
if unzip -q "$download_file" -d "$extract_dir" 2> /dev/null; then
127134
if [ -f "$extract_dir/package.json" ]; then
128135
printf "$${GREEN}✅ Successfully installed $${CODE}$extension_id$${RESET}\n"
@@ -146,7 +153,11 @@ download_and_install_extension() {
146153
fi
147154
else
148155
printf "$${RED}❌ Invalid file format$${RESET}\n"
149-
echo "$(date): Invalid file format for $extension_id" >> "$log_file"
156+
{
157+
echo "$(date): ZIP validation failed for $extension_id"
158+
echo "$(date): File size: $(stat -c%s "$download_file") bytes"
159+
echo "$(date): First 100 bytes: $(head -c 100 "$download_file" | hexdump -C | head -3)"
160+
} >> "$log_file"
150161
rm -rf "$extension_temp_dir"
151162
return 1
152163
fi
@@ -182,6 +193,7 @@ install_extension_from_url() {
182193
local extension_id="$extension_name"
183194

184195
printf "$${BOLD}📦 Installing extension from URL: $${CODE}$extension_name$${RESET}...\n"
196+
echo "$(date): Starting installation of $extension_id from URL: $url" >> "$log_file"
185197

186198
if [[ -d "$target_dir/$extension_id" ]] && [[ -f "$target_dir/$extension_id/package.json" ]]; then
187199
printf "$${GREEN}✓ Extension $${CODE}$extension_id$${RESET}$${GREEN} already installed$${RESET}\n"
@@ -193,7 +205,9 @@ install_extension_from_url() {
193205
extension_temp_dir="$temp_dir/$extension_id-$(date +%s)"
194206
local download_file="$temp_dir/$extension_id.vsix"
195207

208+
echo "$(date): Downloading extension to $download_file" >> "$log_file"
196209
if timeout 30 curl -fsSL "$url" -o "$download_file" 2>&1; then
210+
echo "$(date): File size: $(stat -c%s "$download_file") bytes" >> "$log_file"
197211
# Create target directory
198212
mkdir -p "$target_dir"
199213
local extract_dir="$target_dir/$extension_id"
@@ -205,6 +219,7 @@ install_extension_from_url() {
205219

206220
mkdir -p "$extract_dir"
207221

222+
echo "$(date): Extracting to $extract_dir" >> "$log_file"
208223
if unzip -q "$download_file" -d "$extract_dir" 2> /dev/null; then
209224
if [ -f "$extract_dir/package.json" ]; then
210225
printf "$${GREEN}✅ Successfully installed $${CODE}$extension_id$${RESET}\n"

0 commit comments

Comments
 (0)