diff --git a/CHANGELOG.md b/CHANGELOG.md index 2726256..8845965 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## `Unreleased` + +### Changed + +- Modified the `rokit install` command to check if Rokit is in the user's PATH after installation, and provide appropriate instructions based on the user's operating system and shell ([#92]) + +[#92]: https://github.com/rojo-rbx/rokit/pull/92 + ## `1.0.0` - November 13th, 2024 Given that Rokit is already used in production by many Roblox developers, and many months have passed with no new major issues, it is time to release version `1.0.0`. diff --git a/src/cli/install.rs b/src/cli/install.rs index 5097200..368a43f 100644 --- a/src/cli/install.rs +++ b/src/cli/install.rs @@ -5,7 +5,7 @@ use clap::Parser; use console::style; use futures::{stream::FuturesUnordered, TryStreamExt}; -use rokit::{discovery::discover_all_manifests, storage::Home}; +use rokit::{discovery::discover_all_manifests, storage::Home, system::exists_in_path}; use crate::util::{find_most_compatible_artifact, prompt_for_trust_specs, CliProgressTracker}; @@ -132,6 +132,41 @@ impl InstallSubcommand { pt.formatted_elapsed(), )); + // 6. Check if PATH was updated and if the user needs to restart their terminal + // or source their shell configuration file to make Rokit available + if !exists_in_path(home) { + if cfg!(windows) { + // Windows users need to restart their PC for PATH changes to take effect + pt.finish_with_emoji_and_message( + "⚠️", + "You need to restart your computer for Rokit to be available.", + ); + } else { + // Unix systems with alternative source commands + let restart_message = + "You need to restart your terminal for Rokit to be available."; + let shell_command = if let Ok(shell) = std::env::var("SHELL") { + if shell.ends_with("/zsh") { + "source ~/.zshenv" + } else if shell.ends_with("/bash") { + "source ~/.bashrc" + } else { + "source ~/.profile" + } + } else { + "source ~/.profile" + }; + + pt.finish_with_emoji_and_message( + "⚠️", + format!( + "{restart_message}\n\nAlternatively, run {} in your current terminal.", + style(shell_command).bold().green() + ), + ); + } + } + Ok(()) } }