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 import std lib module for example Deno script #3723

Closed
4 tasks done
jimjam-slam opened this issue Dec 21, 2022 · 16 comments
Closed
4 tasks done

Can't import std lib module for example Deno script #3723

jimjam-slam opened this issue Dec 21, 2022 · 16 comments
Assignees
Labels
bug Something isn't working needs-repro Issues that are blocked until reporter provides an adequate reproduction
Milestone

Comments

@jimjam-slam
Copy link

Bug description

I'm trying to run the example Deno script code inside a Quarto project (that does have a _quarto.yml).

Here's my script, snel.ts:

import { parse } from "https://deno.land/std/encoding/yaml.ts";

const config = parse(Deno.readTextFileSync("_quarto.yml"));

When I ran this on Quarto 1.3.21, I got an error:

$ quarto run snel.ts
error: Specifier not found in cache: "https://deno.land/std@0.153.0/encoding/yaml.ts", --cached-only is specified.
    at file:///[project path]/snel.ts:1:23

I understand that Quarto's Deno can't download modules, but I would assume that this module is one of the cached ones.

I've now upgraded to Quarto 1.3.56, but I'm getting a similar-sounding error:

$ quarto run snel.ts
error: Module not found "file:///Users/jgol0005/Applications/quarto/vendor/deno.land/std@0.166.0/encoding/yaml.ts".
    at file:///[project path]/snel.ts:1:23

Having a look at the contents of the newly installed Quarto, it looks like the path relative to the Quarto installation should probably be /bin/vendor/deno-land rather than /vendor/deno.land, although I can't see encoding/yaml.ts in any of the cached std@[version] directories:

Screen Shot 2022-12-21 at 11 17 12

Does Quarto manage filling this cache on demand, or should the full standard library be there on install?

Checklist

  • Please include a minimal, fully reproducible example in a single .qmd file? Please provide the whole file rather than the snippet you believe is causing the issue.
  • Please format your issue so it is easier for us to read the bug report.
  • Please document the RStudio IDE version you're running (if applicable), by providing the value displayed in the "About RStudio" main menu dialog?
  • Please document the operating system you're running. If on Linux, please provide the specific distribution.
@jimjam-slam jimjam-slam added the bug Something isn't working label Dec 21, 2022
@cscheid
Copy link
Collaborator

cscheid commented Dec 21, 2022

There's a different place where the stdlib caching for deno run is stored. In the source tree, that lives in package/dist/share/deno_std, so that's likely in your share subdirectory. That gets resolved differently than the libraries you're seeing.

