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

dub add-local should affect dub run #2706

Closed
VPanteleev-S7 opened this issue Oct 5, 2023 · 6 comments
Closed

dub add-local should affect dub run #2706

VPanteleev-S7 opened this issue Oct 5, 2023 · 6 comments

Comments

@VPanteleev-S7
Copy link

VPanteleev-S7 commented Oct 5, 2023

Consider the situation:

  • There is a script which, somewhere deep inside, runs dub run
  • We would like to substitute that invocation with a provided copy of the package (e.g. because we need to run the script offline, or use a slightly modified version of the package being run)

So, if the script runs dub run some-package@1.2.3, we should be able to use dub add-local path/to/our/version/of/package 1.2.3 first to make the former command use the version specified in the latter command.

Alternatively, a hypothetical dub install --version=1.2.3 could install the package from the current directory into Dub's cache, so that dub run would then use it.

@WebFreak001
Copy link
Member

dub fetch package@1.2.3
dub run package@1.2.3

and add-local beforehand and using dub run package@1.2.3 should also work, did it not?

@VPanteleev-S7
Copy link
Author

dub fetch package@1.2.3

How to do this step without Internet access, if we have a copy of the package?

@WebFreak001
Copy link
Member

no need to run it at all, just only do the add-local one and it should work.

@VPanteleev-S7
Copy link
Author

Sorry, I don't understand what you mean. It doesn't work.

$ mkdir some-temp-directory && cd some-temp-directory
$ wget https://code.dlang.org/packages/dpp/0.5.5.zip
...
$ unzip 0.5.5.zip
...
$ HOME=$PWD dub add-local dpp-0.5.5 0.5.5
             Registered package: dpp (version: 0.5.5)
$ HOME=$PWD bwrap --dev-bind / / --unshare-net dub run dpp@0.5.5
     Warning Package dpp not found for registry at https://code.dlang.org/ (fallbacks registry at https://codemirror.dlang.org/, registry at https://dub.bytecraft.nl/, registry at https://code-mirror.dlang.io/): Failed to download https://code.dlang.org/api/packages/infos?packages=%5B%22dpp%22%5D&include_dependencies=true&minimize=true
Error No package dpp was found matching the dependency 0.5.5

(HOME=$PWD makes Dub use a fresh ~/.dub, bwrap --dev-bind / / --unshare-net effectively disables Internet access)

Geod24 added a commit to Geod24/dub that referenced this issue Jan 9, 2024
The code was overly complicated and failed to do what it intended.
If a version was provided, it would always call 'fetch' even though
getBestPackage would have returned something.
Assuming that sub-packages are always present is also not working,
as the following would fail:
$ rm -rf ~/.dub/packages/vibe-d && dub run vibe-d:data
    Warning Package 'vibe-d:data' was neither found locally nor online.
The new code is both shorter and simpler, taking advantage
of the various improvements made to the APIs over the year
(for example, getBestPackage with VersionRange.Any does the right thing).
Geod24 added a commit to Geod24/dub that referenced this issue Jan 9, 2024
The code was overly complicated and failed to do what it intended.
If a version was provided, it would always call 'fetch' even though
getBestPackage would have returned something.
Assuming that sub-packages are always present is also not working,
as the following would fail:
$ rm -rf ~/.dub/packages/vibe-d && dub run vibe-d:data
    Warning Package 'vibe-d:data' was neither found locally nor online.
The new code is both shorter and simpler, taking advantage
of the various improvements made to the APIs over the year
(for example, getBestPackage with VersionRange.Any does the right thing).
@Geod24
Copy link
Member

Geod24 commented Jan 9, 2024

@VPanteleev-S7 : Thanks for the test case. Fix is here: #2787

Geod24 added a commit to Geod24/dub that referenced this issue Jan 9, 2024
The code was overly complicated and failed to do what it intended.
If a version was provided, it would always call 'fetch' even though
getBestPackage would have returned something.
Assuming that sub-packages are always present is also not working,
as the following would fail:
$ rm -rf ~/.dub/packages/vibe-d && dub run vibe-d:data
    Warning Package 'vibe-d:data' was neither found locally nor online.
The new code is both shorter and simpler, taking advantage
of the various improvements made to the APIs over the year
(for example, getBestPackage with VersionRange.Any does the right thing).
@Geod24 Geod24 closed this as completed in d65decb Jan 9, 2024
@VPanteleev-S7
Copy link
Author

Awesome, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants