Skip to content

Commit

Permalink
Additional information on Nim compiler integration (#554)
Browse files Browse the repository at this point in the history
* Additional information on Nim compiler integration

* Move the information to a dedicated section

Emphasize the fact that no extra step is required if using default `nimbleDir`.

* Adds changes requested

* NimblePath to nimblePath for consistency

* Update readme.markdown
technicallyagd authored and dom96 committed Dec 10, 2018
1 parent ba6577d commit 119be48
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion readme.markdown
Original file line number Diff line number Diff line change
@@ -733,7 +733,7 @@ installing your package (on macOS):
### Nim compiler

The Nim compiler cannot read .nimble files. Its knowledge of Nimble is
limited to the ``nimblePaths`` feature which allows it to use packages installed
limited to the ``nimblePath`` feature which allows it to use packages installed
in Nimble's package directory when compiling your software. This means that
it cannot resolve dependencies, and it can only use the latest version of a
package when compiling.
@@ -746,6 +746,27 @@ This means that you can safely compile using the compiler when developing your
software, but you should use Nimble to build the package before publishing it
to ensure that the dependencies you specified are correct.

### Compile with `nim` after changing the nimble directory

The Nim compiler has been preconfigured to look at the default nimble directory while compiling,
so no extra step is required to use nimble managed packages in your code.
However, if you are using a custom `nimbleDir`, you need to specify the
`--nimblePath:PATH` option. 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
```

Some code editors rely on `nim check` to check for errors under the hood (e.g. VScode),
and the editor extension may not allow users to pass custom option to `nim check`, which
will cause `nim check` to scream `Error: cannot open file:<the_package>`. In this case,
you will have to use [Nim compiler's configuration files](https://nim-lang.org/docs/nimc.html#compiler-usage-configuration-files). Simply add the line:
```
nimblePath = "/some/custom/path/nimble/pkgs"
```
to the `nim.cfg` located in any directory listed in the [documentation](https://nim-lang.org/docs/nimc.html#compiler-usage-configuration-files), this should resolve the problem.

### Versions

Versions of cloned packages via Git or Mercurial are determined through the

0 comments on commit 119be48

Please sign in to comment.