diff --git a/src/nimble.nim b/src/nimble.nim index 0d93af9..56a3b93 100644 --- a/src/nimble.nim +++ b/src/nimble.nim @@ -336,6 +336,7 @@ proc removePkgDir(dir: string, options: Options) = removeFile(options.getBinDir() / binary.str) # Search for an older version of the package we are removing. + # So that we can reinstate its symlink. let (pkgName, _) = getNameVersion(dir) let pkgList = getInstalledPkgsMin(options.getPkgsDir(), options) var pkgInfo: PackageInfo @@ -818,7 +819,7 @@ proc uninstall(options: Options) = for pkgTup in options.action.packages: display("Looking", "for $1 ($2)" % [pkgTup.name, $pkgTup.ver], priority = HighPriority) - let installedPkgs = getInstalledPkgs(options.getPkgsDir(), options) + let installedPkgs = getInstalledPkgsMin(options.getPkgsDir(), options) var pkgList = findAllPkgs(installedPkgs, pkgTup) if pkgList.len == 0: raise newException(NimbleError, "Package not found") @@ -912,10 +913,12 @@ proc developFromDir(dir: string, options: Options) = # `nimble develop` if they change their `srcDir` but I think it's a worthy # compromise. let contents = pkgInfo.myPath & "\n" & pkgInfo.getRealDir() - writeFile(pkgDestDir / pkgInfo.name.addFileExt("nimble-link"), contents) + let nimbleLinkPath = pkgDestDir / pkgInfo.name.addFileExt("nimble-link") + writeFile(nimbleLinkPath, contents) # Save a nimblemeta.json file. - saveNimbleMeta(pkgDestDir, "file://" & dir, vcsRevisionInDir(dir)) + saveNimbleMeta(pkgDestDir, "file://" & dir, vcsRevisionInDir(dir), + nimbleLinkPath) # Save the nimble data (which might now contain reverse deps added in # processDeps). diff --git a/src/nimblepkg/packageinstaller.nim b/src/nimblepkg/packageinstaller.nim index d34a9a7..e48a910 100644 --- a/src/nimblepkg/packageinstaller.nim +++ b/src/nimblepkg/packageinstaller.nim @@ -94,7 +94,7 @@ proc saveNimbleMeta*(pkgDestDir, url, vcsRevision: string, nimblemeta["isLink"] = %isLink writeFile(pkgDestDir / "nimblemeta.json", $nimblemeta) -proc saveNimbleMeta*(pkgDestDir, pkgDir, vcsRevision: string) = +proc saveNimbleMeta*(pkgDestDir, pkgDir, vcsRevision, nimbleLinkPath: string) = ## Overload of saveNimbleMeta for linked (.nimble-link) packages. ## ## pkgDestDir - The directory where the package has been installed. @@ -103,4 +103,4 @@ proc saveNimbleMeta*(pkgDestDir, pkgDir, vcsRevision: string) = ## pkgDir - The directory where the original package files are. ## For example: ~/projects/jester/ saveNimbleMeta(pkgDestDir, "file://" & pkgDir, vcsRevision, - initSet[string](), initSet[string](), true) \ No newline at end of file + toSet[string]([nimbleLinkPath]), initSet[string](), true) \ No newline at end of file diff --git a/tests/tester.nim b/tests/tester.nim index 986c87f..ad8906a 100644 --- a/tests/tester.nim +++ b/tests/tester.nim @@ -507,4 +507,14 @@ suite "develop feature": let (output, exitCode) = execNimble("c", "-r", "src/dependent.nim") checkpoint output check(output.processOutput.inLines("hello")) - check exitCode == QuitSuccess \ No newline at end of file + check exitCode == QuitSuccess + + test "can uninstall linked package": + cd "develop/srcdirtest": + let (_, exitCode) = execNimble("develop", "-y") + check exitCode == QuitSuccess + + let (output, exitCode) = execNimble("uninstall", "-y", "srcdirtest") + checkpoint(output) + check exitCode == QuitSuccess + check(not output.processOutput.inLines("warning"))