(That doesn't mean this isn't a bug, I'm just giving context.)

@cscheid cscheid self-assigned this Dec 21, 2022
@cscheid cscheid added this to the v1.3 milestone Dec 21, 2022
@cscheid
Copy link
Collaborator

cscheid commented Dec 21, 2022

I can't currently reproduce this on my Mac either, unfortunately. I added a console.log(JSON.stringify(config, null, 2)) line and got this:

quarto run snel.ts
{
  "project": {
    "type": "website"
  },
  "website": {
    "title": ".",
    "navbar": {
      "left": [
        {
          "href": "index.qmd",
          "text": "Home"
        },
        "about.qmd"
      ]
    }
  },
  "format": {
    "html": {
      "theme": "cosmo",
      "css": "styles.css",
      "toc": true
    }
  }
}

@cscheid cscheid added the needs-repro Issues that are blocked until reporter provides an adequate reproduction label Dec 21, 2022
@jimjam-slam
Copy link
Author

Makes sense! I upgraded over the top, so I might do a clean install and see what happens 😊

@cscheid
Copy link
Collaborator

cscheid commented Dec 26, 2022

@jimjam-slam Just checking in on this. Our upgrade should have happened cleanly, but I'm wondering if it's a different bug.

@jimjam-slam
Copy link
Author

Sorry, @cscheid! I swanned off on holiday and forgot all about it 😅 I'll see what I can do!

@cscheid
Copy link
Collaborator

cscheid commented Dec 26, 2022

@jimjam-slam no hurry! I'm technically out as well :) I just wanted to make I hadn't dropped the ball somewhere either.

@jimjam-slam
Copy link
Author

jimjam-slam commented Jan 3, 2023

I had a crack at "clean installing" by deleting the quarto folder at ~/Applications/quarto (I'd opted for single-user install), installed Quarto 1.3.78, opened a new shell and tried this again. Still no dice though, unfortunately!

(note: testscript is the project folder below)

_quarto.yml (nabbed from the docs this time):

project:
  output-dir: _output

toc: true
number-sections: true
bibliography: references.bib  
  
format:
  html:
    css: styles.css
    html-math-method: katex
  pdf:
    documentclass: report
    margin-left: 30mm
    margin-right: 30mm

snel.ts:

import { parse } from "https://deno.land/std/encoding/yaml.ts";

const config = parse(Deno.readTextFileSync("_quarto.yml"));

console.log(JSON.stringify(config, null, 2));

Command:

$ quarto run snel.ts
error: Module not found "file:///Users/[username]/Applications/quarto/vendor/deno.land/std@0.166.0/encoding/yaml.ts".
    at file:///Users/[username]/Code/svelte/testscript/snel.ts:1:23
$ which quarto
/Users/[username]/Applications/quarto/bin/quarto

@jimjam-slam
Copy link
Author

Oh! I deleted the quarto folder again and reinstalled Quarto 1.3.78 with an all-user install (putting it in /usr/local/bin/quarto instead of ~/Applications/quarto and the command ran successfully, producing the expected JSON output on line 3.

Looks like this might something to do with the single user install!

@cscheid cscheid added the needs-discussion Issues that require a team-wide discussion before proceeding further label Jan 3, 2023
@allenmanning allenmanning removed the needs-discussion Issues that require a team-wide discussion before proceeding further label Jan 4, 2023
@jimjam-slam
Copy link
Author

Apologies—this has cropped up for me again as I've attempted to move up to Quarto 1.3.107.

I've deleted /Applications/quarto and /usr/local/bin/quarto (which looked like it symlinked to /Applications/quarto/bin/quarto—I hadn't clocked that in my previous post), then run the macOS installer, again choosing all-user install.

With a fresh terminal, I can see the symlink again pointing to /Applications/quarto/bin/quarto (which I can see was just created), but when I quarto render a project tht was previously working, I get:

error: Module not found "file:///Applications/quarto/vendor/deno.land/std@0.166.0/path/mod.ts".

(The offending line is import * as path from "https://deno.land/std/path/mod.ts";

@jimjam-slam
Copy link
Author

I should note that if I downgrade to 1.2.313, I no longer get this error (even if I install it in the same way, using the .pkg installer and specifying "all-user" install).

@cscheid
Copy link
Collaborator

cscheid commented Jan 16, 2023

I'm pretty sure what's happening is that we're letting deno create a cache somewhere, and then when you upgrade to a new quarto version, we have a new stdlib (which needs a new cache) but we're resolving to the wrong cache. You're seeing that problem because we need to upgrade deno stdlibs when we upgrade deno version, and I bet deno doesn't version its internal caches (as I would argue it should)

@cscheid cscheid added the needs-discussion Issues that require a team-wide discussion before proceeding further label Jan 16, 2023
@jimjam-slam
Copy link
Author

Let me know if there's anything I can do on my side to help you isolate it!

@allenmanning allenmanning removed the needs-discussion Issues that require a team-wide discussion before proceeding further label Jan 25, 2023
@cderv
Copy link
Collaborator

cderv commented Feb 9, 2023

@cscheid I believe quarto-ext/shinylive#8 is now about the same issue than here. OP there is in a state where this happens so could be helpful to help debug this if we need more information.

@cscheid
Copy link
Collaborator

cscheid commented Feb 9, 2023

I think this should be fixed as of 87ae6fc

@cderv
Copy link
Collaborator

cderv commented Feb 9, 2023

I confirmed that quarto-ext/shinylive#8 is now fixed using very latest 1.3

@cscheid
Copy link
Collaborator

cscheid commented Feb 9, 2023

@jimjam-slam I'm going to go ahead and close this one. If the latest prerelease continues to give you trouble, please feel free to reopen this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-repro Issues that are blocked until reporter provides an adequate reproduction
Projects
None yet
Development

No branches or pull requests

4 participants