From 9fcc86d99e026706d79a528a6b24fd42413a7166 Mon Sep 17 00:00:00 2001 From: Griffin Date: Tue, 1 Jul 2025 00:01:15 +0800 Subject: [PATCH 1/2] Prompt user to restart their terminal after install --- CHANGELOG.md | 8 ++++++++ src/cli/install.rs | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) 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..6160c87 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,38 @@ 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) { + let restart_message = "You need to restart your terminal for Rokit to be available."; + + if cfg!(windows) { + // Windows-only message (simpler since no source alternatives) + pt.finish_with_emoji_and_message("⚠️", restart_message); + } else { + // Unix systems with alternative source commands + 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(()) } } From e38ca538e3b44359d87dc527b405a53fbb0eb413 Mon Sep 17 00:00:00 2001 From: Griffin Date: Wed, 2 Jul 2025 18:46:57 +0800 Subject: [PATCH 2/2] Clarify post-install instructions --- src/cli/install.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/cli/install.rs b/src/cli/install.rs index 6160c87..368a43f 100644 --- a/src/cli/install.rs +++ b/src/cli/install.rs @@ -135,13 +135,16 @@ impl InstallSubcommand { // 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) { - let restart_message = "You need to restart your terminal for Rokit to be available."; - if cfg!(windows) { - // Windows-only message (simpler since no source alternatives) - pt.finish_with_emoji_and_message("⚠️", restart_message); + // 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"