-
Notifications
You must be signed in to change notification settings - Fork 1k
"git.company.com:1234/group/project.git" is not a valid import path #411
Comments
One of my deps is on an internal Atlassian Stash/Bitbucket server that requires a port number. I'm hitting this error too with the following dependency. [[dependencies]] |
@liuliuhit - sorry for the delayed response. The right fix for your case should be to declare a @tobert so, I suspect you have a separate issue - "failed to deduce repository root." these problems are subtly different, and unfortunately, yours may be the harder one. Does the private Stash service allow you to specify the repository extension as part of the path? If so, e.g. |
I tried adding the extension and am getting the same results. `[tobert@gadget scorebot]$ tail -n 4 Gopkg.toml Solver wall times by segment: TOTAL: 4.520145946s ensure Solve(): "source.mycompany.com:7999/core/thing.git" is not a valid import path` |
Ah, OK, you didn't say this was the error you were getting 😄 First, to make sure we're clear - you're absolutely certain that |
Right, my code has been using a manually vendored copy of the problematic repo for about a year now. The import is "source.mycompany.com/core/thing" and I manually vendored it into "$GOPATH/src/source.mycompany.com/core/scorebot/vendor/source.mycompany.com/core/thing". Having the source line working Godeps.toml will make this a much nicer situation :) |
I'm working up a program to get some output. However, on looking back over,
This is not what I meant. I meant this:
And you'll have to change all your import paths that were pointing to |
Assuming the above change still doesn't fix the problem, please compile and run this program. Doesn't matter where you run it from. |
@sdboyer I'm sorry I forget paste my Gopkg.toml Ah, I declare And I resolve this problem in a hack way for temporary. Notice github.com/sdboyer/gps,
|
@liuliuhit i mean...hacking |
Closing this one out - in the small scale, this is a won't fix, as we're within the parameters laid down by the Go spec to treat |
Adding the .git extension doesn't work and I haven't had a chance to try your program. I will do so after morning meetings. @liuliuhit's fix is obviously correct. I get that the Go project doesn't support this use case but it doesn't mean dep can't solve a long-standing issue with 'go get'. |
What error do you get?
The end goal for dep is to make it into the toolchain. Decisions like these that depart from current toolchain behavior are of the sort that, while they address a pain point in the immediate term, may add little bits of complexity and edge cases to the eventual move, which is already going to be a tremendously complex process. In this case, the concern with allowing colons would be the subtle Windows incompatibility it creates, where colons in filenames are not allowed. It's even a little hinky on OSX. |
I get the same error regardless of how I modify the source field. I tried the variations you suggested as well as some others. From what I can tell, the 'dependencies.source' field in Gopkg.toml exists to allow redirecting an import (name) to a fully-specified URL so that imports and filesystem paths do not need to be modified. I took a look at your gps package and see that it is using the same RE for the import path and source checks and yeah, it wouldn't make sense to allow ports there. Could the regexp be split so that there is an import regexp that strictly conforms to the go specs and then something less strict for sources? I suppose if it's calling through to go get's fetching code it won't work. It appeared that the source field would scratch this itch, but I understand if it needs to be kept limited to the go specs. I already have to hack around those limitations and can continue to do so. Thanks! |
It's the import statements in your code that need to be updated - #411 (comment) . And the The validation regexp shouldn't be applied to the source field; if it is, that's a bug. |
I tried modifying the code as well. If I get some time this afternoon I'll try again and record the results this time. Line 110 of gps/deduce.go calls the same RE (githubDeducer.regexp) as githubDeducer.deduceRoot(). It's using it to extract the path from the provided source string. func (m githubDeducer) deduceSource(path string, u *url.URL) (maybeSource, error) {
v := m.regexp.FindStringSubmatch(path)
if v == nil {
return nil, fmt.Errorf("%s is not a valid path for a source on github.com", path)
} |
gps has been moved into dep - let's look/pull line numbers from (and please, stably link instead of line numbers) from there instead of from sdboyer/gps.
Please do - that's the information I really need to be able to sort this out.
The RE used by githubDeducer is not the same RE as the path validator. It's not a factor in this. Rather, the |
@sdboyer err from ListVersions: "source.mycompany.com:7999/core/thing" is not a valid import path |
Means if I put in the vcs extension, the validation regexp shouldn't be applied to the source field. While deduceKnownPaths calls normalizeURI() function, regardless of github repo or vcs provided repo, and path validation regexp is applied to every source field. |
Ugh, yes, OK. Sorry it took me so long to actually look at the code. As soon as I did, the problem was immediately evident :( I need to ponder a bit about what the right way is to solve this. |
I'm currently running into this, and hopefully I can help shed some light as to the direction to take to fixing it. My organization has (private) repos on github which are moving to a self-hosted repo accessible over ssh with an alternative port. Dealing with this situation using dep is how these issues came up, but I'm not just going to talk about that use case. I realize that some of these may be covered in other comments on this issue and other referenced issues, but I'm going to try to get my thoughts down. I was hoping that
would do it, allowing us to continue to use First, the
(I can work around this with putting a
This, as we know from this ticket so far, is due to the repo URL being intepreted as an import path, and this import path then having illegal (?) characters in it, specifically the colon. I'm able to hack up dep to add a new deducer for what is really my custom import path. This new deducer looks for One thing I've been throwing around in this is that I'd like to divorce the namespace of the pkg from where it is hosted/accessible. I'd like to be able to do:
(or any other valid repo path on the RHS of the colon) to fully separate the pkg namespacing from its physical location. I realize that doing this would require the code in orgname/repo to, if it contains self-references, use Side note: the |
whew, lots of thoughts here. OK. i realize i've let this sit for way, way too long...four months. yikes. i'm gonna put a little time in on it tonight, see what i can see. @thwarted - most of this is actually separate from the main focus of this issue; some may merit separate issues, although much of it has been covered elsewhere. (sorry, i don't have issue numbers on hand, but i promise that some searching around will be fruitful).
definitely a bug, although separate from the main one focused on in this issue. could use its own issue.
if only it were that simple. the real problem point is that you DO have to hack in a deducer, and that does make your tool (and the and, wrt this:
some more discussion on this in #860.
yes, because |
Which parts of "the rest of the ecosystem" should I be concerned with here? I'm already willing to forgo I'm still reviewing #860, #286, #767, and their referenced issues, many of which seem to all have the same problem coming at it from different directions, so bear with me while my thoughts are captured here. The deducer I wrote is literally the simplest deducer possible: a regular expression that matches the import path on I've been experimenting with an implementation of a "generic deducer" that does the above without having to build a custom deducer into the binary, perhaps populating a list of mappings from the Gopkg.toml file. Part of the issue I have, at least conceptually, is that it's not really a "deducer", because it doesn't need to do discovery of vcs or transport protocol, those things can be built into the source URL given in the mapping. If they don't, then I'd expect it to fail. If the source URL isn't the project root that can be cloned/downloaded from, I expect it to fail. And if something is referenced that can't be deduced, the suggested fix could be to explicitly map the un-deducable import path to a source URL. That is, the "smarts" of deducing can be ignored for this simple mapping case. I mentioned my expectations for |
sorry, i was jumping forward a bit (though it's to the place you've already gone). you needn't necessarily be concerned with them, if you're willing to run a modified version just for your folks - but i have to be, because people having different deducers means that there are invisible incompatibilities between projects.
yep, that's the thing i mention in #860 may be doable.
even if you're able to construct something that works in an entirely declarative context (like the better solution here is registries - along the lines of #286. |
Any update on this? Through Jenkins I have been able to specify an SSH key (i.e. git clone works fine), but dep is still unable to find the git repository. Gopkg.toml
|
@hoshsadiq ah, that's actually issue #860. This is specifically about not being able to include a port in the |
I'm not sure if a workaround exists for this yet, but even if I were able to modify the toml to point at the correct location, I am migrating from glide. As the single locally sourced package in my project fails due to our ssh+git being on a non-standard port, init fails, I get no toml and thus am unable to modify it to correct the problem. I presume a fix for the explicit port will inherently fix the init/migrate steps? |
@hamid-elaosta it should, yes, if that's the only problem you're running into while migrating. fixed in #1509. |
From @liuliuhit on April 19, 2017 3:22
I got this error message because of normalizeURI() function.
Notice
deduce.go
line 75pathvld = regexp.MustCompile(`^([A-Za-z0-9-]+)(.[A-Za-z0-9-]+)+(/[A-Za-z0-9-_.~]+)*$`)
pathvld seems not support the uri pattern with port.
thanks😀
Copied from original issue: sdboyer/gps#219
The text was updated successfully, but these errors were encountered: