nim-lang / nimble

Package manager for the Nim programming language.
https://nim-lang.github.io/nimble/index.html
Other
1.25k stars 191 forks source link

Invalid section: . #665

Closed pb-cdunn closed 5 years ago

pb-cdunn commented 5 years ago
% /mnt/software/n/nim/0.20.0/Nim/bin/nimble --debug install
   Warning: Using the environment variable: NIMBLE_DIR='/pbi/flash/cdunn/repo/nim-pb/nimbleDir'
     Error: Could not read package info file in /pbi/flash/cdunn/repo/nim-falcon/repos/msgpack4nim/msgpack4nim.nimble;
        ...   Reading as ini file failed with:
        ...     Invalid section: .
        ...   Evaluating as NimScript file failed with:
        ...     Invalid section: .

That happens with the nimble in 0.20 on devel. Different versions of nimble work fine for me. Could I have done something wrong?

pb-cdunn commented 5 years ago

If I copy a working foo.nimble from another repo, it fails here. That means the actual failure is not in the .nimble file itself. Something else in the directory is the problem. I need much more information to debug this.

Here is the repo: https://github.com/jangko/msgpack4nim

Maybe someone else could figure out the problem?

pb-cdunn commented 5 years ago

Yeah, if I copy the "bad" .nimble into a different repo, it works fine there. So there is a problem in the directory, is nimble is not tell me.

pb-cdunn commented 5 years ago

I've copied my older nimble, built as part of nim-0.19, and it's working fine. I think there is a pretty serious problem with nimble in the 0.20.0 release.

dom96 commented 5 years ago

@genotrance can you take a look?

genotrance commented 5 years ago

I just tried this in multiple ways and didn't see any issue with that package. It works with NIMBLE_DIR set, with --nimbleDir and without as well. I tried on Ubuntu.

I presume you were in /pbi/flash/cdunn/repo/nim-falcon/repos/msgpack4nim directory when you ran those commands.

genotrance commented 5 years ago

Note that nimble now needs nim in the path to process the nimble file since it no longer embeds the compiler. It seems you are running nimble by providing the full path.

@dom96 - seems like we need a --nim flag like testament or allow adding nim location in the ini file to support this usage.

genotrance commented 5 years ago

@pb-cdunn can you please confirm if Nim isn't in the path and if you add it, it works for you?

pb-cdunn commented 5 years ago

nim is in $PATH for sure. I was getting nim and nimble from the same directory.

I'm disappointed that this is not reproducible. I can't spend a huge amount of time on each new Nim installation. I simply installed Nim as I've always done -- from csources -- and hit this strange problem. So I copied an old nimble into Nim/bin and it worked.

When I have time, I will try another full Nim installation from devel and see if it happens again. I have not had a problem using nimble from GitHub, so I assumed there was a problem with how the Nim release acquires Nimble source-code.

ghost commented 5 years ago

I just ran into this one. Clearing /tmp/nimblecache worked for me. The pkgxyz.ini were full of weird escaped debug output from when I was debugging the compiler. I vaguely remember the no-compiler PR passing info via stdin/stderr so maybe connected?

genotrance commented 5 years ago

@dumjyl - can you please clarify further? Are you saying the ini file generated by nocompiler was garbled? How is this connected to stdout? Is there some known issue in 0.20.0?

@pb-cdunn - can you please share the contents of /tmp/nimblecache/msgpack4nim-* if you can still reproduce the issue? And then delete /tmp/nimblecache and try again?

ghost commented 5 years ago

Are you saying the ini file generated by nocompiler was garbled?

The file looks like this:

{
  "kind": "tyRange",
  "id": 3606,
  "sym": {
    "kind": "skType",
    "name": "Positive",

# ... more ast output ...

      "kind": "nkIntLit",
      "intVal": 9223372036854775807
    }]
  }
}
[Package]
version: """0.10.2"""
author: """Dominik Picheta"""
description: """Nim package manager."""
license: """BSD"""
srcdir: """src"""
backend: """c"""
installExt: "nim"
bin: "nimble"

[Deps]
requires: "nim >= 0.13.0"

How is this connected to stdout?

That output is from this https://github.com/nim-lang/Nim/blob/devel/compiler/astalgo.nim#L34 which outputs via stdout. This is for debugging the compiler and should not make it into a real/release version of the compiler, but could be a way to reproduce the issue. The stderr/stdout comment was partly speculation from a comment that I kinda remember from irc. I realize the 'weird escaping' is just terminal coloring.

Is there some known issue in 0.20.0?

This was from debugging something unrelated to this nimble issue. So nothing relevant.

Hopefully this is more helpful.

genotrance commented 5 years ago

This basically suggests not using stdout for returning info to nimble from nim e since compiler could spit out random stuff that would garble the ini file.

Considering we use the outfile for json, I propose updating the code to use the same mechanism for printPkgInfo as well. That way, only the content generated will go into the ini file and not any other debug/warning info from the compiler.

@dom96 - please confirm and I'll make this update to make it more resilient.

pb-cdunn commented 5 years ago
% cat /tmp/nimblecache/falcon_6979361620520236082/falcon.ini
thisDir:/pbi/flash/cdunn/repo/nim-falcon
HELLO in nim-falcon/configs.nim
[Package]
version: """0.0.0"""
author: """Christopher Dunn"""

Yep, I think it's my debugging output from my config.nims:

% cat config.nims
#--parallelBuild:0
echo "thisDir:", thisDir()
--debuginfo
--listCmd
echo "HELLO in nim-falcon/configs.nim"
genotrance commented 5 years ago

I just pushed a branch with a fix for this - can you please verify?

https://github.com/genotrance/nimble/tree/nocompiler-fixes-3

pb-cdunn commented 5 years ago

Verified.

genotrance commented 5 years ago

Use koch --latest nimble to get this fix in an existing install.