diff --git a/CLAUDE.md b/CLAUDE.md index b4487d121c..1ba66ed71a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -11,6 +11,9 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co - `mise run test:e2e` - Run end-to-end tests only - `mise run snapshots` - Update test snapshots with `cargo insta` +### Debugging +- Use `MISE_DEBUG=1` or `MISE_TRACE=1` environment variables to enable debug output (not `RUST_LOG`) + ### Code Quality and Testing - `mise run lint` - Run all linting tasks - `mise run lint-fix` - Run linting and automatically fix issues diff --git a/e2e/cli/test_generate_tool_stub b/e2e/cli/test_generate_tool_stub new file mode 100755 index 0000000000..f0f6043a12 --- /dev/null +++ b/e2e/cli/test_generate_tool_stub @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Test that tool-stub generation works for git-branchless + +echo "Testing tool-stub generation for git-branchless..." + +# Generate a tool stub for git-branchless +mise generate tool-stub git-branchless \ + --platform-url 'https://github.com/arxanas/git-branchless/releases/download/v0.10.0/git-branchless-v0.10.0-x86_64-unknown-linux-musl.tar.gz' + +# Check that the file was created +if [[ ! -f git-branchless ]]; then + echo "FAIL: Tool stub file was not created" + exit 1 +fi + +# Check that it's executable +if [[ ! -x git-branchless ]]; then + echo "FAIL: Tool stub is not executable" + exit 1 +fi + +echo "Tool stub created successfully" + +# Show the stub content for debugging +echo "Stub content:" +cat git-branchless + +# Try to execute it to see the version +# This will install the tool if we're on Linux x64, otherwise will show an error about platform +echo "Attempting to execute git-branchless --version..." +OUTPUT=$(./git-branchless --version 2>&1 || true) +echo "Output: $OUTPUT" + +if echo "$OUTPUT" | grep -q "git-branchless"; then + echo "SUCCESS: git-branchless executed successfully" +elif echo "$OUTPUT" | grep -q "No URL configured for platform"; then + echo "Expected platform error (not on linux-x64), but tool stub works" +else + echo "FAIL: Unexpected output when executing git-branchless" + exit 1 +fi + +echo "Test passed!" diff --git a/src/cli/generate/tool_stub.rs b/src/cli/generate/tool_stub.rs index b45d358023..1fd63acef6 100644 --- a/src/cli/generate/tool_stub.rs +++ b/src/cli/generate/tool_stub.rs @@ -444,7 +444,11 @@ impl ToolStub { if will_strip { let path = std::path::Path::new(&selected_exe); if let Ok(stripped) = path.strip_prefix(path.components().next().unwrap()) { - return Ok(stripped.to_string_lossy().to_string()); + let stripped_str = stripped.to_string_lossy().to_string(); + // Don't return empty string if stripping removed everything + if !stripped_str.is_empty() { + return Ok(stripped_str); + } } }