Skip to content

Commit bce6811

Browse files
committed
docs: add coder workspace update scripts and guide
1 parent 5bafcbe commit bce6811

3 files changed

Lines changed: 465 additions & 0 deletions

File tree

CODER_UPDATE_INSTRUCTIONS.md

Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
# Coder Workspace Update Instructions
2+
3+
## Problem
4+
5+
`/home/vscode/.claude.json` is a directory instead of a file, causing:
6+
7+
```
8+
Error: EISDIR: illegal operation on a directory, open '/home/vscode/.claude.json'
9+
```
10+
11+
## Solution
12+
13+
Your workspace needs to be rebuilt with the updated Coder template (PR #442).
14+
15+
---
16+
17+
## ✅ Permanent Fix - Option 1: Automated Script
18+
19+
### Step 1: Copy the script to dev-server
20+
21+
```bash
22+
# On your Mac
23+
scp update-coder-template.sh dev-server:~/
24+
```
25+
26+
### Step 2: Run the script on dev-server
27+
28+
```bash
29+
# SSH to dev-server
30+
ssh dev-server
31+
32+
# Run the update script
33+
bash ~/update-coder-template.sh
34+
```
35+
36+
The script will:
37+
38+
- ✅ Pull latest changes from develop (includes PR #442)
39+
- ✅ Update the Coder template
40+
- ✅ Guide you through rebuilding your workspace
41+
- ✅ Preserve all your code and settings
42+
43+
---
44+
45+
## ✅ Permanent Fix - Option 2: Manual Steps
46+
47+
### Step 1: SSH to dev-server
48+
49+
```bash
50+
ssh dev-server
51+
```
52+
53+
### Step 2: Update the repository
54+
55+
```bash
56+
cd /home/coder/workspaces/$(whoami)/SimpleAccounts-UAE
57+
git fetch origin develop
58+
git checkout develop
59+
git pull origin develop
60+
```
61+
62+
### Step 3: Update Coder template
63+
64+
```bash
65+
cd .coder
66+
coder templates push
67+
```
68+
69+
You should see output like:
70+
71+
```
72+
✓ Template pushed successfully!
73+
```
74+
75+
### Step 4: Find your workspace name
76+
77+
```bash
78+
coder list
79+
```
80+
81+
Example output:
82+
83+
```
84+
NAME STATUS LAST BUILT
85+
MohsinHashmi-DataInn Running 2h ago
86+
```
87+
88+
### Step 5: Rebuild your workspace
89+
90+
```bash
91+
# Replace with your actual workspace name from step 4
92+
WORKSPACE_NAME="MohsinHashmi-DataInn"
93+
94+
# Stop workspace
95+
coder stop $WORKSPACE_NAME
96+
97+
# Delete workspace (your code is safe in /home/coder/workspaces/)
98+
coder delete $WORKSPACE_NAME --force
99+
100+
# Recreate with new template
101+
coder create $WORKSPACE_NAME
102+
```
103+
104+
### Step 6: Verify the fix
105+
106+
```bash
107+
# Connect to your new workspace
108+
coder ssh $WORKSPACE_NAME
109+
110+
# Check .claude.json is now a FILE (not directory)
111+
ls -la /home/vscode/.claude.json
112+
# Should show: -rw-r--r-- (file, not drwxr-xr-x)
113+
114+
# Verify contents
115+
cat /home/vscode/.claude.json
116+
# Should show: {}
117+
118+
# Check .claude directory exists
119+
ls -la /home/vscode/.claude/
120+
# Should be a directory
121+
122+
# Test Claude CLI
123+
claude
124+
# Should work without EISDIR error!
125+
```
126+
127+
---
128+
129+
## 🔍 Verify Host-Side Files Were Created
130+
131+
```bash
132+
# On dev-server, check host directories
133+
ls -la /home/coder/.coder-mount/$(whoami)/claude/
134+
135+
# Should show:
136+
# -rw-r--r-- .claude.json (file)
137+
# drwxr-xr-x .claude/ (directory)
138+
```
139+
140+
---
141+
142+
## 📋 What Got Fixed
143+
144+
The updated template (PR #442) includes:
145+
146+
1. **Host Directory Provisioner** (`null_resource.host_directories`)
147+
- Creates directories on host BEFORE container starts
148+
- Initializes `.claude.json` with `{}`
149+
- Sets proper ownership
150+
151+
2. **Correct Volume Mounts**
152+
153+
```terraform
154+
# File mount
155+
/home/coder/.coder-mount/<user>/claude/.claude.json
156+
→ /home/vscode/.claude.json
157+
158+
# Directory mount
159+
/home/coder/.coder-mount/<user>/claude/.claude
160+
→ /home/vscode/.claude/
161+
```
162+
163+
3. **Permission Fixing**
164+
- Startup script fixes ownership for both files and directories
165+
- Uses `-e` test instead of `-d` to handle both types
166+
167+
---
168+
169+
## ⚠️ Temporary Fix (Not Recommended)
170+
171+
If you can't rebuild now, you can temporarily fix it in the devcontainer:
172+
173+
```bash
174+
# In devcontainer
175+
sudo rm -rf /home/vscode/.claude.json
176+
echo '{}' | sudo tee /home/vscode/.claude.json > /dev/null
177+
sudo chown vscode:vscode /home/vscode/.claude.json
178+
179+
# Test
180+
claude
181+
```
182+
183+
**Note:** This will be lost when the container restarts!
184+
185+
---
186+
187+
## ❓ Troubleshooting
188+
189+
### "Template push failed"
190+
191+
```bash
192+
cd /home/coder/workspaces/$(whoami)/SimpleAccounts-UAE/.coder
193+
coder templates push --verbose
194+
```
195+
196+
### "Workspace not found"
197+
198+
```bash
199+
coder list
200+
# Use exact name from output
201+
```
202+
203+
### "Permission denied"
204+
205+
```bash
206+
# Ensure you're on dev-server as your user
207+
whoami
208+
# Should match your Coder username
209+
```
210+
211+
### Still getting EISDIR after rebuild
212+
213+
```bash
214+
# Check mounts in container
215+
mount | grep claude
216+
217+
# Check if file/directory types are correct
218+
ls -ld /home/vscode/.claude.json # Should be: -rw-r--r-- (file)
219+
ls -ld /home/vscode/.claude # Should be: drwxr-xr-x (dir)
220+
```
221+
222+
---
223+
224+
## 📞 Need Help?
225+
226+
If you encounter issues:
227+
228+
1. Check the diagnostic output: `bash diagnose-mounts.sh`
229+
2. Verify template was updated: `git log -1 /home/coder/workspaces/$(whoami)/SimpleAccounts-UAE/.coder/template.tf`
230+
3. Check Coder logs: `coder logs <workspace-name>`

diagnose-mounts.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/bash
2+
# Diagnostic script to check Claude mount issue
3+
4+
echo "================================"
5+
echo "🔍 Claude Mount Diagnostics"
6+
echo "================================"
7+
echo ""
8+
9+
echo "1️⃣ Checking /home/vscode/.claude.json"
10+
echo " Type: $(if [ -f /home/vscode/.claude.json ]; then echo 'FILE ✅'; elif [ -d /home/vscode/.claude.json ]; then echo 'DIRECTORY ❌ (WRONG!)'; else echo 'DOES NOT EXIST ❌'; fi)"
11+
if [ -e /home/vscode/.claude.json ]; then
12+
echo " Permissions: $(ls -ld /home/vscode/.claude.json)"
13+
fi
14+
echo ""
15+
16+
echo "2️⃣ Checking /home/vscode/.claude/"
17+
echo " Type: $(if [ -d /home/vscode/.claude ]; then echo 'DIRECTORY ✅'; elif [ -f /home/vscode/.claude ]; then echo 'FILE ❌ (WRONG!)'; else echo 'DOES NOT EXIST ❌'; fi)"
18+
if [ -e /home/vscode/.claude ]; then
19+
echo " Permissions: $(ls -ld /home/vscode/.claude)"
20+
if [ -d /home/vscode/.claude ]; then
21+
echo " Contents: $(ls -la /home/vscode/.claude 2>/dev/null | wc -l) items"
22+
fi
23+
fi
24+
echo ""
25+
26+
echo "3️⃣ Checking mount points"
27+
mount | grep -E "\.claude" || echo " No claude mounts found"
28+
echo ""
29+
30+
echo "4️⃣ Host paths (if accessible)"
31+
if [ -d "/home/coder/.coder-mount" ]; then
32+
echo " Host mount base exists: ✅"
33+
USER_DIR=$(ls -d /home/coder/.coder-mount/*/ 2>/dev/null | head -1)
34+
if [ -n "$USER_DIR" ]; then
35+
echo " User directory: $USER_DIR"
36+
if [ -d "${USER_DIR}claude" ]; then
37+
echo " Claude host dir: ✅"
38+
ls -la "${USER_DIR}claude/" 2>/dev/null
39+
else
40+
echo " Claude host dir: ❌ MISSING"
41+
fi
42+
fi
43+
else
44+
echo " Host mount not accessible from container (expected)"
45+
fi
46+
echo ""
47+
48+
echo "5️⃣ Current user"
49+
echo " User: $(whoami)"
50+
echo " UID: $(id -u)"
51+
echo " GID: $(id -g)"
52+
echo ""
53+
54+
echo "================================"
55+
echo "🔧 Recommended Fix"
56+
echo "================================"
57+
if [ -d /home/vscode/.claude.json ]; then
58+
echo "❌ .claude.json is a DIRECTORY (should be FILE)"
59+
echo ""
60+
echo "This means the workspace is using the OLD template."
61+
echo ""
62+
echo "To fix:"
63+
echo "1. Stop the Coder workspace"
64+
echo "2. Update the Coder template: coder templates push"
65+
echo "3. Rebuild the workspace: coder start <workspace-name>"
66+
echo ""
67+
echo "OR manually fix (temporary):"
68+
echo "sudo rm -rf /home/vscode/.claude.json"
69+
echo "touch /home/vscode/.claude.json"
70+
echo "echo '{}' > /home/vscode/.claude.json"
71+
echo "sudo chown vscode:vscode /home/vscode/.claude.json"
72+
fi
73+
echo "================================"

0 commit comments

Comments
 (0)