Skip to content

Commit bef2816

Browse files
fix: ensure claude remains available after setup (#1424)
* fix: keep claude available after setup nvm upgrade * Update setup.sh Co-authored-by: amazon-q-developer[bot] <208079219+amazon-q-developer[bot]@users.noreply.github.com> * Update setup.sh Co-authored-by: amazon-q-developer[bot] <208079219+amazon-q-developer[bot]@users.noreply.github.com> --------- Co-authored-by: amazon-q-developer[bot] <208079219+amazon-q-developer[bot]@users.noreply.github.com>
1 parent 4d3765d commit bef2816

2 files changed

Lines changed: 65 additions & 53 deletions

File tree

setup.sh

Lines changed: 60 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -329,56 +329,7 @@ fi
329329
echo -e "${DIVIDER}"
330330
echo "Setting up development tools..."
331331

332-
# Amazon Q removed - was breaking tmux by hijacking shell sessions with qterm
333-
334-
# Claude Code Configuration (includes trivial npm install)
335-
echo -e "${DIVIDER}"
336-
echo "Configuring Claude Code..."
337-
338-
if [[ -f "$DOT_DEN/utils/configure-claude-code.sh" ]]; then
339-
source "$DOT_DEN/utils/configure-claude-code.sh"
340-
configure_claude_code || {
341-
echo -e "${YELLOW}Claude Code configuration incomplete. Run configure-claude-code.sh manually.${NC}"
342-
}
343-
fi
344-
345-
# Symlink Claude Code settings to correct location
346-
# Claude Code terminology: ~/.claude/settings.json = "user settings" (their term for global)
347-
# We call these "global settings" since they apply across all your projects
348-
# Using .claude/settings.json (not .local) prevents Claude from overwriting on startup
349-
if [[ -f "$DOT_DEN/.claude/settings.json" ]]; then
350-
echo "Creating symlink for Claude Code global settings..."
351-
# Create ~/.claude directory if it doesn't exist
352-
mkdir -p "$HOME/.claude"
353-
# Create symlink (force to overwrite if exists)
354-
ln -sf "$DOT_DEN/.claude/settings.json" "$HOME/.claude/settings.json"
355-
echo -e "${GREEN}✓ Claude Code global settings symlinked to ~/.claude/settings.json${NC}"
356-
else
357-
echo -e "${YELLOW}Warning: .claude/settings.json not found. Skipping settings symlink.${NC}"
358-
fi
359-
360-
# Symlink Claude Desktop MCP config to unified location (experiment #1213)
361-
if [[ -f "$DOT_DEN/mcp/mcp.json" ]]; then
362-
echo "Creating symlink for Claude Desktop MCP config..."
363-
# Create ~/.config/claude directory if it doesn't exist
364-
mkdir -p "$HOME/.config/claude"
365-
# Create symlink to unified MCP config
366-
ln -sf "$DOT_DEN/mcp/mcp.json" "$HOME/.config/claude/claude_desktop_config.json"
367-
echo -e "${GREEN}✓ Claude Desktop MCP config symlinked to mcp/mcp.json${NC}"
368-
fi
369-
370-
# OpenAI Codex Configuration (includes trivial npm install)
371-
echo -e "${DIVIDER}"
372-
echo "Configuring OpenAI Codex..."
373-
374-
if [[ -f "$DOT_DEN/utils/configure-codex.sh" ]]; then
375-
bash "$DOT_DEN/utils/configure-codex.sh" || {
376-
echo -e "${YELLOW}Codex configuration incomplete. Run configure-codex.sh manually.${NC}"
377-
}
378-
fi
379-
380-
381-
# Node.js setup with NVM
332+
# Node.js setup with NVM (must run before CLI configuration to keep global tools available)
382333
echo -e "${DIVIDER}"
383334
echo "Setting up Node.js with NVM..."
384335

@@ -469,6 +420,65 @@ else
469420
fi
470421
fi
471422

423+
# Amazon Q removed - was breaking tmux by hijacking shell sessions with qterm
424+
425+
# Claude Code Configuration (includes trivial npm install)
426+
echo -e "${DIVIDER}"
427+
echo "Configuring Claude Code..."
428+
429+
# Verify npm is available before proceeding
430+
if ! command -v npm >/dev/null 2>&1; then
431+
echo -e "${YELLOW}npm not available. Skipping Claude Code configuration.${NC}"
432+
else
433+
if [[ -f "$DOT_DEN/utils/configure-claude-code.sh" ]]; then
434+
source "$DOT_DEN/utils/configure-claude-code.sh"
435+
configure_claude_code || {
436+
echo -e "${YELLOW}Claude Code configuration incomplete. Run configure-claude-code.sh manually.${NC}"
437+
}
438+
fi
439+
fi
440+
441+
# Symlink Claude Code settings to correct location
442+
# Claude Code terminology: ~/.claude/settings.json = "user settings" (their term for global)
443+
# We call these "global settings" since they apply across all your projects
444+
# Using .claude/settings.json (not .local) prevents Claude from overwriting on startup
445+
if [[ -f "$DOT_DEN/.claude/settings.json" ]]; then
446+
echo "Creating symlink for Claude Code global settings..."
447+
# Create ~/.claude directory if it doesn't exist
448+
mkdir -p "$HOME/.claude"
449+
# Create symlink (force to overwrite if exists)
450+
ln -sf "$DOT_DEN/.claude/settings.json" "$HOME/.claude/settings.json"
451+
echo -e "${GREEN}✓ Claude Code global settings symlinked to ~/.claude/settings.json${NC}"
452+
else
453+
echo -e "${YELLOW}Warning: .claude/settings.json not found. Skipping settings symlink.${NC}"
454+
fi
455+
456+
# Symlink Claude Desktop MCP config to unified location (experiment #1213)
457+
if [[ -f "$DOT_DEN/mcp/mcp.json" ]]; then
458+
echo "Creating symlink for Claude Desktop MCP config..."
459+
# Create ~/.config/claude directory if it doesn't exist
460+
mkdir -p "$HOME/.config/claude"
461+
# Create symlink to unified MCP config
462+
ln -sf "$DOT_DEN/mcp/mcp.json" "$HOME/.config/claude/claude_desktop_config.json"
463+
echo -e "${GREEN}✓ Claude Desktop MCP config symlinked to mcp/mcp.json${NC}"
464+
fi
465+
466+
# OpenAI Codex Configuration (includes trivial npm install)
467+
echo -e "${DIVIDER}"
468+
echo "Configuring OpenAI Codex..."
469+
470+
# Verify npm is available before proceeding
471+
if ! command -v npm >/dev/null 2>&1; then
472+
echo -e "${YELLOW}npm not available. Skipping Codex configuration.${NC}"
473+
else
474+
if [[ -f "$DOT_DEN/utils/configure-codex.sh" ]]; then
475+
bash "$DOT_DEN/utils/configure-codex.sh" || {
476+
echo -e "${YELLOW}Codex configuration incomplete. Run configure-codex.sh manually.${NC}"
477+
}
478+
fi
479+
fi
480+
481+
472482
# Install uv for Python package management
473483
if ! command -v uv >/dev/null 2>&1; then
474484
echo "Installing uv package manager..."

utils/configure-claude-code.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ install_claude_if_needed() {
6666
fi
6767

6868
# Check if Claude Code is already installed
69-
if command -v claude &> /dev/null; then
69+
# Use type -P to ignore aliases and confirm the actual binary exists
70+
if type -P claude &> /dev/null; then
7071
# Get current version for informational purposes
7172
CURRENT_VERSION=$(claude --version 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' || echo "unknown")
7273
echo -e "${GREEN}✓ Claude Code is already installed (version: $CURRENT_VERSION)${NC}"
@@ -79,6 +80,7 @@ install_claude_if_needed() {
7980
echo -e "${RED}Failed to install Claude Code CLI. Please try again or check your npm installation.${NC}"
8081
return 1
8182
fi
83+
hash -r # ensure the shell picks up the newly installed binary
8284

8385
VERSION=$(claude --version 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' || echo "unknown")
8486
echo -e "${GREEN}✓ Claude Code successfully installed (version: $VERSION)${NC}"
@@ -138,7 +140,7 @@ configure_mcp_servers() {
138140
# These settings must be applied at runtime and cannot be declarative
139141
# ============================================================================
140142
configure_imperative_settings() {
141-
if command -v claude &> /dev/null; then
143+
if type -P claude &> /dev/null; then
142144
echo "Applying imperative settings..."
143145

144146
# These settings cannot be managed declaratively and must be set imperatively
@@ -158,4 +160,4 @@ configure_imperative_settings() {
158160
# Run configuration if script is executed directly (not sourced)
159161
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
160162
configure_claude_code
161-
fi
163+
fi

0 commit comments

Comments
 (0)