mufeedvh / code2prompt

A CLI tool to convert your codebase into a single LLM prompt with source tree, prompt templating, and token counting.
MIT License
1.45k stars 77 forks source link

Failed to copy output to clipboard: XcbConnect(DisplayParsingError) #15

Closed AnirudhRahul closed 3 months ago

AnirudhRahul commented 4 months ago

Could a flag be added to skip copying the output to clipboard so code2prompt can be used on a remote without a clipboard.

ODAncona commented 3 months ago

Same here:

╭─ ~/Documents/projet/src │   
 user@machine
╰─ code2prompt src   
▹▹▹▹▸ Done!                                                                                                                                                                                                                  thread 'main' panicked at /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/code2prompt-1.1.0/src/main.rs:198:50:
Failed to copy output to clipboard: XcbConnect(DisplayParsingError)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[1]    60390 IOT instruction (core dumped)  code2prompt src
ahmedbentabet commented 3 months ago

Quick Solution: Remove Clipboard Functionality and Recompile

The arboard::Clipboard functionality in main.rs is causing issues. To resolve this, we need to remove the related lines of code and recompile the project.

  1. Remove the following lines from main.rs:

    use arboard::Clipboard;
    ...
    let mut clipboard = Clipboard::new().expect("Failed to initialize clipboard");
    clipboard.set_text(rendered).expect("Failed to copy output to clipboard");
    
    println!(
        "{}{}{} {}",
        "[".bold().white(),
        "✓".bold().green(),
        "]".bold().white(),
        "Prompt copied to clipboard!".green()
    );
  2. Recompile the project:

    cargo build --release
ODAncona commented 3 months ago

@AnirudhRahul I implemented the --no-clipboard option in #20. If you are on a remote machine, I'm able to use it using the --output flag.

mufeedvh commented 3 months ago

Fixed in #20 by @ODAncona! 🙌 🎉