Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use "nimble develop" AND "nimble develop -g" #1124

Open
enthus1ast opened this issue Jul 18, 2023 · 9 comments
Open

How to use "nimble develop" AND "nimble develop -g" #1124

enthus1ast opened this issue Jul 18, 2023 · 9 comments

Comments

@enthus1ast
Copy link

enthus1ast commented Jul 18, 2023

Can you explain (and possibly show an example workflow) how to actually use
the new nimble develop and the old nimble develop -g?

$ nim --version
Nim Compiler Version 1.9.5 [Linux: amd64]
Compiled at 2023-07-17
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: 17915d93bfb50aaff6c4bf77fe25707705e557c8
active boot switches: -d:release

$ nimble --version
nimble v0.14.2 compiled at 2023-07-17 01:23:08
git hash: couldn't determine git hash

Old

Since nimble develop -g should be the old workflow
i suspect it to be:

  1. go into the new module's folder
  2. nimble develop -g
  3. use the new module from another module

Unfortunately this does not work.
The package is unknown to the importing module.

The link file however is generated.

$ cd testp
$ git init 
$ git add * 
$ git commit -m "init"
$ nimble develop -g
  Verifying dependencies for [email protected]
  Success:  Package link file "/home/david/.nimble/links/testp-#head/testp.nimble-link" is saved.
  Success:  "testp" set up in develop mode successfully to "/home/david/projects/testp".


$ pwd
/home/david/.nimble/links
$ cat testp-#head/testp.nimble-link 
/home/david/projects/testp/testp.nimble
/home/david/projects/testp

In another package i do:

import tesp

compile it:

nim c -r anotherFile.nim
anotherFile.nim(1, 36) Error: cannot open file: testp

BTW: Is there a way to display the nim path the compiler uses?

New

I'm completely puzzled how to use the new develop way (with local modules). [got it somehow working, see later]

i tried:

david@dnd:~/projects/testp$ nimble develop
  Verifying dependencies for [email protected]
  Success:  "testp" set up in develop mode successfully to "/home/david/projects/testp".

nim c -r anotherFile.nim
anotherFile.nim(1, 36) Error: cannot open file: testp

i tried:

$ cd anotherModule
$ nimble develop /home/david/projects/testp

    Prompt: /home/david/projects/testp not found in any local packages.json, check internet for updated packages? [y/N]

i tried:

$ nimble develop -a:/home/david/projects/testp
  Success:  The package "[email protected]" at path "/home/david/projects/testp" is added to the develop file "nimble.develop".
$ nim c anotherFile.nim 
Hint: used config file '/home/david/.choosenim/toolchains/nim-#devel/config/nim.cfg' [Conf]
Hint: used config file '/home/david/.choosenim/toolchains/nim-#devel/config/config.nims' [Conf]
Hint: used config file '/home/david/projects/nimInformer/src/config.nims' [Conf]
.........................................................................................................
anotherFile.nim(1, 36) Error: cannot open file: testp

$ echo requires "testp" >> otherFile.nimble
$ nimble build
# .. this picks up testp and builds the project

But this only works through nimble.
It does not work when i just compile the nim file with the compiler.

$ nim c -r otherFile.nim
otherFile.nim(1, 36) Error: cannot open file: testp

How can i make it work just with the nim compiler, so without creating a nimble package for
every single Nim file i want to compile? (i literally have thousands of stand alone nim files, that are not in a project folder, that would all not work with the new nim develop, since they all use locally developed modules)
So how the old nimble develop worked (since it does not work like this any more)

The (actual) old behavior:

It seems the (actual) old behavior is either broken, or not supported any more.
This is what it was before:

$ choosenim stable
   Switched to Nim 1.6.14

$ cd /home/david/projects/testp
$ nimble develop
$ cd otherFile
$ nim c -r otherFile # <----- it works from JUST nim! 

Could i maybe set the nim path to my whole project folder for the nim devel compiler?

@treeform
Copy link

treeform commented Aug 3, 2023

I don't get it either:

cd netty
nimble develop -g
cd ../myproject
nim c -r src/myproject.nim
Error: cannot open file: netty

WUT?

Please revert to the old nimble develop behavior.

@enthus1ast
Copy link
Author

enthus1ast commented Aug 4, 2023

@treeform

It seems to work when you use

nimble build

instead of the compiler. The compiler does not pick it up unfortunately.
My problem with this is, i have literally thousands of single nim files, not as nimble package, that would not compile now.

@HugoGranstrom
Copy link

This is really annoying :/ I'm also running a lot of files through the compiler directly (nim r file.nim) when working in nimib. So now it has become much harder for me to make updates to the library and see its effects on the generated document. Having to repeat the installation procedure after every single little update I make is a horrible user experience. Bring the REAL old nimble develop behavior back!

@autumngray
Copy link

I think I understand the issue now. Two problems seem to play into it:

  1. Changed search path: Nimble now uses a 'nimble-link' file format to locate the package. When doing nimble develop -g a link file is saved under $NIMBLEPATH/links/<package-ver>/<package>.nimble-link and nim then locates that using --nimblepath. However, the default nim.cfg was not updated, it should contain a line like:
    nimblepath="$home/.nimble/links/"
  2. link-file doesn't account for srcDir: The nimble repo has a test for "develop global" but it only tests with a flat package without a "src" directory. The second line in a nimble-link file always contains the directory in which the .nimble file is located and the nim compiler uses that as root dir to locate the packages' .nim files.

After I added the missing configuration and edited the .nimble-link file to point to the srcDir, I could successfully import the package. However, nimble then complained about the nimble-link file having an invalid format, so I'm a unsure what the correct fix should be...

@cvanelteren
Copy link

@autumngray could you expand a bit on your fix. I can see the .nimble-link file pointing to my package (without a src reference), but I have some difficulties to understand what you mean with added the missing configuration.

@nitely
Copy link

nitely commented May 4, 2024

So one way I got this working is to run nimble develop package_name inside the package that depends on package_name, that will clone the package_name repo into the current package, then remove it and create a symlink to your local package_name.

Not sure how to do it if package_name is not published.

Edit: the above may not be needed. Apparently if you add --path:"/home/myuser/projects/dependency-package-name/src" to nimble.paths file generated by nimble setup it finds the local package.

Edit2: the above may also not be needed. Just create a config.nims file in your package/project root and add:

--noNimblePath
--path:"/home/myuser/projects/dependency-package-name/src"

it's what nimble setup + nimble develop package_name does. The --noNimblePath likely needs to be removed.

^ this is just a workaround, the develop -g fix is what @autumngray suggested IMO.

@sainttttt
Copy link

@nitely So this works but it breaks loading any other nimble packages from me (globally installed packages)

@nitely
Copy link

nitely commented Jul 4, 2024

I think I had that issue. Try removing the --noNimblePath line

@sainttttt
Copy link

@nitely That works!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants