Skip to content

bug: deno install -g fails to install local files if they are not prefixed with ./ if npm or jsr pkg exists with same name #26969

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

Closed
KnorpelSenf opened this issue Nov 21, 2024 · 6 comments · Fixed by #26975
Labels
bug Something isn't working correctly install

Comments

@KnorpelSenf
Copy link
Contributor

#26629 caused a regression in 2.1.0 that prevents deno install -g from handling local files correctly.

Repro

echo 'console.log("hi");' > cli.ts
deno install -g --name my-cli cli.ts

Expected Result

The program is installed correctly and I can use cli.ts as a globally installed CLI.

Actual Result

error: cli.ts is missing a prefix. Did you mean `deno install -g npm:cli.ts`?

With Deno 2.0.6, everything works as expected. However, since Deno 2.1.0, the above error is thrown.

Ideally, I would like the previous functionality to keep on working. Bare filenames are supported everywhere else and it is just bad DX not to do it here.

On the other hand, if you want to enfore a prefix even for local files for some reason, then this still has to be fixed. The error is nonsense. It should not suggest an import from npm but rather suggest me to prefix the path with ./.

But I believe that the whole point of prefixing jsr/npm imports was to be able to support local files cleanly, so I assume that the behaviour from 2.0.6 can just be restored.

@dsherret dsherret added bug Something isn't working correctly install labels Nov 21, 2024
@dsherret dsherret changed the title bug: deno install -g fails to install local files if they are not prefixed with ./ bug: deno install -g fails to install local files if they are not prefixed with ./ if npm or jsr pkg exists with same name Nov 21, 2024
@dsherret
Copy link
Member

This occurs because https://www.npmjs.com/package/cli.ts exists

@KnorpelSenf
Copy link
Contributor Author

Are you saying that the Deno CLI first contacts the npm registry before even checking for the file on disk? 🫠

@bartlomieju
Copy link
Member

Yes, it's a regression that I didn't catch in code review.

@mbrdg
Copy link
Contributor

mbrdg commented Nov 21, 2024

I'm already rolling a change to fix this.

@dsherret
Copy link
Member

@mbrdg there's a fix #26975

@KnorpelSenf
Copy link
Contributor Author

Thanks for the super fast turnaround time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly install
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants