Skip to content

Fix VCR examples for VCR off#550

Merged
sckott merged 8 commits into
mainfrom
maelle-patch-2
Jan 20, 2026
Merged

Fix VCR examples for VCR off#550
sckott merged 8 commits into
mainfrom
maelle-patch-2

Conversation

@maelle
Copy link
Copy Markdown
Member

@maelle maelle commented Aug 26, 2025

cc @drmowinckels

This is not tested and not enough.

When I try to run examples that use vcr when VCR is off, I get the error:

Error in `cassette$file()`:
! attempt to apply non-function

from https://github.com/ropensci/vcr/blob/42fad406bf43519ffa535ee2316082339fc3bbf8/R/examples.R#L61C3-L61C26

So some earlier escaping is needed.

But a remaining problem is that if no cassette is inserted, vcr::eject_cassette() errors.

In local_cassette(), the ejecting function is called conditionally.

if (!is.null(cassette)) {

Maybe vcr::eject_cassette() should also have an early return() when vcr is off? Thoughts?

@sckott
Copy link
Copy Markdown
Collaborator

sckott commented Sep 9, 2025

thanks @maelle

@maelle
Copy link
Copy Markdown
Member Author

maelle commented Oct 2, 2025

@sckott do you think this is a correct fix?

@sckott
Copy link
Copy Markdown
Collaborator

sckott commented Oct 2, 2025

Sorry for delay @maelle - I was trying to figure it out locally for a while, then got busy with work and life. I'll look again ASAP

@maelle
Copy link
Copy Markdown
Member Author

maelle commented Oct 13, 2025

Friendly reminder, but no pressure 😸

Copy link
Copy Markdown
Collaborator

@sckott sckott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @maelle can you review now? Added the eject_cassette early return, and added a test. What do you think?

Copy link
Copy Markdown
Member Author

@maelle maelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!!

Comment thread tests/testthat/test-examples.R
@maelle
Copy link
Copy Markdown
Member Author

maelle commented Jan 13, 2026

@sckott friendly reminder 😸

@sckott sckott linked an issue Jan 16, 2026 that may be closed by this pull request
@sckott sckott marked this pull request as ready for review January 16, 2026 20:21
@sckott
Copy link
Copy Markdown
Collaborator

sckott commented Jan 16, 2026

@maelle fixed that last thing in the test. Can you take a look? Or did you already think it was good to go?

@sckott sckott added this to the v2.2 milestone Jan 16, 2026
@drmowinckels
Copy link
Copy Markdown

I'm quite certain that fixes the issue for my part (tried cmd check in vanilla mode and everything went fine)

@maelle
Copy link
Copy Markdown
Member Author

maelle commented Jan 19, 2026

Thanks both! @sckott I'll rebase #548 after you merge as I think its builds are red for the same reason.

@sckott sckott merged commit ce8d1ce into main Jan 20, 2026
6 checks passed
@sckott sckott deleted the maelle-patch-2 branch January 20, 2026 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VCR_TURN_OFF and cassettes in vignettes and examples.

3 participants