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

deno.json not used as config by default when installing global script #26212

Closed
annervisser opened this issue Oct 13, 2024 · 2 comments
Closed
Labels
duplicate a duplicate of another issue

Comments

@annervisser
Copy link

When installing a local typescript file as a global script,
the default behaviour is to not take the deno.json in the same folder into account.

This is unexpected, since the documentation for the --config options says:

Typically the configuration file will be called deno.json or deno.jsonc and
automatically detected; in that case this flag is not necessary.

This results in confusing behaviour, and discrepancies between deno run main.ts and deno install --global --name my-script main.ts && my-script

Example:

cd ~/my-script-repo
deno install --global --name my-script main.ts

Expected behaviour

  • Running my-script should run ~/my-script-repo/main.ts it using ~/my-script-repo/deno.json

Actual behaviour:

  • Running my-script runs ~/my-script-repo/main.ts with no/the global deno configuration.

I've uploaded a reproduction at https://github.com/annervisser/deno-relative-import-repro

Version: deno 2.0.0 (stable, release, x86_64-unknown-linux-gnu)
v8 12.9.202.13-rusty
typescript 5.6.2

@annervisser annervisser changed the title deno.json not used as config by default when installing local file as global script deno.json not used as config by default when installing global script Oct 14, 2024
@annervisser
Copy link
Author

I've realized this is also the case when installing a package globally from deno.land,
which is a bigger problem since you can't work around it by specifying --config.

Example:

deno install --reload --force --global --name pr-cli --allow-run --allow-read --allow-env https://deno.land/x/prcli/main.ts

When running pr-cli, the following error is output:

error: Relative import path "@std/log" not prefixed with / or ./ or ../
    at https://deno.land/x/[email protected]/main.ts:6:22

This is once again caused by deno not using the deno.json of that package as its config

@dsherret
Copy link
Member

Duplicate of #17572

See #17855 for improving this.

deno install --reload --force --global --name pr-cli --allow-run --allow-read --allow-env https://deno.land/x/prcli/main.ts

Deno never auto-discovers configuration files in https dependencies. I'd recommend publishing to JSR instead because it handles publishing code with the config inlined.

@dsherret dsherret closed this as not planned Won't fix, can't repro, duplicate, stale Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate a duplicate of another issue
Projects
None yet
Development

No branches or pull requests

2 participants