PATH 문제 해결
This commit is contained in:
1 parent
392a42d2ef
commit
4af780d31f
1 file changed
+25
-16
+25
-16
@@ -140,7 +140,8 @@ if [ -z "$PI_BIN" ] && command -v npm &>/dev/null; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Add pi's directory to PATH for this session so pi install subprocess works
|
# Add pi's directory to PATH for this session so pi install subprocess works,
|
||||||
|
# and permanently add it to the shell profile if not already there.
|
||||||
if [ -n "$PI_BIN" ]; then
|
if [ -n "$PI_BIN" ]; then
|
||||||
PI_DIR="$(dirname "$PI_BIN")"
|
PI_DIR="$(dirname "$PI_BIN")"
|
||||||
case ":$PATH:" in
|
case ":$PATH:" in
|
||||||
@@ -148,6 +149,29 @@ if [ -n "$PI_BIN" ]; then
|
|||||||
*)
|
*)
|
||||||
export PATH="$PI_DIR:$PATH"
|
export PATH="$PI_DIR:$PATH"
|
||||||
info "Added $PI_DIR to PATH for this session"
|
info "Added $PI_DIR to PATH for this session"
|
||||||
|
|
||||||
|
# Permanently add to shell profile
|
||||||
|
SHELL_RC=""
|
||||||
|
if [ -n "${ZSH_VERSION:-}" ] && [ -f "$HOME/.zshrc" ]; then
|
||||||
|
SHELL_RC="$HOME/.zshrc"
|
||||||
|
elif [ -f "$HOME/.bashrc" ]; then
|
||||||
|
SHELL_RC="$HOME/.bashrc"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$SHELL_RC" ]; then
|
||||||
|
PATH_LINE="export PATH=\"$PI_DIR:\$PATH\""
|
||||||
|
if ! grep -qF "$PI_DIR" "$SHELL_RC" 2>/dev/null; then
|
||||||
|
echo "" >>"$SHELL_RC"
|
||||||
|
echo "# Added by install-pi.sh" >>"$SHELL_RC"
|
||||||
|
echo "$PATH_LINE" >>"$SHELL_RC"
|
||||||
|
success "Added $PI_DIR to $SHELL_RC (takes effect on next login)"
|
||||||
|
else
|
||||||
|
info "$PI_DIR already in $SHELL_RC"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "Could not detect shell config. Add this line to your profile manually:"
|
||||||
|
warn " export PATH=\"$PI_DIR:\$PATH\""
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
success "Pi is available: $PI_BIN"
|
success "Pi is available: $PI_BIN"
|
||||||
@@ -205,21 +229,6 @@ info "════════════════════════
|
|||||||
info ""
|
info ""
|
||||||
info "Pi binary: $PI_BIN"
|
info "Pi binary: $PI_BIN"
|
||||||
info ""
|
info ""
|
||||||
if [ -n "$PI_DIR" ]; then
|
|
||||||
case ":$PATH:" in
|
|
||||||
*":$PI_DIR:"*) ;;
|
|
||||||
*)
|
|
||||||
SHELL_RC=""
|
|
||||||
if [ -f "$HOME/.bashrc" ]; then SHELL_RC="$HOME/.bashrc"; elif [ -f "$HOME/.zshrc" ]; then SHELL_RC="$HOME/.zshrc"; fi
|
|
||||||
if [ -n "$SHELL_RC" ]; then
|
|
||||||
info "NOTE: Add $PI_DIR to your PATH permanently by running:"
|
|
||||||
info " echo 'export PATH=\"$PI_DIR:\$PATH\"' >> $SHELL_RC"
|
|
||||||
info " source $SHELL_RC"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
info ""
|
|
||||||
info "Getting started:"
|
info "Getting started:"
|
||||||
info " 1. Navigate to your project: cd /path/to/project"
|
info " 1. Navigate to your project: cd /path/to/project"
|
||||||
info " 2. Start Pi: pi"
|
info " 2. Start Pi: pi"
|
||||||
|
|||||||
Reference in new issue
Block a user