|
| 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>` |
0 commit comments