Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 52 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2015,10 +2015,58 @@ Before removing anything, `uninstall` prints warnings about two situations:
Otherwise the model keeps running on the remote machine with its endpoint
published, and the record that tracked it is gone.

It also lists the shared caches it leaves in place, when they live outside the
ROCm CLI directories: a `uv` package cache that `UV_CACHE_DIR` or the default
`~/.cache/uv` points to, and the Hugging Face model cache. Delete them yourself
if you no longer need them.
It also names the shared caches: a `uv` package cache that `UV_CACHE_DIR` or
the default `~/.cache/uv` points to, and the Hugging Face model cache. One that
lives outside the folders being removed is left in place; delete it yourself if
you no longer need it. If one sits inside a folder being removed (for example
`ROCM_CLI_CACHE_DIR=~/.cache`), the review says it WILL BE DELETED before you
confirm, and which `--keep-` flag keeps it.

`rocm uninstall` removes a config, data, or cache folder inside your home
folder as usual. It never removes:

- `/`, your home folder, or a folder that contains it;
- `/usr`, `/etc`, `/boot`, `/bin`, `/sbin`, `/lib`, `/lib32`, `/lib64`, `/libx32`, `/sys`, `/proc`, `/dev`,
`/run`, `/media`, `/snap`, `/mnt/wsl`, `/mnt/wslg`, or anything inside them — on Windows, `Windows`,
`Program Files`, `Program Files (x86)` and `ProgramData` on the system drive,
and the same folders on a drive WSL mounts at `/mnt/<drive>`;
- a folder other programs share: anything directly under `/` (`/opt`, `/srv`,
`/tmp`, ...), `/var/lib`, `/var/cache`, `/var/log`, `/var/tmp`, or a mounted
drive itself (`/mnt/c`);
- another user's home folder (anything under `/home`, `/Users`, `C:\Users`
or a WSL drive's `Users`, or beside your own home, that is not inside yours).

Anywhere else outside your home folder — `/opt/rocm-cli`, `/srv/rocm`,
`/mnt/d/rocm`, another disk — it removes a folder only if it carries a
`.rocm-cli-root` file. ROCm CLI writes that file only into a folder it creates
itself: the config, data and cache folders when its setup, its first log line
or its first config save creates them, the cache folder its download metadata
or a vLLM install first writes to, and an SDK `--prefix` it creates. A folder
that already existed, one made by hand, one made by a release before this one,
or one some other command happened to create first is not marked, and is
refused rather than removed until you create the file or keep the folder. The check looks at where a folder really is as well as how it is
written, so `ROCM_CLI_DATA_DIR=.` run from your home folder, a home reached
through a linked parent folder, or a system folder reached through a link is
caught too. A setting that names a file or a link rather than a folder is
judged by where its folder really is: with `~/x` a link to `/etc`,
`~/x/config.json` is refused as `/etc/config.json`. The link itself is only
unlinked, never followed. If a system folder that exists cannot be resolved,
nothing can be judged against it, so the uninstall is refused as unresolvable.

If a folder is refused (for example `ROCM_CLI_DATA_DIR=/`, or an SDK installed
with `--prefix ~`), the review lists it under "Refused" with why and the
setting it came from, the command exits with an error, and nothing is removed.
The message says what clears it: re-run with the `--keep-config`,
`--keep-data`, or `--keep-cache` flag to leave that folder in place; point the
`ROCM_CLI_*_DIR` variable it came from elsewhere; or, for an unmarked folder
that is ROCm CLI's, create the `.rocm-cli-root` file it names. For a folder
set by `setup.therock_venv`, use `--keep-data`: moving that setting would leave
the SDK installed there behind. The same flags work in the dashboard's
`/uninstall` and in the assistant's preview, and their refusals name the same
setting. Between the review and the removal, each folder is resolved again;
if it now points somewhere else, the uninstall stops instead.
`rocm runtimes uninstall` and `rocm storage remove-old-installs` keep their own
rule for runtime folders.

### Shell completions

Expand Down
5 changes: 5 additions & 0 deletions apps/rocm/src/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ pub(crate) use self::summaries::deterministic_comfyui_tool_summary;
// `run_internal_mcp_call` lives in `mcp_bridge.rs` and stays reachable here as
// `chat::run_internal_mcp_call` for `main.rs` and `dash_seam.rs`.
pub(crate) use self::mcp_bridge::run_internal_mcp_call;
// `run_rocm_read_only_in_process` lives in `mcp_bridge.rs` and stays
// reachable here for `uninstall_plan.rs`'s tests, which prove the assistant's
// in-process uninstall preview honours the `--keep-*` flags a refusal advises.
#[cfg(test)]
pub(crate) use self::mcp_bridge::run_rocm_read_only_in_process;
// `rocm_chat_tool_system_prompt_for_host` lives in `turn.rs` and stays
// reachable here as `chat::rocm_chat_tool_system_prompt_for_host` for `dash.rs`.
use self::turn::render_chat_prompt_result_with_progress;
Expand Down
18 changes: 12 additions & 6 deletions apps/rocm/src/chat/mcp_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

