-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
cmd/go: go mod tidy
ignores go.work
file
#50750
Comments
Tidiness is a property of an individual module, not a workspace: if a module is tidy, then a downstream consumer of the module knows which versions to use for every dependency of every package in that module. If you don't particularly care about downstream consumers having a package that is provided by the workspace, you can use Otherwise, you either need to publish the workspace dependencies before running |
@matloob, for Go 1.19 I wonder if we should augment the |
go mod tidy
ignores go.work
` filego mod tidy
ignores go.work
` file
go mod tidy
ignores go.work
` filego mod tidy
ignores go.work
file
Currently with reproducing repository (https://github.com/bozaro/go-work-play/tree/go-mod-tidy). I can run:
And But for This behaviour looks like inconsistent: I expects that |
What valid use cases are there for |
This is also happening for I agree with @liadmord, the only benefit I see get from the |
I agree with @bozaro @liadmord and @AlmogBaku I have a monorepo private project where I have multiple modules, and on each one I need to insert a lot of |
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
Encountering the same issue with Furthermore, some other
Expected behaviour: The |
My expected functionality is that a If I don't commit my Once I must make an edit to In other words, if I add this line to
Then |
This is a very big issue for me in the case of creating Docker containers :( I cant use Golang is considered the language for microservices and In the current state of the
I expect 4 things from the
So now, the only thing why I'm using |
Signed-off-by: Valery Piashchynski <piashchynski.valery@gmail.com>
I've faced this issue yesterday but my case is a bit different.. My The solution is simply to move the |
Folks who are commenting here (and please bear in mind https://go.dev/wiki/NoPlusOne!) — have you considered |
@bcmills I'm not sure what the intended workflow is, but I think the feedback here is that the DX is really not intuitive. |
I wish there were |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
However that replace directive seems to be ignored by
|
Yep, that is how I had to work around it. I don't think it has anything to do with limits on the size of a repo though. |
What i mean is that I am using (or rather want to us) multiple modules to get around the size of my monorepo vs just having a single There are two problems with large monorepos and a single For all download type it looks like it defaults to 10<<20 (or around 524MB) which is a lot for a repo, but we use git-lfs which is resolved here and includes any binaries you may want to stuff into your monorepo: https://github.com/golang/go/blob/master/src/cmd/go/internal/modfetch/codehost/codehost.go#L35 Submodules is a great way to solve this, but because of resolving versions and the chicken-and-egg problem they are hard to work with and hard for my coworkers to stomach. |
An important underlying theme here is that monorepos are not monolithic codebases, nor are they distributed eventually consistent codebases where you necessarily version and publish each part to some registry. They are no less modular than multi-repo/polyrepo -- to the contrary, they promote mindful modularity by reducing the incidental disincentives to modular design. That they don't encourage/require long-lived support branches in the form of versioning in many circumstances is frankly unrelated to modularity. If we can agree that this is at least a defensible position, let's try to shift the focus to how we can decouple go module tooling behavior from opinions for/against monorepo adoption without breaking userland. |
"go mod" commands are scoped to modules when making changes; there is no workspace in go mod sub-commands. This is why "go work vendor" is different from "go mod vendor". So "go mod tidy" should not know about go.work any more than the other commands. (Some of the read-only commands like "go mod graph" are workspace-aware, but that's less problematic than read-write commands.) It seems like "go work sync" is what we should be focusing on. What does it do or not do that is inappropriate? |
@rsc Hi Ross, thanks for looking into this.
ScenarioImagine this scenario, you're planning on creating a repo with the following:
ProblemSo now you learn about "go workspaces" that seem like they could help with this and you want to quickly try it out. You make the above file tree, then do:
To workaround you can do:
But that's obviously silly because you might as well not use workspaces at that point. Possible Solution 1:
|
Respectfully, this is not a solution, it's a temporary mitigation at best. Not supporting atomic updates spanning multiple workspace modules defies the purpose of a workspace in the general sense of the term, as it is observed across languages and monorepo build tools. Whether we get Updating go.mod files appears to be within the purview of |
I don't know whether it is related but one issue that I have encountered is, while building something similar to gonew, when downloading a module in a workspace, the go.work file needed to be updated manually. Perhaps that go work sync could also work bottom up (via a flag?) to add this module/directory to the module list in the go.work file? If that makes sense. |
Many use cases were described by participants here. Mine is that I do not want to publish dummy stub modules before I can start to work. I can buy rsc explanation why
that does not try to reach to unpublished modules. Ie. |
@dpifke Thanks, that's a useful perspective. We don't want our tools confusing users with the instructions they give. I'm interested if solving the error messages is the primary reason most people want 'tidy' for these use cases. @brianbraunstein I don't think 'tidyness' is the right concept here. I don't think we should call a @ohir I don't know if @dkrieger I don't think we should frame this discussion around what the concept of a "Workspace" is in other language ecosystems. We want to build what make the most sense for the Go module system. |
It still reaches to the net even if it has everything replaced or internal. It should not. Repro tree attached (usage: |
When I disable the network your repro case doesn't produce an error when the two replaces in the go.work are there. But if I remove them I do get an error. Is that what you're seeing too? If not, what version of Go are you running? |
There is no problem with Since This is a wider problem: The only working solution for now is to replenish all
Of course Summary: |
I don't understand why this discussion has continued for this long, honestly, and yet there's no progress to be seen. Your summary seems to sum it up perfectly and I think it's the reason I subscribed to this issue a long time ago: My expectation was to use |
@matloob After adding Filtered excerpts follows: [cmd/smth imports [other module - imported by cmd/smth but NOT importing
To sort this mess out an explicit replace had to be added to the (cmd's) go.mod I hear "its a gopls issue". No, it is not just I would like my "Summary" warning to be included in the docs of the workspaces for the time being - to save headaches for others trying to add some isolated module to their workspace. Thanks. |
Hey everyone, If you declare the local shared module only with the folder name, you can import it directly in the other module Go files without needing a remote go.mod. By example:
|
Now try running |
@dkrieger all looks good here! No errors or warnings. |
it only makes go mod thinks the module is in the std. compiling will fail. |
This is currently an ongoing issue with go.work configurations in golang/go#50750
This is currently an ongoing issue with go.work configurations in golang/go#50750
This comment was marked as spam.
This comment was marked as spam.
Since this thread seems to summarize many different opinions and ideas as to what to change for the 1 dependency management for "initial setup"I personally hate it that if I work on several new submodules i would need to release an initial version first for all of them to be able to reference them correctly on a main go.mod file. Otherwise the IDE always complains... why not allow to reference inside go.mod something like a keyword to emphasize that this is handled by go.work file and is not maintained currently (yet) against a stable version. something linke: require https://github.com/google/uuid vWorkspace linters can also work with such a keyword showing the warning for this... builds could fail initially when keyword is found. Same for PR checks. Currently my workaround is: With this keyword also go mod tidy would just work. Because the expectation of "this is not a final version" is fulfilled and IDE compiler etc still works without extra effort of manual branch versioning. 2 extra work for submodule tidynessThe second point I read here somewhere in the chat already and it is the need to "cd" into all directories to "go mod tidy" all submodules. Workaround is to edit the make file: tidy: ## Tidy go modules
go work sync #sync root
cd apis/A/v1alpha1 && go mod tidy # tidy all submodules
cd apis/B/v1alpha1 && go mod tidy
...
go mod tidy # tidy main module So here I would love an option to do something like: go mod tidy --recursive #(and if there is no main module it should still look into subfolders...) I think the "featureset" that is available is usable but with manual effort which is confusing as most of the things where also possible with manual effort without the conclusion:IMHO this two small changes would come a long way in terms of "Developer happiness" |
To add my feedback, we've been using go in our monorepo and I think the confusion fundamentally boils down the decision that workspaces are an override for local development, but according to guidelines shouldn't be production, and therefore We have a setup like:
We used to have a We also tried deleting the workspace and running From my perspective, I feel like the tooling is unintuitive and is probably the most 'magical' part of the language, considering how methodical and obvious the rest of the language is. |
What version of Go are you using (
go version
)?What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Minimal reproducing repository: https://github.com/bozaro/go-work-play/tree/go-mod-tidy
Full script:
What did you expect to see?
I expect
go.mod
andgo.sum
updated with current working copy state.What did you see instead?
I see that
go mod tidy
try to get modules forshared
go modules from repository ignoringgo.work
content.The text was updated successfully, but these errors were encountered: