BetterErrors/better_errors

Unable to open file from browser link when using WSL2

petebytes opened this issue · 2 comments

Using BetterErrors.editor = "vscode://file/%{file}:%{line}"
does not generate the correct link for vscode to open the file when the file resides in WSL2

It's not possible for Better Errors to know the "real" path that it's running in when running inside of a virtualized environment like Docker or WSL.

For a case like this you can instead create a proc where you can modify the file path. For example:

BetterErrors.editor = proc { |file, line|
  file = "/some/other/path#{file}"
  "vscode://file/%{file}:%{line}" % { file: URI.encode_www_form_component(file), line: line }
}

I highly recommend against committing this file into your project repository though, since it might be very specific to your personal development environment.