use super::summaries::managed_service_running_state;
use crate::automations::{render_automations_text, render_daemon_text};
use crate::engine_runtime_select::rocm_child_app_path_env;
use crate::freeform_planner::{format_structured_tool_call, plan_freeform_request_with_context};
use crate::managed_service_status::{load_managed_services, managed_service_is_live};
use crate::rocm_argv::{chat_cli_arg_value, chat_cli_has_flag};
Expand All @@ -31,7 +32,7 @@ use crate::services_text::{
render_services_text,
};
use crate::tool_policy::{
ChatRocmCommandAction, chat_install_prefix_is_system, chat_rocm_command_action,
ChatRocmCommandAction, chat_install_prefix_protection, chat_rocm_command_action,
chat_tool_call_is_read_only, json_string, rocm_chat_tool_requested_args,
validate_chat_tool_call,
};
Expand Down Expand Up @@ -458,7 +459,12 @@ fn run_rocm_capture_for_paths(
args: &[&str],
timeout: Duration,
) -> Result<CommandCapture> {
rocm_core::run_rocm_capture_with_env(args, &paths.env_vars(), timeout)
let vars = rocm_child_app_path_env(paths);
let env = vars
.iter()
.map(|(key, value)| (*key, Path::new(value)))
.collect::<Vec<_>>();
rocm_core::run_rocm_capture_with_env(args, &env, timeout)
}

fn run_rocm_command_for_paths(
Expand All @@ -484,7 +490,7 @@ fn run_rocm_command_for_paths(
}
}

fn run_rocm_read_only_in_process(paths: &AppPaths, args: &[String]) -> Result<String> {
pub(crate) fn run_rocm_read_only_in_process(paths: &AppPaths, args: &[String]) -> Result<String> {
let config = RocmCliConfig::load(paths).unwrap_or_default();
match args {
[] => bail!("rocm command requires at least one argument"),
Expand Down Expand Up @@ -620,7 +626,7 @@ fn run_rocm_read_only_in_process(paths: &AppPaths, args: &[String]) -> Result<St
if command.eq_ignore_ascii_case("uninstall")
&& rest.iter().any(|arg| arg.eq_ignore_ascii_case("--dry-run")) =>
{
render_uninstall_dry_run(paths)
render_uninstall_dry_run(paths, rest)
}
[command] if command.eq_ignore_ascii_case("setup") => {
render_setup_status_text(paths, &config)
Expand Down Expand Up @@ -703,9 +709,9 @@ fn internal_mcp_install_sdk_args(
];
if let Some(prefix) = json_string(arguments, "prefix") {
let prefix_path = Path::new(&prefix);
if chat_install_prefix_is_system(prefix_path) {
if let Some(why) = chat_install_prefix_protection(prefix_path) {
bail!(
"install_sdk prefix `{}` is a system folder; choose a user folder instead",
"install_sdk prefix `{}` is {why}; choose a user folder instead",
prefix_path.display()
);
}
Expand Down
61 changes: 59 additions & 2 deletions apps/rocm/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -735,10 +735,17 @@ rocm logs --search error timeout")]
/// warning). It also undoes the PATH change the installer made (its marked
/// shell-profile block, or the user PATH entry it recorded adding on
/// Windows), unless other programs share the install folder.
#[command(after_help = "EXAMPLES:\n \
#[command(
after_help = "Never removes /, your home folder or one containing it, another user's home, a \
system location (/usr, /etc, /lib, /run, ...; Windows, Program Files, ProgramData, ...), or a shared \
folder (anything directly under /, /var/lib, /mnt/<drive>, ...). Outside your home folder it \
removes only a folder holding the .rocm-cli-root file ROCm CLI writes into folders it creates. A \
refusal stops the whole uninstall and says what clears it. See the README for the full rules.\n\n\
EXAMPLES:\n \
rocm uninstall --dry-run\n \
rocm uninstall\n \
rocm uninstall --keep-data --yes")]
rocm uninstall --keep-data --yes"
)]
Uninstall {
/// Do not ask for interactive confirmation. Without it, the command
/// asks `[y/N]` (default: no) in an interactive terminal; outside one,
Expand Down Expand Up @@ -2564,6 +2571,56 @@ mod tests {
assert!(rows.contains(&"rocm uninstall"), "{examples}");
}

/// Every system folder `rocm uninstall --help` names is one the uninstall
/// really refuses as a system location. The list is abbreviated (`...`),
/// so README carries the whole of it; rocm-core's
/// `readme_names_every_uninstall_system_root` holds README to the code.
/// Each platform's names are checked on that platform's lane.
#[test]
fn uninstall_help_names_only_folders_it_refuses() {
let mut command = cli_command();
let help = command
.find_subcommand_mut("uninstall")
.expect("uninstall subcommand")
.render_long_help()
.to_string()
.replace('\n', " ");
let list = help
.split_once("system location (")
.and_then(|(_, rest)| rest.split_once(')'))
.map_or_else(
|| panic!("no system-location list in:\n{help}"),
|(list, _)| list,
);
let names: Vec<&str> = list
.split([',', ';'])
.map(str::trim)
.filter(|name| !name.is_empty() && *name != "...")
.collect();
assert!(
names.contains(&"/usr") && names.contains(&"Windows"),
"{list}"
);
for name in names {
let path = if name.starts_with('/') {
if !cfg!(unix) {
continue;
}
std::path::PathBuf::from(name)
} else {
if !cfg!(windows) {
continue;
}
std::path::PathBuf::from(format!("{}/{name}", rocm_core::windows_system_drive()))
};
assert_eq!(
rocm_core::uninstall_root_verdict(&path, None, &[]),
rocm_core::UninstallRootVerdict::Refused(rocm_core::ProtectedLocation::System),
"--help names {name} as a system location"
);
}
}

#[test]
fn update_rejects_zero_timeout_secs() {
let error = Cli::try_parse_from(["rocm", "update", "--json", "--timeout-secs", "0"])
Expand Down
Loading
Loading