Skip to content

Commit

Permalink
Change the name of the "pkgs" directory to "pkgs2"
Browse files Browse the repository at this point in the history
The names of the "nimbledata.json" file and "pkgs" directory are changed
correspondingly to "nimbledata2.json" and "pkgs2" in order to avoid the
need of removing the Nimble cache when changing between the new and old
Nimble versions.

Related to nim-lang#127
  • Loading branch information
bobeff authored and CyberTailor committed Dec 12, 2021
1 parent cb5ae44 commit 53770c8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 18 deletions.
22 changes: 11 additions & 11 deletions readme.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -816,9 +816,9 @@ Library packages are likely the most popular form of Nimble packages. They are
meant to be used by other library or binary packages.

When Nimble installs a library, it will copy all of its files
into ``$nimbleDir/pkgs/pkgname-ver``. It's up to the package creator to make sure
that the package directory layout is correct, this is so that users of the
package can correctly import the package.
into ``$nimbleDir/pkgs2/pkgname-ver-checksum``. It's up to the package creator
to make sure that the package directory layout is correct, this is so that users
of the package can correctly import the package.

It is suggested that the layout be as follows. The directory layout is
determined by the nature of your package, that is, whether your package exposes
Expand Down Expand Up @@ -868,9 +868,9 @@ bin = @["main"]
```

In this case when ``nimble install`` is invoked, Nimble will build the ``main.nim``
file, copy it into ``$nimbleDir/pkgs/pkgname-ver/`` and subsequently create a
symlink to the binary in ``$nimbleDir/bin/``. On Windows, a stub .cmd file is
created instead.
file, copy it into ``$nimbleDir/pkgs2/pkgname-ver-checksum/`` and subsequently
create a symlink to the binary in ``$nimbleDir/bin/``. On Windows, a stub .cmd
file is created instead.

The binary can be named differently than the source file with the ``namedBin``
table:
Expand Down Expand Up @@ -1096,7 +1096,7 @@ Nimble includes a ``publish`` command which does this for you automatically.
## Nimble's folder structure and packages

Nimble stores all installed packages and metadata in ``$HOME/.nimble`` by default.
Libraries are stored in ``$nimbleDir/pkgs``, and compiled binaries are linked in
Libraries are stored in ``$nimbleDir/pkgs2``, and compiled binaries are linked in
``$nimbleDir/bin``. The Nim compiler is aware of Nimble and will automatically
find modules so you can ``import modulename`` and have that working without
additional setup.
Expand Down Expand Up @@ -1146,13 +1146,13 @@ For example, if your Nimble directory is located at `/some/custom/path/nimble`,
this should work:

```
nim c --nimblePath:/some/custom/path/nimble/pkgs main.nim
nim c --nimblePath:/some/custom/path/nimble/pkgs2 main.nim
```

In the case of package local dependencies with ``nimbledeps``:

```
nim c --nimblePath:nimbledeps/pkgs main.nim
nim c --nimblePath:nimbledeps/pkgs2 main.nim
```

Some code editors rely on `nim check` to check for errors under the hood (e.g.
Expand All @@ -1162,12 +1162,12 @@ In this case, you will have to use the Nim compiler's configuration file capabil
Simply add the following line to the `nim.cfg` located in any directory listed
in the [documentation](https://nim-lang.org/docs/nimc.html#compiler-usage-configuration-files).
```
nimblePath = "/some/custom/path/nimble/pkgs"
nimblePath = "/some/custom/path/nimble/pkgs2"
```

For project local dependencies:
```
nimblePath = "$project/nimbledeps/pkgs"
nimblePath = "$project/nimbledeps/pkgs2"
```

## Troubleshooting
Expand Down
2 changes: 1 addition & 1 deletion src/nimblepkg/common.nim
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type

const
nimbleVersion* = "0.13.1"
nimblePackagesDirName* = "pkgs"
nimblePackagesDirName* = "pkgs2"
nimbleBinariesDirName* = "bin"

proc newNimbleError*[ErrorType](msg: string, hint = "",
Expand Down
6 changes: 1 addition & 5 deletions src/nimblepkg/nimbledatafile.nim
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type
ndjkRevDepPath = "path"

const
nimbleDataFileName* = "nimbledata.json"
nimbleDataFileName* = "nimbledata2.json"
nimbleDataFileVersion = 1

var isNimbleDataFileLoaded = false
Expand Down Expand Up @@ -55,10 +55,6 @@ proc loadNimbleData*(options: var Options) =

if fileExists(fileName):
options.nimbleData = parseFile(fileName)
if not options.nimbleData.hasKey($ndjkVersion):
raise nimbleError(
"You are working with an old version of Nimble cache repository.\n",
&"Please delete your \"{options.getNimbleDir()}\" directory.")
removeDeadDevelopReverseDeps(options)
displayInfo(&"Nimble data file \"{fileName}\" has been loaded.",
LowPriority)
Expand Down
2 changes: 1 addition & 1 deletion tests/tuninstall.nim
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,6 @@ suite "uninstall":

check execNimbleYes("uninstall", "PackageA@0.2", "issue27b").exitCode ==
QuitSuccess
check(not dirExists(installDir / "pkgs" / "PackageA-0.2.0"))
check(not dirExists(pkgsDir / "PackageA-0.2.0"))

check execNimbleYes("uninstall", "nimscript").exitCode == QuitSuccess

0 comments on commit 53770c8

Please sign in to comment.