Guides

Short fixes for problems I have hit, each checked against the versions it names.

Matching guides

6 of 6

  1. grep -q exits 141 under set -o pipefail, even when it matches

    Under set -o pipefail, piping a large payload into grep -q can fail the whole pipeline even though grep found what it was looking for. Swapping the pipe for a here string fixes it.

    one layer down checked Bash · GNU grep bash · grep · pipefail · shell · testing

  2. htmx hx-on fails: unsafe-eval is not an allowed source of script

    Under a Content-Security-Policy with script-src 'self', htmx compiles hx-on attributes into a function at runtime and the browser refuses to run it. Moving the same code into a script file as an event listener fixes it.

    one layer down checked htmx 2.0.7 · Content Security Policy htmx · csp · javascript · security

  3. sqlx: Rust type i64 is not compatible with SQL type NUMERIC

    A SUM() over a BIGINT column comes back as NUMERIC in PostgreSQL, and sqlx refuses to decode that into an i64 field. Casting the sum to BIGINT in the query fixes it.

    one layer down checked sqlx 0.8.6 · PostgreSQL rust · sqlx · postgresql · database

  4. stat -c %F reports the wrong file type under a non-English locale

    GNU stat translates its %F file-type field, so code that matches the English words regular file or directory misreads every path once the locale is, say, Swedish. Pinning LC_ALL=C on the stat call fixes it.

    one layer down checked GNU coreutils · Rust locale · stat · coreutils · ssh · rust

  5. cargo build fails but cargo test passes: could not find net in actix_rt

    After a dependency bump, a plain cargo build stopped with could not find net in actix_rt while cargo test kept passing. actix-server 2.8.0 never asks for the actix-rt features it needs, and updating it to 2.9.5, which does, fixes the build.

    deep checked actix-server 2.8.0 · actix-rt 2.14 and newer · Cargo rust · cargo · dependencies · features

  6. Scraped text runs as HTML in a generated report

    My web scraper wrote scraped titles and links straight into its HTML report, so a page could slip its own markup or a javascript: link into the file. One shared escape function, plus a rule that only http and https addresses become links, fixed it.

    one layer down checked Rust · HTML rust · html · security · escaping