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
5 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.

3

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

Please sign in to leave a comment.