ryanb / letter_opener

Preview mail in the browser instead of sending.
MIT License
3.73k stars 237 forks source link

Add support for Windows 10 WSL #156

Closed jamesst20 closed 5 years ago

jamesst20 commented 6 years ago

Hi,

It is currently possible from WSL to open a web browser in host (Windows 10). I was wondering if it could be supported by letter opener as well?

More info : https://superuser.com/questions/1262977/open-browser-in-host-system-from-windows-subsystem-for-linux/1266038

Currently in WSL, running "explorer.exe http://google.ca" from anywhere open the url in my default browser.

This : export BROWSER='/mnt/c/Windows/explorer.exe' only opens an Explorer window when an email is sent.

This : export BROWSER='/mnt/c/Program\ Files\ (x86)/Google/Chrome/Application/chrome.exe' opens a chrome window to file://mnt/c/Linux/SmartGit/securicheck/tmp/letter_opener/1540214727_835665_4904238/rich.html It works if I replace /mnt/c by C:/.

Thank you

jamesst20 commented 5 years ago

To add extra information.. WSLView from WSLU is not compatible either even though it's meant for that. I am getting :

Start : This command cannot be run due to the error: The system cannot find the file specified.
At line:1 char:1
+ Start file:////mnt/c/Linux/SmartGit/securicheck/tmp/letter_opener/154 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Start-Process], InvalidOperationException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
nashby commented 5 years ago

@jamesst20 hey! Unfortunately I don't have a machine with Windows 10 so can't really help you but pull request is welcome!

axvm commented 5 years ago

The issue is not in letter opener. Launchy doesn't support wsl https://github.com/copiousfreetime/launchy/issues/117

nashby commented 5 years ago

@jamesst20 hey! Have you solved this somehow?

jamesst20 commented 5 years ago

@nashy

Sorry I didn't investigate deeper

nashby commented 5 years ago

Closing this because it looks like Launchy's issue.

Taeir commented 3 years ago

I found a solution to this problem and explained it here: https://github.com/copiousfreetime/launchy/issues/117?_pjax=%23js-repo-pjax-container#issuecomment-805730312

trebeil commented 5 months ago

I needed to change two files to make it work.

On .bashrc: export BROWSER=/mnt/c/Program\ Files\ \(x86\)/Google/Chrome/Application/chrome.exe

On config/environments/development.rb:

LetterOpener.configure do |config|
  config.file_uri_scheme = 'file://wsl.localhost/Ubuntu'
end

What comes after file: on the file_uri_scheme may be different for you. You can find it out typing on the console: wslpath -m '/'