denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
96.72k stars 5.34k forks source link

`deno install` does not cache all dep files. #26180

Open M4RC3L05 opened 1 week ago

M4RC3L05 commented 1 week ago

Hi, Given the following deno.json file

{
  // ...
  "lock": {
    "frozen": true
  },
  "imports": {
    "@david/dax": "jsr:@david/dax@0.42.0",
    "@std/cli": "jsr:@std/cli@1.0.6",
    "@std/path": "jsr:@std/path@^1.0.6",
    "@std/yaml": "jsr:@std/yaml@1.0.5"
  }
}

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

M4RC3L05 commented 1 week ago

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/hono@4.6.2",
    ...
  }
}
AFCMS commented 1 week ago

Probably the real error behind my problem https://github.com/denoland/std/issues/6108

bartlomieju commented 1 week ago

@dsherret please take a look

M4RC3L05 commented 5 days ago

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
lucacasonato commented 1 day ago

Does it work if you do deno install -e main.ts instead of deno install?

AFCMS commented 1 day ago

Does it work if you do deno install -e main.ts instead of deno install?

Doesn't work either in my case.

M4RC3L05 commented 1 day ago

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