Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

fix(cli): warn on shadowed ov installs (#2030)

Zayn Jarvisecb4579c42c9
diff --git a/crates/ov_cli/install.sh b/crates/ov_cli/install.sh
index 99c602647..7177661af 100755
--- a/crates/ov_cli/install.sh
+++ b/crates/ov_cli/install.sh
@@ -1,206 +1,19 @@
#!/bin/bash
set -e
-# OpenViking CLI Installer (legacy GitHub Releases path)
-# Prefer npm for new installs:
-# npm i -g @openviking/cli
-# Alternative TOS installer:
-# curl -fsSL http://openviking.tos-cn-beijing.volces.com/cli/install.sh | bash
-# Skip checksum: SKIP_CHECKSUM=1 bash install.sh
-# Custom repo: REPO=owner/repo curl -fsSL ... | bash
+cat >&2 <<'EOF'
+[DEPRECATED] crates/ov_cli/install.sh no longer installs OpenViking CLI.
-REPO="${REPO:-volcengine/openviking}"
-BINARY_NAME="ov"
-INSTALL_DIR="/usr/local/bin"
-SKIP_CHECKSUM="${SKIP_CHECKSUM:-0}"
+Install the CLI from npm instead:
-# Colors for output
-RED='\033[0;31m'
-GREEN='\033[0;32m'
-YELLOW='\033[1;33m'
-NC='\033[0m' # No Color
+ npm i -g @openviking/cli
-info() { echo -e "${GREEN}[INFO]${NC} $1"; }
-warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
-error() { echo -e "${RED}[ERROR]${NC} $1"; exit 1; }
+Or run it without installing:
-# Detect platform and architecture
-detect_platform() {
- case "$(uname -s)" in
- Linux*)
- OS="linux"
- ;;
- Darwin*)
- OS="macos"
- ;;
- CYGWIN*|MINGW*|MSYS*)
- OS="windows"
- ;;
- *)
- error "Unsupported operating system: $(uname -s)"
- ;;
- esac
+ npx @openviking/cli --help
- case "$(uname -m)" in
- x86_64|amd64)
- ARCH="x86_64"
- ;;
- arm64|aarch64)
- ARCH="aarch64"
- ;;
- *)
- error "Unsupported architecture: $(uname -m)"
- ;;
- esac
+The old raw GitHub installer path is kept only to avoid a silent 404 for
+existing links. It intentionally does not download binaries from GitHub or TOS.
+EOF
- ARTIFACT_NAME="${BINARY_NAME}-${OS}-${ARCH}"
- if [[ "$OS" == "windows" ]]; then
- ARTIFACT_NAME="${ARTIFACT_NAME}.exe"
- ARCHIVE_EXT="zip"
- else
- ARCHIVE_EXT="tar.gz"
- fi
-}
-
-# Get latest CLI release info
-get_latest_release() {
- info "Getting latest CLI release information..."
-
- # Paginate through releases and stop at first CLI match
- PAGE=1
- PER_PAGE=30
- TAG_NAME=""
-
- while [[ -z "$TAG_NAME" ]]; do
- RELEASES=$(curl -s "https://api.github.com/repos/${REPO}/releases?per_page=${PER_PAGE}&page=${PAGE}")
-
- # Check if we got any releases
- RELEASE_COUNT=$(echo "$RELEASES" | jq 'length')
- if [[ "$RELEASE_COUNT" -eq 0 ]]; then
- error "Could not find any CLI releases. Make sure CLI releases exist with tags starting with 'cli-'"
- fi
-
- # Find first CLI release in this page
- TAG_NAME=$(echo "$RELEASES" | jq -r '.[] | select(.tag_name | startswith("cli@")) | .tag_name' | head -n 1)
-
- if [[ -n "$TAG_NAME" ]]; then
- break
- fi
-
- PAGE=$((PAGE + 1))
-
- # Safety limit: don't fetch more than 5 pages (150 releases)
- if [[ "$PAGE" -gt 5 ]]; then
- error "Could not find any CLI releases in the last 150 releases"
- fi
- done
-
- if [[ -z "$TAG_NAME" ]]; then
- error "Could not determine latest CLI release version"
- fi
-
- info "Latest CLI version: $TAG_NAME"
- DOWNLOAD_URL="https://github.com/${REPO}/releases/download/${TAG_NAME}/${ARTIFACT_NAME}.${ARCHIVE_EXT}"
- CHECKSUM_URL="https://github.com/${REPO}/releases/download/${TAG_NAME}/${ARTIFACT_NAME}.${ARCHIVE_EXT}.sha256"
-}
-
-# Download and extract binary
-download_binary() {
- info "Downloading ${ARTIFACT_NAME}.${ARCHIVE_EXT}..."
- TEMP_DIR=$(mktemp -d)
- ARCHIVE_FILE="$TEMP_DIR/${ARTIFACT_NAME}.${ARCHIVE_EXT}"
- CHECKSUM_FILE="$TEMP_DIR/${ARTIFACT_NAME}.${ARCHIVE_EXT}.sha256"
-
- # Download archive
- if ! curl -sSL -o "$ARCHIVE_FILE" "$DOWNLOAD_URL"; then
- error "Failed to download from $DOWNLOAD_URL"
- fi
-
- # Download and verify checksum
- if [[ "$SKIP_CHECKSUM" == "1" ]]; then
- warn "Skipping checksum verification (SKIP_CHECKSUM=1)"
- elif ! curl -sSL -o "$CHECKSUM_FILE" "$CHECKSUM_URL"; then
- warn "Could not download checksum file, skipping verification"
- elif grep -q "Not Found" "$CHECKSUM_FILE" 2>/dev/null; then
- warn "Checksum file not available in release, skipping verification"
- else
- info "Verifying checksum..."
- if command -v sha256sum >/dev/null; then
- (cd "$TEMP_DIR" && sha256sum -c "${ARTIFACT_NAME}.${ARCHIVE_EXT}.sha256") || error "Checksum verification failed"
- elif command -v shasum >/dev/null; then
- (cd "$TEMP_DIR" && shasum -a 256 -c "${ARTIFACT_NAME}.${ARCHIVE_EXT}.sha256") || error "Checksum verification failed"
- else
- warn "No checksum utility found, skipping verification"
- fi
- fi
-
- # Extract archive
- info "Extracting archive..."
- if [[ "$ARCHIVE_EXT" == "tar.gz" ]]; then
- tar -xzf "$ARCHIVE_FILE" -C "$TEMP_DIR" || error "Failed to extract archive"
- elif [[ "$ARCHIVE_EXT" == "zip" ]]; then
- unzip -q "$ARCHIVE_FILE" -d "$TEMP_DIR" || error "Failed to extract archive"
- fi
-
- TEMP_FILE="$TEMP_DIR/$BINARY_NAME"
- if [[ "$OS" == "windows" ]]; then
- TEMP_FILE="${TEMP_FILE}.exe"
- fi
-
- if [[ ! -f "$TEMP_FILE" ]]; then
- error "Binary not found after extraction: $TEMP_FILE"
- fi
-
- info "Download and extraction successful"
-}
-
-# Install binary
-install_binary() {
- info "Installing to $INSTALL_DIR/$BINARY_NAME..."
-
- # Check if install directory exists and is writable
- if [[ ! -d "$INSTALL_DIR" ]]; then
- error "Install directory $INSTALL_DIR does not exist"
- fi
-
- # Try to install
- if [[ -w "$INSTALL_DIR" ]]; then
- cp "$TEMP_FILE" "$INSTALL_DIR/$BINARY_NAME"
- else
- info "Requesting sudo privileges for installation..."
- sudo cp "$TEMP_FILE" "$INSTALL_DIR/$BINARY_NAME"
- sudo chmod +x "$INSTALL_DIR/$BINARY_NAME"
- fi
-
- # Make executable
- chmod +x "$INSTALL_DIR/$BINARY_NAME" 2>/dev/null || sudo chmod +x "$INSTALL_DIR/$BINARY_NAME"
-
- # Cleanup
- rm -rf "$TEMP_DIR"
-}
-
-# Verify installation
-verify_installation() {
- info "Verifying installation..."
- if command -v "$BINARY_NAME" >/dev/null; then
- VERSION=$($BINARY_NAME --version)
- info "Successfully installed: $VERSION"
- info "Run '$BINARY_NAME --help' to get started"
- else
- error "Installation failed - $BINARY_NAME not found in PATH"
- fi
-}
-
-main() {
- info "OpenViking CLI Installer"
- detect_platform
- info "Detected platform: $OS ($ARCH)"
- get_latest_release
- download_binary
- install_binary
- verify_installation
- info "Installation complete! πŸŽ‰"
-}
-
-# Run main function
-main "$@"
+exit 1
diff --git a/npm/cli/bin/postinstall.mjs b/npm/cli/bin/postinstall.mjs
index 7f053c2df..164a00738 100644
--- a/npm/cli/bin/postinstall.mjs
+++ b/npm/cli/bin/postinstall.mjs
@@ -1,9 +1,93 @@
#!/usr/bin/env node
+import { execFileSync } from "node:child_process";
+import { existsSync } from "node:fs";
+import { delimiter, join } from "node:path";
+import { fileURLToPath } from "node:url";
+
+const packageTarget = fileURLToPath(new URL("./ov.mjs", import.meta.url));
+
+function write(message = "") {
+ process.stderr.write(`${message}\n`);
+}
+
+function runVersion(command, args = []) {
+ try {
+ return execFileSync(command, [...args, "--version"], {
+ encoding: "utf8",
+ stdio: ["ignore", "pipe", "pipe"],
+ windowsHide: true,
+ }).trim().split(/\r?\n/)[0] || "<version unavailable>";
+ } catch {
+ return "<version unavailable>";
+ }
+}
+
+function installedBinTarget() {
+ const prefix = process.env.npm_config_prefix;
+ if (!prefix || process.env.npm_config_global !== "true") {
+ return null;
+ }
+ return process.platform === "win32"
+ ? join(prefix, "ov.cmd")
+ : join(prefix, "bin", "ov");
+}
+
+function findOvPaths() {
+ const names = process.platform === "win32"
+ ? ["ov.cmd", "ov.exe", "ov.ps1", "ov"]
+ : ["ov"];
+ const seen = new Set();
+ const paths = [];
+
+ for (const dir of (process.env.PATH || "").split(delimiter)) {
+ if (!dir) {
+ continue;
+ }
+ for (const name of names) {
+ const candidate = join(dir, name);
+ if (seen.has(candidate) || !existsSync(candidate)) {
+ continue;
+ }
+ seen.add(candidate);
+ paths.push(candidate);
+ }
+ }
+
+ return paths;
+}
+
+function printPathDiagnostics() {
+ const target = installedBinTarget();
+ const paths = findOvPaths();
+
+ if (target) {
+ if (paths.includes(target)) {
+ write(` PATH target: ${target}`);
+ } else {
+ write(` Warning: npm bin target is not on PATH: ${target}`);
+ }
+ }
+
+ if (target && paths[0] && paths[0] !== target) {
+ write(` Warning: PATH resolves ov to ${paths[0]} before ${target}`);
+ }
+
+ if (paths.length > 1) {
+ write(" Warning: multiple ov executables found on PATH:");
+ for (const path of paths) {
+ write(` ${path} -> ${runVersion(path)}`);
+ }
+ }
+}
+
process.stderr.write(`
╔═══════════════════════════════════════════════════╗
β•‘ OpenViking CLI installed β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
+ Installed package target: ${packageTarget}
+ Installed package target version: ${runVersion(process.execPath, [packageTarget])}
+
Usage: ov <command> [options]
Commands:
@@ -16,4 +100,6 @@ process.stderr.write(`
ov config show Show current configuration
Run "ov --help" for the full command list.
-\n`);
+`);
+
+printPathDiagnostics();