This has some benefits over the use of a globally activated dependency, as it allows the consuming project to specify the version of the tool to use.
If we look at the JS ecosystem, npx handles this by first checking for a local version of the requested package and using it if found, or falling back to installing it globally. This makes it possible for devs to use a command like npx prettier . --write to format their code without needing to care about whether the project they're working uses a specific version of prettier or not. If it does, npx prettier will use that locally installed version of prettier, otherwise it'll just use the latest version of prettier.
If we supported the same pattern, then Dart developers could, for example, always run dependency validation with dpx dependency_validator. If the package they're working on specifies dependency_validator in their dev_dependencies, dpx will use that version, otherwise it will install it globally and use that.
Some projects use executables from packages by installing them locally as a
dev_dependency
. For example:This has some benefits over the use of a globally activated dependency, as it allows the consuming project to specify the version of the tool to use.
If we look at the JS ecosystem,
npx
handles this by first checking for a local version of the requested package and using it if found, or falling back to installing it globally. This makes it possible for devs to use a command likenpx prettier . --write
to format their code without needing to care about whether the project they're working uses a specific version ofprettier
or not. If it does,npx prettier
will use that locally installed version of prettier, otherwise it'll just use the latest version ofprettier
.If we supported the same pattern, then Dart developers could, for example, always run dependency validation with
dpx dependency_validator
. If the package they're working on specifiesdependency_validator
in theirdev_dependencies
, dpx will use that version, otherwise it will install it globally and use that.