This question is rather ambiguous as the command VAR is multiply defined; which VAR? Judging from the syntax, I am guessing {vars}.
The error message says that x, which has the word lagged in the name and that's often a hint that it was time shifted, contains values that are either NA [the first or last observation is often missing because of the implied time shift], NaN [not a number] or infinite, though possibly negative infinite especially if one has not been exceedingly careful about the fact that logs are only defined on non-negatives. Absent additional information, this is going to be really hard to diagnose. The command works; the reprex in the help file works with either the {fable} or {vars}.
By the way, I am not sure that RStudio IDE is the proper topic heading for this as no version of VAR is RStudio or their IDE.