deno
e840a924 - fix(install): rewrite relative imports/scopes in copied deno.json (#34562)

Commit
107 days ago
fix(install): rewrite relative imports/scopes in copied deno.json (#34562) ## Summary `deno install -g -c deno.json` copies the supplied config into `<install_dir>/.<name>/deno.json` and points the generated shim at that copy. Relative `./` / `../` paths in `imports` and `scopes` were left intact, so `deno_config` resolved them against the new location and produced URLs pointing at non-existent files under the install directory. Running the installed binary then failed with `Module not found`, even though `--import-map` against the same paths worked. Before, for the example in the bug report: ```sh $ deno install --root=/usr/local -c deno.jsonc -f -n addd main.ts ✅ Successfully installed addd $ addd error: Module not found "file:///usr/local/bin/src/lib.ts". at file:///Users/ttaa/Desktop/test/main.ts:1:21 ``` After: ```sh $ deno install --root=/usr/local -c deno.jsonc -f -n addd main.ts ✅ Successfully installed addd $ addd invoke lib successfully ``` The copied `deno.json` now contains `"@/": "file:///Users/ttaa/Desktop/test/src/"` instead of `"@/": "./src/"`, so the imports keep pointing at the original project. Bare specifiers (`npm:`, `jsr:`, etc.) and already-absolute URLs are left untouched. Fixes #20390. Closes denoland/orchid#301 ## Test plan - [x] Added `tests/specs/install/global/config_file_relative_imports` reproducing the bug (the test fails on `main`). - [x] `cargo test --test specs -- specs::install::global::` — all install global tests pass. - [x] Manually verified the bug-report scenario reproduces and is fixed against the built binary. Co-authored-by: divybot <divybot@users.noreply.github.com> Co-authored-by: Divy Srivastava <me@littledivy.com>
Author
Parents
Loading