Repository: go
Issue: x/tools/gopls: Error loading packages: invalid workspace folder path: no such file or directory
Labels: gopls,Tools

I am using gopls in Emacs to connect to a remote workspace over SSH (using [tramp](https://www.gnu.org/software/emacs/manual/html_node/tramp)).

Local machine is running Mac OSX and remote is Linux.

### Remote gopls version
On remote:
```
$ gopls -v version                                                                                                                                    1 ↵
Build info
----------
golang.org/x/tools/gopls v0.13.2
    golang.org/x/tools/gopls@v0.13.2 h1:Pyvx6MKvatbX3zzZmdGiFRfQZl0ohPlt2sFxO/5j6Ro=
    github.com/BurntSushi/toml@v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
    github.com/google/go-cmp@v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
    github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
    golang.org/x/exp@v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA=
    golang.org/x/exp/typeparams@v0.0.0-20221212164502-fae10dda9338 h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y=
    golang.org/x/mod@v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
    golang.org/x/sync@v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
    golang.org/x/sys@v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
    golang.org/x/text@v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4=
    golang.org/x/tools@v0.11.2-0.20230810185051-cc6b5804b8cf h1:Oush7UwPamr2/iNeNFBuNFj89YyHn0YY69EKDdvANnk=
    golang.org/x/vuln@v0.0.0-20230110180137-6ad3e3d07815 h1:A9kONVi4+AnuOr1dopsibH6hLi1Huy54cbeJxnq4vmU=
    honnef.co/go/tools@v0.4.2 h1:6qXr+R5w+ktL5UkwEbPp+fEvfyoMPche6GkOpGHZcLc=
    mvdan.cc/gofumpt@v0.4.0 h1:JVf4NN1mIpHogBj7ABpgOyZc65/UUOkKQFkoURsz4MM=
    mvdan.cc/xurls/v2@v2.4.0 h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc=
go: go1.20.8
```

### Remote go env
```
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="<redacted>"
GOENV="<redacted>"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="<redacted>"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="<redacted>"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="<redacted>"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="<redacted>"
GOVCS=""
GOVERSION="go1.20.8"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2897107243=/tmp/go-build -gno-record-gcc-switches"
```

### Local gopls version
```
$ gopls -v version
Build info
----------
golang.org/x/tools/gopls v0.13.2
    golang.org/x/tools/gopls@v0.13.2 h1:Pyvx6MKvatbX3zzZmdGiFRfQZl0ohPlt2sFxO/5j6Ro=
    github.com/BurntSushi/toml@v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
    github.com/google/go-cmp@v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
    github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
    golang.org/x/exp@v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA=
    golang.org/x/exp/typeparams@v0.0.0-20221212164502-fae10dda9338 h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y=
    golang.org/x/mod@v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
    golang.org/x/sync@v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
    golang.org/x/sys@v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
    golang.org/x/text@v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4=
    golang.org/x/tools@v0.11.2-0.20230810185051-cc6b5804b8cf h1:Oush7UwPamr2/iNeNFBuNFj89YyHn0YY69EKDdvANnk=
    golang.org/x/vuln@v0.0.0-20230110180137-6ad3e3d07815 h1:A9kONVi4+AnuOr1dopsibH6hLi1Huy54cbeJxnq4vmU=
    honnef.co/go/tools@v0.4.2 h1:6qXr+R5w+ktL5UkwEbPp+fEvfyoMPche6GkOpGHZcLc=
    mvdan.cc/gofumpt@v0.4.0 h1:JVf4NN1mIpHogBj7ABpgOyZc65/UUOkKQFkoURsz4MM=
    mvdan.cc/xurls/v2@v2.4.0 h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc=
go: go1.20.4
```

### Local go env
```
$ go env
GO111MODULE="on"
GOARCH="arm64"
GOBIN=""
GOCACHE="<redacted>"
GOENV="<redacted>"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="<redacted>"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="<redacted>"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.20.4"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/4g/g02xvq957bn8bjr6wdvs1sgm0000gr/T/go-build880898998=/tmp/go-build -gno-record-gcc-switches -fno-common"
```


### What did you do?
When lsp-mode (LSP client that I am using for Emacs) tries to open a file, I am seeing the following message returned from the server:
```
[Trace - 05:56:20 PM] Received notification '$/progress'.
Params: {
  "token": "5105710039192624326",
  "value": {
    "kind": "end",
    "message": "Error loading packages: invalid workspace folder path: no such file or directory; check that the casing of the configured workspace folder path agrees with the casing reported by the operating system"
  }
}

[Trace - 05:56:20 PM] Received notification 'window/showMessage'.
Params: {
  "type": 1,
  "message": "Error loading workspace folders (expected 1, got 0)\nfailed to load view for file:///<file-path>: invalid workspace folder path: no such file or directory; check that the casing of the configured workspace folder path agrees with the casing reported by the operating system\n"
}
```


And then finally, lsp-mode bails with:
```
[Trace - 05:56:20 PM] Received response 'nil - (186)' in 0ms.
Result: {
  "code": -32800,
  "message": "JSON RPC cancelled"
}


[Trace - 05:56:20 PM] Received response 'textDocument/codeLens - (187)' in 99ms.
Result: {
  "code": 0,
  "message": "no views in session"
}
```

### What did you expect to see?
gopls server should have correctly recognized the folder.


### What did you see instead?
The error attached above.


### Editor and settings
Editor:
```
  "clientInfo": {
    "name": "emacs",
    "version": "GNU Emacs 29.1 (build 2, aarch64-apple-darwin22.6.0, NS appkit-2299.70 Version 13.5 (Build 22G74))\n of 2023-08-18"
  },
```

lsp mode editor settings:
```
(use-package lsp-mode
  :commands (lsp lsp-deferred)
  :init
  (setq lsp-keymap-prefix "C-c l")
  :config
  (setq lsp-prefer-flymake nil)
  (lsp-enable-which-key-integration t)
  ;; lsp remote clients
  (lsp-register-client
   (make-lsp-client :new-connection (lsp-stdio-connection "gopls")
                    :major-modes '(go-mode go-dot-mod-mode go-ts-mode go-mod-ts-mode)
                    :language-id "go"
                    :remote? t
                    :priority 0
                    :server-id 'gopls-remote
                    ))
  :hook
  ((c-mode c++-mode java-mode python-mode go-mode go-ts-mode go-dot-mod-mode go-mod-ts-mode python-ts-mode) . lsp))
;; lsp-ui for minimal UI features
(use-package lsp-ui
  :hook (lsp-mode . lsp-ui-mode)
  :config
  (setq lsp-ui-doc-enable nil))
```