vhs icon indicating copy to clipboard operation
vhs copied to clipboard

New ENV command breaks SET command in tape file

Open rahji opened this issue 1 year ago • 9 comments

Describe the bug

If you add a line like Env PROMPT '>' in the tape file, it has to be after any Set commands or it will cause them to be ignored when tape is run. (They appear in STDOUT but grayed out, and its clear from the resulting gif that they were ignored).

Setup Please complete the following information along with version numbers, if applicable.

  • OS: Windows 11 WSL2 (Ubuntu 22.04.4 LTS)
  • Shell: default
  • Terminal Emulator: Windows Terminal
  • Terminal Multiplexer: tmux

To Reproduce Steps to reproduce the behavior:

  1. Create a tape file containing the following and run with tape:
Output foo.gif
Env PROMPT "-"
Set Height 100
Type "creates a gif, but ignores 'Set Height'"
  1. Create a second tape file containing the following and run with tape:
Output bar.gif
Set Height 100
Env PROMPT "-"
Type "The tape command will fail with this file since 100 is not a valid 'Height'"

Source Code See above

Expected behavior Both tape files should work properly. Instead, the first one will create foo.gif but will ignore the Set Height command. The second one will fail since the Set Height line is not being ignored (and contains an invalid value)

Screenshots n/a

Additional context This only occurs on the current build. The ENV command is not available in the latest release. @Delta456's #469 was merged after that.

rahji avatar Jul 14 '24 23:07 rahji

In my PR I removed the functionality of ENV PROMPT prompt and it only allows to define env variables.

Delta456 avatar Jul 15 '24 03:07 Delta456

~ENV PROMPT prompt works - but only if it comes after the SET lines~

Actually, PROMPT doesn't work.

The bug is still accurate otherwise though, since the following tape file causes the Set commands to be ignored (because Env precedes them):

Output demo.gif

Env A "2"
Set Width 1150
Set Height 700
Set FontSize 18

Type "echo $A"
Enter

Sleep 2s

rahji avatar Jul 15 '24 12:07 rahji

I will investigate this and attempt to fix this.

Delta456 avatar Jul 20 '24 06:07 Delta456

After hours of investigation, this happens for all commands before SET. Perhaps all commands need to be written after setting the configuration of a tape.

Delta456 avatar Jul 20 '24 12:07 Delta456

After hours of investigation, this happens for all commands before SET. Perhaps all commands need to be written after setting the configuration of a tape.

Hey @Delta456, this is a documented behaviour of settings: https://github.com/charmbracelet/vhs#settings

Setting must be administered at the top of the tape file. Any setting (except TypingSpeed) applied after a non-setting or non-output command will be ignored.

maaslalani avatar Jul 21 '24 15:07 maaslalani

Ah, I missed that. This needs to be told when using the program IMO. Also, this issue can now be closed.

Delta456 avatar Jul 21 '24 16:07 Delta456

Ah, I missed that. This needs to be told when using the program IMO. Also, this issue can now be closed.

Agreed, if a setting is ignored we should display a warning that this setting should appear at the top of the file!

maaslalani avatar Jul 21 '24 16:07 maaslalani

Ah, I missed that. This needs to be told when using the program IMO. Also, this issue can now be closed.

Agreed, if a setting is ignored we should display a warning that this setting should appear at the top of the file!

I will add this warning in my future PRs.

Delta456 avatar Jul 21 '24 18:07 Delta456

This issue can be closed as https://github.com/charmbracelet/vhs/pull/508 is merged

Delta456 avatar Oct 20 '24 09:10 Delta456