BetterErrors / better_errors

Better error page for Rack apps
MIT License
6.88k stars 435 forks source link

Unable to open file from browser link when using WSL2 #485

Closed petebytes closed 3 years ago

petebytes commented 3 years ago

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

RobinDaugherty commented 3 years ago

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.

RobinDaugherty commented 3 years ago

Actually, I just found this in the wiki: https://github.com/BetterErrors/better_errors/wiki/Running-on-virtual-machines