Skip to content

Commit 93df9ae

Browse files
committed
mise: fix vm:claude on macOS
1 parent 5849994 commit 93df9ae

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

mise/tasks/vm/claude

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,27 @@ echo "Syncing credentials from host to VM..."
3636
# Ensure .claude directory exists in VM
3737
ssh "${HOSTNAME}" 'mkdir -p ~/.claude'
3838

39+
# Copy .claude.json configuration file
40+
scp ~/.claude.json "${HOSTNAME}:~/.claude.json"
41+
3942
# Extract and copy credentials based on host OS
4043
if [[ "${HOST_OS}" == "mac" ]]; then
41-
# Extract from macOS Keychain and pipe directly to VM
42-
if ! security find-generic-password -s "Claude Code-credentials" -w 2>/dev/null | \
43-
jq -c 'del(.claudeAiOauth.refreshToken)' | \
44-
ssh "${HOSTNAME}" 'cat > ~/.claude/.credentials.json'; then
44+
# Try extracting from macOS Keychain with both possible service names
45+
if security find-generic-password -s "Claude Code-credentials" -w 2>/dev/null | \
46+
jq -c 'del(.claudeAiOauth.refreshToken)' | \
47+
ssh "${HOSTNAME}" 'cat > ~/.claude/.credentials.json'; then
48+
echo "Found credentials under 'Claude Code-credentials'"
49+
elif security find-generic-password -s "Claude Code" -w 2>/dev/null | \
50+
ssh "${HOSTNAME}" 'read key && jq --arg key "$key" ".primaryApiKey = \$key" ~/.claude.json > ~/.claude.json.tmp && mv ~/.claude.json.tmp ~/.claude.json'; then
51+
echo "Found credentials under 'Claude Code'"
52+
else
4553
echo "Error: Could not find Claude Code credentials in macOS Keychain"
4654
echo "Please ensure you are logged in to Claude Code on the host"
4755
exit 1
4856
fi
57+
58+
# Set appropriate permissions
59+
ssh "${HOSTNAME}" 'chmod 700 ~/.claude && chmod 600 ~/.claude/.credentials.json 2>/dev/null || chmod 600 ~/.claude.json'
4960
elif [[ "${HOST_OS}" == "linux" ]]; then
5061
# Copy directly from Linux filesystem
5162
if ! cat ~/.claude/.credentials.json | \
@@ -55,12 +66,9 @@ elif [[ "${HOST_OS}" == "linux" ]]; then
5566
echo "Please ensure you are logged in to Claude Code on the host"
5667
exit 1
5768
fi
58-
fi
5969

60-
# Copy .claude.json configuration file
61-
scp ~/.claude.json "${HOSTNAME}:~/.claude.json"
62-
63-
# Set appropriate permissions
64-
ssh "${HOSTNAME}" 'chmod 700 ~/.claude && chmod 600 ~/.claude/.credentials.json'
70+
# Set appropriate permissions
71+
ssh "${HOSTNAME}" 'chmod 700 ~/.claude && chmod 600 ~/.claude/.credentials.json'
72+
fi
6573

6674
echo "Claude Code installed and configured in ${HOSTNAME}"

mise/tasks/vm/create-post

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ if [[ -d /tmp/idle-shutdown ]]; then
5757
sudo systemctl daemon-reload
5858
sudo systemctl enable --now idle-shutdown.timer
5959
rm -rf /tmp/idle-shutdown
60-
fi
60+
fi

0 commit comments

Comments
 (0)