Hi all, trying out pants in a monorepo, with Go &a...
# general
c
Hi all, trying out pants in a monorepo, with Go & Python. When running
pants tailor ::
I get
KeyError: 'Version'
. More details in the thread
pants version is 2.19.1, stacktrace is
Copy code
...
"/Users/ed/Library/Caches/nce/b53192ff83dd22c11f093268f09503786fcdeb806b34ecf4d2e519c915578288/bindings/venvs/2.19.1/lib/python3.9/site-packages/pants/backend/go/util_rules/third_party_pkg.py", line 235, in analyze_module_dependencies
    version = mod_json["Replace"]["Version"]
KeyError: 'Version'
Code does ensure that
Replace
key is present, but it doesn't check for version:
Copy code
for mod_json in ijson.items(mod_list_result.stdout, "", multiple_values=True):
        # Skip the first-party module being analyzed.
        if "Main" in mod_json and mod_json["Main"]:
            continue

        if "Replace" in mod_json:
            # TODO: Reject local file path replacements? Gazelle does.
            name = mod_json["Replace"]["Path"]
            version = mod_json["Replace"]["Version"]
        else:
            name = mod_json["Path"]
            version = mod_json["Version"]
I wonder if issue could be as simple that code assumes
replace
in go module has version? It is not mandatory as per https://go.dev/doc/modules/gomod-ref#replace
Found an existing ticket which is exactly the same error
Trying to find any kind of fix. Obviously most simple attempt to use
mod_json["Replace"].get("Version")
doesn't help, because
None
is not valid version identifier. Empty string (using
.get("")
doesn't help either)
Edit: seems like removing all BUILD worked, now rerunning
pants tailor ::
doesn't complain anything 🤔 Edit2: issue still remains, if I remove all buildfiles and use
pants tailor ::
to generate those, it succeeds. But if I then run
pants tailor ::
then it fails with
cannot use relative path ../<reponame>@latest
ok, found this year old thread which I interprete as follows: • Go code should not use relative paths in
replace
or • we should find people willing to work on Go part not enough familiar with Pants, so not sure where to start if I'd want to fix it. Sad in a way that relative paths are not allowed, as to me it seems like it is one reason why people create monorepos; to avoid versioning, because as long as you deploy all linked projects together in a monorepo, you don't need internal versioning of parts
h
We'd welcome a fix for this if you're willing to dive in! We can provide some high-level guidance. Alternatively, I believe @fast-nail-55400 may be available for Go consulting work in this area to either guide or do the work.
🙏 1
c
I'd like to give it a shot, but would really appreciate help there. And I have to say, like website advertises the community is friendly ☺️ Thank you!
❤️ 1
h
I think we can continue the discussion on the ticket at https://github.com/pantsbuild/pants/issues/14996 ?
👍 1
I'll respond over there
h
Hi guys, I'm having the same issue. Does this issue still persist?
f
Probably since I don't recall anyone fixing it.
h
I think this will require someone who is invested enough in Go to either do the work or sponsor the work
@curved-hydrogen-24259 any interest still in tackling this?
h
What does sponsoring look like?
h
That’s a good question - we’re currently looking at various models for this. One thing that has come up is a “feature bounty”, like a bug bounty but for feature development. Is that something your organization might be interested in?
h
Do you have more details on the pricing? We are more like a startup
h
No this is all still at the ideas stage. But ideally multiple companies would contribute, so it wouldn’t fall so much on any one. Apparently there are websites that manage this sort of thing, like kickstarter for development, so we’re looking at that
c
@curved-hydrogen-24259 any interest still in tackling this?
Sorry wouldn't be able to now, as it's quite unfamiliar with the details and would take too much time for me to even figure out how 😞 Thanks for asking though
👍 1