Intellij won't sync dependencies in Go project

Answered

This project runs from the command line, but Intellij can't find any of its dependencies.  They are in my GOPATH.  I've run `go mod tidy` and have deleted the .idea/ and *.iml files, but Intellij still won't sync the dependencies.

I've noticed in other projects if there is a problem Intellij will (eventually) prompt you to sync dependencies.  Is there a way to force Intellij to sync dependencies?

 

3
7 comments

Please make sure Go modules integration is enabled via Preferences | Go | Go Modules. After that, Sync Dependencies action should be available in go.mod file.

4

That was the problem.

I believe there was a ticket to fix this.  When there is a go.mod file in a project module integration is enabled by default.

1

You're right, Go modules integration should be enabled by default. However, there are several issues with that. Did you rollback between GoLand versions? 

1

I ran into this problem even with modules enabled.  For me the fix involved running the same go list command idea tried to see dependencies that needed a replace directive in the mod file.  Hope this helps if anyone runs into my version of the problem.

1

I also ran into similar issue, solution was close IJ then `rm -rf .idea/` and then re-open project.

1

Windows and wsl2 issue:

I also ran into this (even with modules enabled). Turns out, I was loading a project with `.idea` files that were transferred from macos and linux, and trying to open it in wsl2. I found that, instead of opening the directory like usual (`idea .`), I needed to create a new project from existing sources. Then Idea can properly set the wsl2 directory vars and env and so forth to make it work.  Hope that helps someone else.

0

I'm running into this problem because an `//indirect` references a tag that no longer exists, is there a way around this that doesn't require upgrading the chain of dependencies?

0

Please sign in to leave a comment.