@@ -22,6 +22,7 @@ PYTHON_VERSION=">=3.10,<3.13"
2222UV_INSTALLER_URL=" https://astral.sh/uv/install.sh"
2323PYTHON_BIN_PATH=" " # set after a verified install is found
2424DEV_BRANCH=" " # set by --dev-branch flag
25+ DO_UNINSTALL=0 # set by uninstall flag
2526PRINT_VERBOSE=0
2627PRINT_QUIET=1
2728
@@ -43,6 +44,13 @@ Run 'agentstack update' to update to the latest version.
4344EOF
4445)
4546
47+ MSG_UNINSTALL=$( cat << EOF
48+ ✅ AgentStack has been uninstalled.
49+ If you encountered any issues, or have feedback, please open an issue:
50+ $REPO_URL /issues
51+ EOF
52+ )
53+
4654usage () {
4755 cat << EOF
4856agentstack-install.sh
5664 agentstack-install.sh [OPTIONS]
5765
5866OPTIONS:
67+ uninstall Uninstall
5968 --version=<version> Specify version to install (default: $VERSION )
6069 --python-version=<version> Specify Python version to install (default: $PYTHON_VERSION )
6170 --dev-branch=<branch> Install from a specific git branch/commit/tag
@@ -114,7 +123,7 @@ err() {
114123 say " \n${_red} [ERROR]${_reset} : $1 " >&2
115124 say " \nRun with --verbose for more details."
116125 say " \nIf you need help, please feel free to open an issue:"
117- say " \n $REPO_URL /issues\n"
126+ say " $REPO_URL /issues\n"
118127 fi
119128 exit 1
120129}
@@ -225,10 +234,12 @@ install_uv() {
225234 err " uv installation failed: $_output "
226235 fi
227236
237+ update_path " $HOME /.local/bin"
238+
228239 # verify uv installation
229240 local _uv_version
230241 _uv_version=" $( uv --version 2> /dev/null) " || {
231- _uv_version=0
242+ err " could not find uv "
232243 }
233244
234245 end_activity
@@ -396,8 +407,10 @@ setup_app() {
396407update_path () {
397408 local new_path=" $1 "
398409
399- # update for current session
400- export PATH=" $new_path :$PATH "
410+ # update for current session if not already set
411+ if ! echo $PATH | grep -q " $new_path " ; then
412+ export PATH=" $new_path :$PATH "
413+ fi
401414
402415 # update for each shell
403416 local config_files=(
437450 chmod +x $_program_bin
438451}
439452
453+ uninstall () {
454+ say " Uninstalling $APP_NAME ..."
455+ show_activity
456+
457+ update_path " $HOME /.local/bin"
458+ PYTHON_BIN_PATH=" $( uv python find " $PYTHON_VERSION " 2> /dev/null) " || {
459+ PYTHON_BIN_PATH=" "
460+ }
461+
462+ # uninstall the app
463+ local _packages_dir=" $( $PYTHON_BIN_PATH -m site --user-site 2> /dev/null) " || {
464+ err " Failed to find user site packages directory"
465+ }
466+ say_verbose " Uninstalling from $_packages_dir "
467+ local _uninstall_cmd=" uv pip uninstall --python=" $PYTHON_BIN_PATH " --target=" $_packages_dir " $APP_NAME "
468+ say_verbose " $_uninstall_cmd "
469+ local _uninstall_out=" $( eval " $_uninstall_cmd " 2>&1 ) "
470+ say_verbose " $_uninstall_out "
471+ if [ $? -ne 0 ] || echo " $_uninstall_out " | grep -qi " error\|failed\|exception" ; then
472+ err " Failed to uninstall $APP_NAME ."
473+ fi
474+
475+ # remove the bin file
476+ rm -f " $HOME /.local/bin/$APP_NAME "
477+
478+ end_activity
479+ }
480+
440481# Download a file. Try curl first, if not installed, use wget instead.
441482download_file () {
442483 local _url=" $1 "
@@ -487,6 +528,10 @@ verify_sha256_checksum() {
487528parse_args () {
488529 while [[ $# -gt 0 ]]; do
489530 case " $1 " in
531+ uninstall)
532+ DO_UNINSTALL=1
533+ shift
534+ ;;
490535 --version=* )
491536 VERSION=" ${1#* =} "
492537 shift
@@ -562,6 +607,12 @@ main() {
562607
563608 say " $LOGO \n"
564609
610+ if [ $DO_UNINSTALL -eq 1 ]; then
611+ uninstall
612+ say " \n$MSG_UNINSTALL \n"
613+ exit 0
614+ fi
615+
565616 if check_cmd $APP_NAME ; then
566617 say " \n$MSG_ALREADY_INSTALLED \n"
567618 exit 0
0 commit comments