quarto-ext / shinylive

Quarto extension to embed Shinylive for Python applications
https://quarto-ext.github.io/shinylive/
MIT License
144 stars 8 forks source link

Quarto 1.4.3 triggers shinylive error due to deno standard library change #18

Closed garrettgman closed 1 year ago

garrettgman commented 1 year ago

Reposted from https://github.com/quarto-dev/quarto/issues/242.

I updated my Macbook to the developer version of quarto, 1.4.303, and noticed that I could no longer render quarto documents that contained Shinylive apps, as I reported https://github.com/quarto-ext/shinylive/issues/15#issuecomment-1675375077.

Rolling back to quarto 1.3.450 made the error go away.

While I was using 1.4.303, I could create the error by ...

To which @jjallaire suggests

This is going to require a change in the shinylive extension to work with the updated version of the deno standard library included with v1.4 (unfortunately it is still shifting around a bit). Could you re-post the issue there?

Note that if shinylive wants to make 2 versions available (one for use with v1.3 and one for v1.4) they can use a branch/tag based installation (as described here: https://quarto.org/docs/extensions/distributing.html#github-distribution) and just update docs accordingly to help users pick the right one.

jjallaire commented 1 year ago

cc @wch

wch commented 1 year ago

I think the fix is more straightforward than I initially believed it would be.

It looks like readLines was available in https://deno.land/std/io/buffer.ts until version 0.174.0, after which it was removed. At the same time, readLines has been available in https://deno.land/std/io/mod.ts since the earliest version for which there are docs, version 0.34.0.

So I just unconditionally changed the import from this:

import { readLines } from "https://deno.land/std/io/buffer.ts";

to this:

import { readLines } from "https://deno.land/std/io/mod.ts";

This was in https://github.com/rstudio/shinylive/commit/635b2e62cac8181a06c25940cf496b70b843c417. I'll also make a new release of shinylive and the shinylive python package soon.

wch commented 1 year ago

This should be fixed now. The way to get the fix is to update to the latest python shinylive package, which you can do with:

pip install --upgrade shinylive

This should install shinylive 0.0.17.