-
Notifications
You must be signed in to change notification settings - Fork 1k
dep init fails if in not in $GOPATH[...]/src/{somedir..} #148
Comments
I could got same issue.
This issue is happened every time in $GOPATH/src. |
Yes, I've got the same issue, for private projects we work with determineProjectRoot: Though I was told this isn't the intended way of using the tool though, so it might be out of scope. |
I think this approach to things should work fine, though because it's not a design case we've had in mind, there's likely to be at least a few hinky issues related to the base project root being empty. (Yeah...I can think of a few now.) The only important note to make is that the resulting repository will be useless for anyone trying to import it...but I imagine that's not a concern for anyone taking this approach. To be clear - this approach means that dep will ensure there is exactly one version of all dependencies in your system, and all of them will be managed as a group. In general, if you leave all your third-party deps under At minimum, we need a better error here. Ideally, we'd support this as a first-class use case. |
Yeah, this looks related to #201. I'll add an integration test for the cases described above then clean up the code. |
Actually, this is not the same issue as #201 after all. This is more of a defintion question. The dependency import path is calculated as everything past |
Just to clarify, I don't put my sourcecode directly in My tree for most of my projects look somewhat like this: (Or vendor directly in Hope this clear some things up :)
|
@tro3 yeah, this issue describes an alternate use pattern to what's typical; @machiel's description is a good description of one variant of it. It can work within the general model of dep, sliding through on a technicality (actually, more like a door-left-carefully-ajar). However, fixing the handling to make the "GOPATH/src as root" case work is more involved, more or less because of what you note - there is no import path to figure out. Even once we solve it in dep, gps is going to need a bit of special handling for empty root import paths to support this case. ...and, actually, some other things, too. Ugh. I need to open an issue on gps for it. |
Oh, I see. Actually, I kind of like that use case, though presumably $GOPATH is then set per-project. (Still a newbie, here.) So if it works as-is for $GOPATH (thru the door left ajar :-)) and as intended for $GOPATH/src/x, maybe just a better error message for |
Looking forward to the progress on this. We have a proprietary project that has many small utilities built into a busybox-like executable and has some vendored packages from the stdlib and third-parties for those utilities. Currently the best solution is GB but it seems abandoned. We also have to integrate the project into some BSPs, including AOSP and other buildroot-based ones, which makes the process a little messy. Hopefully a canonical tool like dep will ease our job soon. |
@sdboyer so your design is to force everyone to put their project under src folder? I don't understand why I should group my repositories by language, instead I should be able to group by projects. For example I have a project, which contains one service written in Ruby and another in Golang. In general I would like to decide myself how to name and organize my folders. |
why does dep depend on GOPATH? isn't the whole point to ignore GOPATH and use |
@andrewrk sadly, dep can't liberate us from given that we know we have to accept GOPATH's existence for now, we do rely on it for figuring out the root import path of the current project. this is important because we use it to determine which import paths are "internal" vs "external" when inspecting the code from the current project. A fair bit more on those mechanics here: #313 (comment) when we're ready to move away from GOPATH (it might look something like this), we'll probably add a field to |
Ah. Thanks for this explanation. I was getting ridiculed in #go-nuts for the same question but your answer is clear and helpful. |
Another bad situation is when I run |
Thanks for the explanation @sdboyer , I am trying to run a |
An interesting observation. When I try to run |
I'm really confused by all this. So just to be explicit: if you're developing a project and you want to use So my current fix is to symlink my project into |
We hate to put our project in GOPATH, as the project itself might contain submodule for other project, or contain code written by other language. |
@frostyplanet we know the reasons why it's important to do, and agree with them. it doesn't change the reality that it's not a choice we can make in dep right now. |
@sdboyer
Set GOPATH with "go get" works fine with public code. For private code we have written some script to download them into "thirdparty" and deal with the branch/tag/commit thing, but still our script is not good at resolving dependency. |
Looks like Russ Cox has decided to fix this issue: https://research.swtch.com/vgo-intro
Great! It took a long time, but looks like we'll get a happy ending after all. |
Yay! God that's such exciting news. You can find a mirror for |
yep, addressing this was never really a question. just needed to get to the point where the changes could happen in the toolchain.
…On February 21, 2018 1:29:02 PM EST, Andrew Kelley ***@***.***> wrote:
@sdboyer
> sadly, dep can't liberate us from GOPATH on its own, as the compiler
still requires it. and, being that dep's goal is to have as easy a
transition into the toolchain as possible, we're focusing minimally on
those areas that complement/extend the existing go toolchain, rather
than supplanting existing systems.
Looks like Russ Cox has decided to fix this issue:
https://research.swtch.com/vgo-intro
> The most significant change, though, is the end of GOPATH as a
required place to work on Go code. Because the go.mod file includes the
full module path and also defines the version of every dependency in
use, a directory with a go.mod file marks the root of a directory tree
that serves as a self-contained work space, separate from any other
such directories. Now you just git clone, cd, and start writing.
Anywhere. No GOPATH required.
Great! It took a long time, but looks like we'll get a happy ending
after all.
--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#148 (comment)
|
So what is the fix? |
In my case how i can solve this is, First i run the export for my GOPATH. Lets assume my GoPath would be. /Users/your-username/Documents/mataharimall-development/www/go/. After that make sure you have directory src under your gopath and your project directory under src folder |
you should use this command "dep init" in $GOPATH/src/your projectname |
It's annoying that we can't do it without using $GOPATH yet, but it's on the way! |
I have a project that I can build from any path in my workstation and I can fetch all the dependencies with:
why does |
Not sure if this is the same issue or not - but it is the same error. If the GOPATH is based on symlinks the
My quick fix for this is running the
|
If GOPATH is foo/bar/ then running dep init from /foo/bar/src
yields:
determineProjectRoot: /foo/bar/src not in any $GOPATH
yet it most certainly is in the GOPATH.
I'll leave the commentary off about why I want this, but if this is going to be disallowed for now, a better error is needed.
The text was updated successfully, but these errors were encountered: