Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't run shinylive, module error on ts #15

Open
muellerzr opened this issue Jul 18, 2023 · 10 comments
Open

Can't run shinylive, module error on ts #15

muellerzr opened this issue Jul 18, 2023 · 10 comments

Comments

@muellerzr
Copy link

Tried spinning up my old code to work on some parts, and when I try to render I get the following error:

error: Uncaught SyntaxError: The requested module 'https://deno.land/std/io/buffer.ts' does not provide an export named 'readLines'
import { readLines } from "https://deno.land/std/io/buffer.ts";
         ^
    at <anonymous> (file:///home/zach/.cache/shinylive/shinylive-0.1.3/scripts/codeblock-to-json.js:2776:10)
Error running filter /home/zach/quarto-cli/src/resources/filters/main.lua:
Error running quarto (error code 1): <no output>
stack traceback:
        ...-Learning/_extensions/quarto-ext/shinylive/shinylive.lua:72: in function <...-Learning/_extensions/quarto-ext/shinylive/shinylive.lua:67>
        [C]: in ?
        [C]: in method 'walk'
        ...h/quarto-cli/src/resources/filters/./ast/customnodes.lua:72: in function 'run_emulated_filter'
        .../quarto-cli/src/resources/filters/./ast/runemulation.lua:34: in local 'callback'
        [string "..."]:1884: in field 'withScriptFile'
        .../quarto-cli/src/resources/filters/./ast/runemulation.lua:43: in upvalue 'run_emulated_filter_chain'
        .../quarto-cli/src/resources/filters/./ast/runemulation.lua:78: in function <.../quarto-cli/src/resources/filters/./ast/runemulation.lua:75>
stack traceback:
        ...h/quarto-cli/src/resources/filters/./ast/customnodes.lua:72: in function 'run_emulated_filter'
        .../quarto-cli/src/resources/filters/./ast/runemulation.lua:34: in local 'callback'
        [string "..."]:1884: in field 'withScriptFile'
        .../quarto-cli/src/resources/filters/./ast/runemulation.lua:43: in upvalue 'run_emulated_filter_chain'
        .../quarto-cli/src/resources/filters/./ast/runemulation.lua:78: in function <.../quarto-cli/src/resources/filters/./ast/runemulation.lua:75>
ERROR: Error
    at renderFiles (file:///home/zach/quarto-cli/src/command/render/render-files.ts:546:23)
    at eventLoopTick (ext:core/01_core.js:181:11)
    at async renderProject (file:///home/zach/quarto-cli/src/command/render/project.ts:266:23)
    at async serveProject (file:///home/zach/quarto-cli/src/project/serve/serve.ts:208:24)
    at async Command.fn (file:///home/zach/quarto-cli/src/command/preview/cmd.ts:331:9)
    at async Command.execute (file:///home/zach/quarto-cli/src/vendor/deno.land/x/cliffy@v0.25.4/command/command.ts:1790:7)
    at async quarto (file:///home/zach/quarto-cli/src/quarto.ts:135:3)
    at async file:///home/zach/quarto-cli/src/quarto.ts:167:5

shinylive is v0.0.14, code is as follows:

```{shinylive-python}
#| standalone: true

def addition(a:int, b:int) -> int:
    "Returns the sum of `a` and `b`"
    return a+b

def multiplication(a:int, b:int) -> int:
    "Returns the product of `a` and `b`"
    return a*b

print(addition(2,3))
print(multiplication(2,3))
```
@wch
Copy link
Collaborator

wch commented Jul 18, 2023

What version of Quarto are you using?

@wch
Copy link
Collaborator

wch commented Jul 18, 2023

The Deno stdlib does not stay still, that's for sure...

It looks like readLines was removed from buffer.ts in std@0.175.0:

I believe each version of Quarto uses a specific version of Deno and Deno's stdlib, so if Quarto updated those things, it could cause that import to fail.

Assuming that's the cause of the problem, the solution would be to replace that readLines import with whatever the new thing is -- but we also want to make sure it'll work with older versions of Quarto.

@muellerzr
Copy link
Author

muellerzr commented Jul 18, 2023

I had this error with the dev version and 1.3.340 and 1.3.433 (and installing didn't pin the versions)

@muellerzr
Copy link
Author

@wch do you know how I can get those to install at the right versions?

@wch
Copy link
Collaborator

wch commented Jul 18, 2023

@muellerzr How are you installing Quarto?

On my local computer, I've installed it by cloning the https://github.com/quarto-dev/quarto-cli repo and then running ./configure.sh. I'm using the v1.3 branch, which is just a few commits ahead of the v1.3.433 tag. (Note that if you install this way, quarto --version reports 99.9.9.)

In Github Actions, it installs quarto 1.3.433 via a .deb file, and appears to be building the site just fine:
https://github.com/quarto-ext/shinylive/actions/runs/5425842660/jobs/9867124521#step:3:123

@muellerzr
Copy link
Author

By doing that when running the local dev, and dpkg -i {filename} after wget'ing the deb's

@wch
Copy link
Collaborator

wch commented Jul 18, 2023

My only guess is that there's some weird Deno stdlib caching thing going on.

For reference, here are two old issues related to caching, but they apparently have been fixed:


Can you create a file called version_std.ts with the following:

import { VERSION } from 'https://deno.land/std/version.ts';
console.log("Current Deno stdlib version", VERSION);

And then run it with quarto run version_std.ts. It will actually error out on the import (I'm told that Quarto currently doesn't import std/version.ts so it won't have this available), but the error message will actually be informative. I get:

$ quarto run version_std.ts
error: Specifier not found in cache: "https://deno.land/std@0.166.0/version.ts", --cached-only is specified.
    at file:///Users/winston/shinylive/shinylive-quarto/version.ts:1:25

Then create another file, version_deno.ts:

console.log("Current Deno version", Deno.version.deno);
console.log("Current TypeScript version", Deno.version.typescript);
console.log("Current V8 version", Deno.version.v8);

And run it:

$ quarto run version_deno.ts
Current Deno version 1.28.2
Current TypeScript version 4.8.3
Current V8 version 10.9.194.1

@garrettgman
Copy link

@wch I'm running into the same error:

Screenshot 2023-08-11 at 3 26 41 PM

Following your instructions in the last post, I create and ran version_std.ts (no error):
Screenshot 2023-08-11 at 3 30 22 PM

And version_deno.ts:
Screenshot 2023-08-11 at 3 31 25 PM

Any thoughts?

@garrettgman
Copy link

Rolling back to Quarto 1.3.450 fixed this for me.

@wch
Copy link
Collaborator

wch commented Aug 23, 2023

Sorry for taking so long to get this fixed -- installing the latest version of the shinylive Python package should make everything work.

pip install --upgrade shinylive

See #18 for more information. Please confirm that this fixes things for you!

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

No branches or pull requests

3 participants