Workiva / dpx

Apache License 2.0
1 stars 0 forks source link

Running dpx with a package globally activated with -spath, prompts for install #16

Open matthewnitschke-wk opened 3 months ago

matthewnitschke-wk commented 3 months ago

Please include the following information:

  • Dart SDK version (dart --version): 2.19.6
  • dpx version (dpx --version): 0.0.0

If I have a dart package installed locally on my machine (via dart pub global activate -spath ./path/to/dart/package), running dpx cmd_name will still prompt for installation event though its available

# install via -spath
$ dart pub global activate -spath ./scip-dart

# run via dpx
$ dpx scip_dart ./
Need to install the following packages:
scip_dart
Ok to proceed? (y/n)

Is this functionality expected? I would anticipate dpx to prioritize whatever is installed globally, regardless of how it was installed

evanweible-wf commented 3 months ago

Good question! Currently the logic that checks for a matching package is more conservative and requires that the already-active package be hosted from the same pub server as the requested package: https://github.com/Workiva/dpx/blob/7c512c44c897cf26edb5ee34c60bce5cf15c2edc/lib/src/find_reusable_package.dart#L17

Maybe that's not necessary. We could just check if the package name matches and then check if the version constraint is satisfied (if specified)?

matthewnitschke-wk commented 3 months ago

Ah, that makes sense, and could be understandable from a security perspective

Do we know what npx does in this case? might make sense to just mirror that since its a derivative of that tool