`deno install` does not cache all dep files.
Hi,
Given the following deno.json file
{
// ...
"lock": {
"frozen": true
},
"imports": {
"@david/dax": "jsr:@david/[email protected]",
"@std/cli": "jsr:@std/[email protected]",
"@std/path": "jsr:@std/path@^1.0.6",
"@std/yaml": "jsr:@std/[email protected]"
}
}
I would expect that after a deno install, i would be able to use the deno commands using the --cached-only flag.
What happens is that if i do deno install && deno compile main.ts i get the following error
error: Specifier not found in cache: "https://jsr.io/@std/yaml/1.0.5/_type.ts", --cached-only is specified.
at https://jsr.io/@std/yaml/1.0.5/_loader_state.ts:40:37
I am under the impression that deno install would download and cache all deps, but it happers that is misses some files?
Running deno install && deno compile main.ts it dos work but i have to download the missing file but it seems weird that i cannot use the --cached-only:
Download https://jsr.io/@std/yaml/1.0.5/_type.ts
Check file:///home/main/devs/the-office-quote/main.ts
Compile file:///home/main/devs/the-office-quote/main.ts to the-office-quote
Download https://dl.deno.land/release/v2.0.0/denort-x86_64-unknown-linux-gnu.zip
deno 2.0.0 (stable, release, x86_64-unknown-linux-gnu) v8 12.9.202.13-rusty typescript 5.6.2
This behavior is not only on compile, i have other project where i am trying to build a docker image that cached the deps before copying the source code, where it gets a similar error when doing a deno run --cached-only
FROM docker.io/denoland/deno:alpine-2.0.0
RUN mkdir /app
RUN chown -R deno:deno /app
USER deno
WORKDIR /app
COPY --chown=deno:deno deno.json deno.lock .
RUN deno install --node-modules-dir
RUN deno eval "import '@db/sqlite'"
COPY --chown=deno:deno . .
RUN mkdir /app/data
VOLUME [ "/app/data" ]
EXPOSE 4321 4322
when running i get:
error: Specifier not found in cache: "https://jsr.io/@hono/hono/4.6.2/src/jsx/jsx-runtime.ts", --cached-only is specified.
at file:///app/src/apps/web/app.tsx:1:1
heres the deno.json
{
...
"compilerOptions": {
"jsx": "precompile",
"jsxImportSource": "@hono/hono/jsx"
},
"lock": {
"frozen": true
},
"imports": {
"@hono/hono": "jsr:@hono/[email protected]",
...
}
}
Probably the real error behind my problem https://github.com/denoland/std/issues/6108
@dsherret please take a look
Just tried with deno v2.0.1 and the error i get is a bit different, but still, do not work with --cached-only flag:
deno install
deno compile --cached-only main.ts
error: JSR package manifest for '@std/yaml' failed to load. Specifier not found in cache: "https://jsr.io/@std/yaml/meta.json", --cached-only is specified.
at file:///home/main/devs/the-office-quote/main.ts:1:23
Does it work if you do deno install -e main.ts instead of deno install?
Does it work if you do
deno install -e main.tsinstead ofdeno install?
Doesn't work either in my case.
Can confirm it does not work to me either
rm -rf ~/.cache/deno && deno install -e main.ts && deno compile --cached-only main.ts
error: Specifier not found in cache: "https://jsr.io/@std/yaml/1.0.5/_type.ts", --cached-only is specified.
at https://jsr.io/@std/yaml/1.0.5/_loader_state.ts:40:37
Hey @nathanwhit thx, for taking a look at this issue. Tried locally and it fixed the issue i had in here: https://github.com/denoland/deno/issues/26180#issuecomment-2426242386, but it did not for when: deno.json
{
...
"compilerOptions": {
"jsx": "precompile",
"jsxImportSource": "@hono/hono/jsx"
},
"lock": {
"frozen": true
},
"imports": {
"@hono/hono": "jsr:@hono/[email protected]",
...
}
}
which still gives the error:
rm -rf ~/.cache/deno && ~/repos/deno/target/debug/deno install && ~/repos/deno/target/debug/deno run -A --cached-only src/apps/web/main.ts
error: Specifier not found in cache: "https://jsr.io/@hono/hono/4.6.5/src/jsx/jsx-runtime.ts", --cached-only is specified.
at file:///home/main/devs/rss-hub/src/apps/web/app.tsx:1:1
without the cached flag --cached-only it downloads the missing files, which i expected the deno instal would already do for me:
Download https://jsr.io/@hono/hono/4.6.5/src/jsx/jsx-runtime.ts
Download https://jsr.io/@hono/hono/4.6.5/src/adapter/deno/index.ts
Download https://jsr.io/@hono/hono/4.6.5/src/middleware/basic-auth/index.ts
Download https://jsr.io/@hono/hono/4.6.5/src/middleware/jsx-renderer/index.ts
Download https://jsr.io/@hono/hono/4.6.5/src/http-exception.ts
Download https://jsr.io/@hono/hono/4.6.5/src/middleware/secure-headers/secure-headers.ts
Download https://jsr.io/@hono/hono/4.6.5/src/helper/streaming/index.ts
Download https://jsr.io/@m4rc3l05/requester/0.5.0/src/composers/mod.ts
Download https://jsr.io/@hono/hono/4.6.5/src/jsx/jsx-dev-runtime.ts
Download https://jsr.io/@hono/hono/4.6.5/src/helper/html/index.ts
Download https://jsr.io/@hono/hono/4.6.5/src/jsx/utils.ts
Download https://jsr.io/@hono/hono/4.6.5/src/adapter/deno/serve-static.ts
Download https://jsr.io/@hono/hono/4.6.5/src/adapter/deno/ssg.ts
Download https://jsr.io/@hono/hono/4.6.5/src/adapter/deno/websocket.ts
Download https://jsr.io/@hono/hono/4.6.5/src/adapter/deno/conninfo.ts
Download https://jsr.io/@hono/hono/4.6.5/src/utils/basic-auth.ts
Download https://jsr.io/@hono/hono/4.6.5/src/utils/buffer.ts
Download https://jsr.io/@hono/hono/4.6.5/src/jsx/index.ts
Download https://jsr.io/@hono/hono/4.6.5/src/jsx/streaming.ts
Download https://jsr.io/@hono/hono/4.6.5/src/utils/encode.ts
Download https://jsr.io/@hono/hono/4.6.5/src/helper/streaming/stream.ts
Download https://jsr.io/@hono/hono/4.6.5/src/helper/streaming/sse.ts
Download https://jsr.io/@hono/hono/4.6.5/src/helper/streaming/text.ts
Download https://jsr.io/@m4rc3l05/requester/0.5.0/src/composers/retry.ts
Download https://jsr.io/@m4rc3l05/requester/0.5.0/src/composers/timeout.ts
Download https://jsr.io/@m4rc3l05/requester/0.5.0/src/composers/delay.ts
Download https://jsr.io/@m4rc3l05/requester/0.5.0/src/composers/skip.ts
Download https://jsr.io/@hono/hono/4.6.5/src/jsx/base.ts
Download https://jsr.io/@hono/hono/4.6.5/src/middleware/serve-static/index.ts
Download https://jsr.io/@hono/hono/4.6.5/src/helper/ssg/index.ts
Download https://jsr.io/@hono/hono/4.6.5/src/utils/crypto.ts
Download https://jsr.io/@hono/hono/4.6.5/src/jsx/children.ts
Download https://jsr.io/@hono/hono/4.6.5/src/jsx/components.ts
Download https://jsr.io/@hono/hono/4.6.5/src/jsx/context.ts
Download https://jsr.io/@hono/hono/4.6.5/src/jsx/dom/hooks/index.ts
Download https://jsr.io/@hono/hono/4.6.5/src/jsx/hooks/index.ts
Download https://jsr.io/@hono/hono/4.6.5/src/jsx/constants.ts
Download https://jsr.io/@hono/hono/4.6.5/src/jsx/dom/components.ts
Download https://jsr.io/@hono/hono/4.6.5/src/jsx/dom/render.ts
Download https://jsr.io/@hono/hono/4.6.5/src/utils/stream.ts
Download https://jsr.io/@hono/hono/4.6.5/src/jsx/intrinsic-element/common.ts
Download https://jsr.io/@hono/hono/4.6.5/src/jsx/intrinsic-element/components.ts
Download https://jsr.io/@hono/hono/4.6.5/src/utils/compress.ts
Download https://jsr.io/@hono/hono/4.6.5/src/utils/filepath.ts
Download https://jsr.io/@hono/hono/4.6.5/src/helper/ssg/ssg.ts
Download https://jsr.io/@hono/hono/4.6.5/src/helper/ssg/middleware.ts
Download https://jsr.io/@hono/hono/4.6.5/src/jsx/dom/context.ts
Download https://jsr.io/@hono/hono/4.6.5/src/jsx/dom/jsx-runtime.ts
Download https://jsr.io/@hono/hono/4.6.5/src/utils/concurrent.ts
Download https://jsr.io/@hono/hono/4.6.5/src/helper/ssg/utils.ts
Download https://jsr.io/@hono/hono/4.6.5/src/jsx/dom/utils.ts
Download https://jsr.io/@hono/hono/4.6.5/src/jsx/dom/jsx-dev-runtime.ts
Download https://jsr.io/@hono/hono/4.6.5/src/utils/handler.ts
Download https://jsr.io/@hono/hono/4.6.5/src/jsx/dom/intrinsic-element/components.ts
Also, on another project with the following deno.json
{
...
"compilerOptions": {
"lib": ["DOM", "deno.ns"],
"jsx": "react-jsx"
},
"lock": {
"frozen": true
},
"imports": {
"@david/dax": "jsr:@david/[email protected]",
"@luca/esbuild-deno-loader": "jsr:@luca/[email protected]",
"@mjackson/multipart-parser": "jsr:@mjackson/[email protected]",
"@std/cli": "jsr:@std/[email protected]",
"@std/path": "jsr:@std/[email protected]",
"esbuild": "npm:esbuild@^0.24.0",
"node-taglib-sharp": "npm:[email protected]",
"react": "npm:[email protected]",
"react-bootstrap": "npm:[email protected]",
"react-dom": "npm:[email protected]"
}
}
i am doing cross compilation and if i specify a target different from my os (linux in my case) i get an error as well
rm -rf ~/.cache/deno && ~/repos/deno/target/debug/deno install && ~/repos/deno/target/debug/deno compile --cached-only --target=x86_64-pc-windows-msvc src/main
.ts
error: Failed caching npm package '@esbuild/[email protected]'.
0: An npm specifier not found in cache: "@esbuild/win32-x64", --cached-only is specified.
and again like above without the cached flag it downloads the missing files, which i expected the deno instal would already do for me:
Download https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.24.0.tgz
Check file:///home/main/devs/denotag/src/main.ts
Compile file:///home/main/devs/denotag/src/main.ts to src.exe
Download https://dl.deno.land/release/v2.0.2/denort-x86_64-pc-windows-msvc.zip
Am i doing something wrong? am i missing something?
cc: @bartlomieju @lucacasonato
Ah, so the first issue is https://github.com/denoland/deno/issues/26498. We only cache the root export of @hono/hono, so we miss stuff like @hono/hono/jsx @hono/hono/adapter/deno and all of those files. I've opened a PR for that, you can follow that issue for updates.
The second issue comes out of the fact that we only install packages for the current system.
For that I've opened https://github.com/denoland/deno/issues/26500, as that would likely need to be a new flag to deno install.
@nathanwhit It seems that now deno install fails with:
rm -rf ~/.cache/deno && ~/repos/deno/target/debug/deno install
error: Expected a JavaScript or TypeScript module, but identified a Json module. Consider importing Json modules with an import attribute with the type of "json".
Specifier: https://jsr.io/@std/html/1.0.3/named_entity_list.json
I am not importing the file directly in my code, so i assume this is something breaking on the install process, where it does not properly handle json exports?
Ah good catch, I didn’t even realize JSR packages could have JSON exports. Opened #26509, I’ll take a look at it tomorrow