@@ -63,8 +63,8 @@ ReducedPackageInfo redubDownloadPackage(string packageName, string repo, string
6363 */
6464private ReducedPackageInfo getPackageInFolder (string folder, string packageName, string subPackage, string packageVersion)
6565{
66- import std.path ;
6766 import redub.misc.path;
67+ import std.path ;
6868 import std.file ;
6969 import std.algorithm.sorting ;
7070 import std.algorithm.iteration ;
@@ -114,7 +114,6 @@ private ReducedPackageInfo getPackageInFolder(string folder, string packageName,
114114PackageInfo getPackage (string packageName, string repo, string packageVersion, string requiredBy)
115115{
116116 import std.file ;
117- import std.path ;
118117 import redub.misc.path;
119118 import std.algorithm ;
120119 import std.array ;
@@ -170,11 +169,32 @@ private ReducedPackageInfo getPackageInJSON(JSONValue json, string packageName,
170169 {
171170 const (JSONValue)* nameJson = " name" in v;
172171 const (JSONValue)* ver = " version" in v;
173- SemVer packageVer = SemVer(ver.str) ;
174- if (nameJson && nameJson.str == packageName && packageVer.satisfies(requirement) )
172+ const (JSONValue) * pathJson = " path " in v ;
173+ if (nameJson)
175174 {
176- vlog(" Using local package found at " , v[" path" ].str, " with version " , ver.str);
177- return ReducedPackageInfo (ver.str, v[" path" ].str);
175+ if (! pathJson)
176+ {
177+ warn(" Corrupted JSON " , getLocalPackagesPath(), " local-packages.json must always have a 'path'" );
178+ continue ;
179+ }
180+ if (! ver)
181+ {
182+ static bool hasShown = false ;
183+ if (! hasShown)
184+ {
185+ warn(" dub add-path is not currently implemented. Please add your custom packages with dub add-local instead." ,
186+ " Warning generated for path " , pathJson.str,
187+ " . Local packages is at " , getLocalPackagesPath());
188+ hasShown = true ;
189+ continue ;
190+ }
191+ }
192+ SemVer packageVer = SemVer(ver.str);
193+ if (nameJson.str == packageName && packageVer.satisfies(requirement))
194+ {
195+ vlog(" Using local package found at " , pathJson.str, " with version " , ver.str);
196+ return ReducedPackageInfo (ver.str, pathJson.str);
197+ }
178198 }
179199 }
180200 return ReducedPackageInfo.init;
@@ -202,7 +222,7 @@ private ReducedPackageInfo getPackageInLocalPackages(string packageName, string
202222 return getPackageInJSON (localCache, packageName, packageVersion);
203223 }
204224 isCached = true ;
205- string locPackages = buildNormalizedPath(getDefaultLookupPathForPackages(), " local-packages.json " );
225+ string locPackages = getLocalPackagesPath( );
206226 if (std.file.exists (locPackages))
207227 localCache = parseJSON(std.file.readText (locPackages));
208228 return getPackageInLocalPackages (packageName, packageVersion);
@@ -260,6 +280,15 @@ private string getDefaultLookupPathForPackages()
260280 return buildNormalizedPath (getDubWorkspacePath, " packages" );
261281}
262282
283+ private string getLocalPackagesPath ()
284+ {
285+ import redub.misc.path;
286+ static string localPackages;
287+ if (! localPackages)
288+ localPackages = buildNormalizedPath(getDefaultLookupPathForPackages(), " local-packages.json" );
289+ return localPackages;
290+ }
291+
263292/**
264293 * Git style (~master)
265294 * Params:
0 commit comments