Go language server workspace

87 views
Skip to first unread message

Maxime Pigeon

unread,
Dec 14, 2023, 12:24:51 PM12/14/23
to BBEdit Talk
Hi,

I’m having issues with Go’s language server in BBEdit. When I open a simple Go project, that is, a repository with a single module (for instance : https://github.com/eliben/static-server), I get an error saying “This file is within module “Downloads/static-server” which is not included in your workspace…”, and another error about not being able to find a package in GOROOT or GOPATH.

I get this error in the logs: 

2023-12-14 12:11:40.325: Server message: 2023/12/14 12:11:40 errors loading workspace: You are outside of a module and outside of $GOPATH/src.
If you are using modules, please open your editor to a directory in your module.
If you believe this warning is incorrect, please file an issue: https://github.com/golang/go/issues/new.
snapshot=3
directory=file:///Users/maximepigeon/

It’s as if BBEdit is not properly communicating my project directory, which should be  “/Users/maximepigeon/Download/static-server” to gopls.

I’m fairly certain this is not an error with the repository since it works in other editors (VSCode, Sublime, Helix). It also doesn’t work if I move the repository somewhere else.

Best,
Maxime

Maxime Pigeon

unread,
Dec 21, 2023, 11:53:23 AM12/21/23
to BBEdit Talk
Update for future reference.

The issue seems to be caused by opening multiple projects that uses the same language server — in this case, Gopls. The language server’s workspace is defined only once by BBEdit when a project is opened. Each subsequent project inherits the same workspace, which might confuse certain servers.

For instance, if I open BBEdit, then open the Go project "/Developer/foo", the server’s workspace is correctly set to "/Developer/foo", and everything works fine. If I then open another Go project, say "/Developer/bar", without quitting BBEdit, the server still assumes the workspace is "/Developer/foo”.

The issue can be “solved” by closing all projects and reopening BBEdit.

Bare Bones is aware of this limitation, which might be addressed in future version.

Reply all
Reply to author
Forward
0 new messages