dub icon indicating copy to clipboard operation
dub copied to clipboard

dub add <packagename> ignores local packages

Open gitgit3 opened this issue 1 year ago • 0 comments

System information

  • DUB version 1.38.1, built on Jul 4 2024
  • Linux Mint 21 (ubuntu/debian) 5.15.0-107-generic 117-Ubuntu SMP (x86_64)

Bug Description

dub add <local_package> does not find the package. also, "dub list" does not list local packages. The list shows only the users .dub/packages directories and ignores anything inside the local-packages.json file which might exist in that location.

It is my understanding, from the docs and some experimenting, that using dub add-local <local_package_path> will create an entry in .dub/packages/local-packages.json. So this is not really an "add" package but rather a "register" package but I digress.

So after calling: dub add-local <local_package> I would expect to be able to list said package by: dub list and I would expect to be able to add a dependency to another project by calling: dub add <local_package>

In order to fix this, I need to edit the dub.json file and add an entry to the dependencies property: "dependencies": { "local_package": "~master" },

How to reproduce?

create a new <project_dep> using dub init create the source file <project_dep>/source<project_dep> edit the file and add module <project_dep>; and also create a short test function and then: dub build to check you have create a lib.a file

run: dub add-local <project_dep> which will (should) make the project_dep available as a dependency and creates an entry in .dub/packages/local-packages.json

next create a new <project_main> using dub init edit <project_main>/source/app.d and add the line import <project_dep>; and in main(), make a call to the function created in the <project_dep> project. now run: dub add <project_dep>

and there will be the error message Error Could not find package 'project_dep'.

Expected Behavior

I would expect the <project_dep> to be added to dub.json as: "dependencies": { "local_package": "~master" },

Indeed, if this added manually, then the project will compile using dub build.

gitgit3 avatar Jul 30 '24 12:07 gitgit3