vhs icon indicating copy to clipboard operation
vhs copied to clipboard

v0.12.0 exits 0 and writes no output file on ubuntu-24.04 runners; v0.11.0 records the same tape

Open vahapogut opened this issue 2 months ago • 8 comments

On an ubuntu-24.04 GitHub Actions runner, vhs v0.12.0 runs a tape to completion, prints Creating <file>.gif..., prints the publish hint, exits 0, and writes no file. v0.11.0 records the same tape on the same runner without complaint.

The gap between the two printed lines is about 200 to 440 milliseconds, which is far too short to encode twenty seconds of terminal, so it looks like the encode never starts rather than failing.

Controlled comparison

Two runs of the same job, on the same runner image, from two commits whose only functional difference is the version passed to charmbracelet/[email protected]:

Run vhs Result
34459564668 v0.12.0 exits 0, no file anywhere on the filesystem
34460025896 v0.11.0 writes a 201 KB, 1200x700, 224 frame GIF

The diff between the two commits is one line plus comments:

-          version: v0.12.0
+          version: v0.11.0

Both runs are public, so the full logs are readable.

Environment

vhs     v0.12.0 (db96d73)   /opt/hostedtoolcache/vhs/0.12.0/x64/...
ttyd    1.7.7-40e79c7
ffmpeg  6.1.1-3ubuntu5
chrome  Google Chrome 152.0.7977.64  (chromium 152.0.7977.0 also present)
os      Ubuntu 24.04.5 LTS, x86_64
image   ubuntu-24.04, version 20260831.293.1
action  charmbracelet/vhs-action v2.1.1

Tape

Output docs/demo.gif

Require trustdiff

Set Shell bash
Set FontSize 16
Set Width 1200
Set Height 700
Set Padding 20
Set TypingSpeed 40ms

Type "trustdiff check npm:[email protected] pypi:requests cargo:serde"
Sleep 500ms
Enter
Wait+Screen@300s /Exit code/
Sleep 6s

trustdiff is a CLI on PATH; any command that prints a screen of text and ends with a line matching the Wait+Screen pattern should do.

Observed

Every tape step executes and every Wait+Screen matches, so the terminal side is working. Then:

09:16:20.0019515Z  Creating docs/demo.gif...
09:16:20.0021686Z
09:16:20.4461187Z  Host your GIF on vhs.charm.sh: vhs publish <file>.gif

vhs docs/demo.tape run by hand in the same job exits 0. Afterwards docs/ contains no gif, and find / -name 'demo.gif' -type f -newermt '-5 minutes' finds nothing.

Ruled out

Four things, each tested on its own before the version was suspected:

  • Set Columns / Set Rows. The tape originally used them, and they are new in v0.12.0, so they were the obvious suspect. Replacing them with Set Width / Set Height changed nothing.
  • Missing ffmpeg. The ubuntu-24.04 image does not carry ffmpeg. Installing it changed nothing here, but see the note below.
  • A Hide / Show block. The tape warmed a cache off camera inside one. Removing it entirely changed nothing.
  • Tape length. Cut from two recorded commands to one. Changed nothing.

Possibly a separate issue

vhs does not appear to check for ffmpeg before starting, and a run without it fails in exactly the shape above: tape completes, Creating ....gif... prints, exit 0, no file. That made this bug considerably harder to isolate, because the first thing anyone checks produces the same symptom. A startup check, or an error when the encode produces nothing, would turn both cases into something a reader can act on. Happy to open that separately if you would rather keep them apart.

Thanks for vhs. The recording it produces is exactly what the project wanted.

vahapogut avatar Sep 10 '26 10:09 vahapogut

Same symptoms when attempting to package vhs 0.12.0 for Void Linux.

I'm speculating that the issue lies somewhere in the ffmpeg invocation, but the fact that vhs seemingly doesn't check for or report any errors, or even have a verbose option to get more info from the tools it runs, doesn't help.

tranzystorekk avatar Sep 10 '26 11:09 tranzystorekk

Here https://github.com/charmbracelet/vhs/blob/main/evaluator.go#L186 the context used for rendering (the line below) is cancelled. One potential fix could be to use different contexts for rendering and recording.

gtartari-eurofunk avatar Sep 10 '26 12:09 gtartari-eurofunk

same here i got the same issue but locally in my cachyos+hyprland (ml4w) setup i checked ttyd ffmpeg vhs all version all deps everything but a gif is never produced

edit: use

cd /tmp
curl -fL -o vhs.tar.gz https://github.com/charmbracelet/vhs/releases/download/v0.11.0/vhs_0.11.0_Linux_x86_64.tar.gz
tar -xzf vhs.tar.gz
sudo install -Dm755 vhs_0.11.0_Linux_x86_64/vhs /usr/local/bin/vhs
vhs --version

and the gif also rendered for my case too using 0.11.0

programmersd21 avatar Sep 14 '26 10:09 programmersd21

Same failure on macOS, and both open fixes work there.

Environment: macOS 26.6.2 arm64, vhs 0.12.0 (Homebrew bottle), Chrome 153.0.8010.36, ffmpeg 9.0.1, ttyd 1.7.7, Go 1.27.1.

Results with a six-line tape:

Build Exit Output
Homebrew 0.12.0 0 no file
#788 at 7e0c332 0 400x200 GIF, 33 frames
#789 at 2f00c0e 0 400x200 GIF, 33 frames

With VHS_TEST_BROWSER=1, the new tests pass on both branches. As a control, I restored evaluator.go and vhs.go from v0.12.0 on the #789 branch and reran TestRenderWritesOutput. It failed with no output written, so the test catches this bug.

Before finding these PRs I patched it locally with v.Render(context.WithoutCancel(ctx)). That also produces a file, but it ignores cancellation of the parent context during encoding. The separate recorder context in #788 and #789 avoids that.

hartsock avatar Sep 14 '26 11:09 hartsock

Also reproduced on Windows, so this isn't Linux/macOS specific glue.

Environment: Windows 11 (build 26200), vhs 0.12.0 via winget (db96d73), ttyd 1.7.7 via winget, ffmpeg 9.0 (gyan.dev full build via winget), system Chrome.

What I saw matches the original report, with one extra detail: the recording side is completely healthy. My tape scaffolds a project via a CLI, and the scaffolded directory shows up in the working directory afterwards — ttyd, xterm.js and frame capture all did their job. Then:

Creating Deploy.mp4...
<one empty line>
Host your GIF on vhs.charm.sh: vhs publish <file>.gif

Exit 0, no file, and the same shape for .gif / .webm / .mp4 outputs.

That empty line is the failure, just disguised. The encoder is started with exec.CommandContext(ctx, "ffmpeg", ...) on the already-canceled context @gtartari-eurofunk pointed at, so CombinedOutput() fails immediately with context.Canceled before ffmpeg has written anything, and then in Render():

out, err := cmd.CombinedOutput()
if err != nil {
    log.Println(string(out))
}

logs the empty output and still returns nil. From the outside the whole run looks perfectly healthy. Anything that keeps an error path around the encoder (like #788 does) would have turned this into an obvious failure instead.

For other Windows people hitting this: 0.11.0 is still in the winget catalog, so winget uninstall charmbracelet.vhs + winget install charmbracelet.vhs --version 0.11.0 is the escape hatch until one of the fix PRs ships.

Oppenheymu avatar Sep 17 '26 11:09 Oppenheymu

Independent confirmation on macOS (Homebrew vhs 0.12.0, arm64, macOS 26.6.2): tape runs to completion, prints Creating <file>.mp4... and the publish hint, exits 0, and writes no file. Frames-only output (Output frames/) is produced correctly, so capture is healthy and this is purely the encode step.

Root cause matches what @gtartari-eurofunk identified: evaluator.go:116 ctx, cancel := context.WithCancel(ctx) rebinds ctx, and the now-canceled recording context is what Render(ctx) receives at evaluator.go:187. exec.CommandContext then aborts ffmpeg immediately with context canceled — and Render swallows it because video.go only logs CombinedOutput() output, which is empty on an exec abort (the tell-tale blank line after "Creating ...").

I also verified that the minimal one-line fix alone — using a separate recordingCtx for Record() and leaving Render(ctx) on the parent context, no test/browser changes — is sufficient: a from-source build of the v0.12.0 tag with that single change renders the same tape to a valid MP4.

For maintainers: #789 covers exactly that minimal change; #788 additionally un-swallows the context canceled error, which is worth having for future regressions. Either resolves this.

I wrote up the full analysis — root cause, minimal repro, and the one-line patch that unblocked me: Link

gauravbluepi avatar Sep 17 '26 14:09 gauravbluepi

Independent repro, macOS 26.6.2 arm64 (Homebrew vhs 0.12.0, ttyd 1.7.7, ffmpeg 9.0.1).

One extra data point not covered above: downgrading ffmpeg does NOT fix it. With [email protected] first on PATH (same tape, minimal 6-line repro: Output test.gif + single Type + Enter + Sleep), behavior is identical — Creating test.gif... + publish hint + exit 0 + no file anywhere on disk (searched /tmp, cwd, tape dir, and ~/Library).

Test matrix on this machine:

Build Result
vhs 0.12.0 (bottle) exit 0, no file
vhs 0.12.0 + [email protected] on PATH exit 0, no file (same)
ttyd standalone healthy — serves sessions, HTTP 200, stays alive
frame capture (per @gauravbluepi) n/a tested here, but recording side completes

Also reproduced from a real PTY in an interactive terminal pane (not CI/sandbox), and with tapes containing real API calls — so no sandbox/PTY excuse. Matches @gtartari-eurofunk's context-cancellation diagnosis: the encode step is cancelled before it starts regardless of ffmpeg version. Confirming the fix PRs (#788/#789) are the way forward; will report back if a mainline build changes anything on this machine.

nedzen avatar Sep 20 '26 14:09 nedzen

This is so crazy. Sorry for the long review. Please, cc me next time something like this comes up.

For anyone curious, this bug was caused by linting, which is why i didn't think to check.

Sorry for the inconvenience, everybody, will release now.

andrinoff avatar Sep 24 '26 09:09 andrinoff