Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spacemacs in wsl2 can't open links in windows browser while the default Emacs (using emacs -Q) can #13382

Closed
Zxrcoming opened this issue Mar 16, 2020 · 7 comments

Comments

@Zxrcoming
Copy link

Zxrcoming commented Mar 16, 2020

image

As we can see above is a link in spacemacs, and I am in graphcal version of spacemacs, when I click or simple hit RET, link can't open
But in terminal-based spacemacs, it just work like a charm

here is the code I using for open links in wsl2 version of spacemacs
the code is put in the .spacemacs , in the dotspacemacs/user-init() session
image

and using `emacs -Q'

the open link works like a charm

I think it's a problem of spacemacs config, not the X410 because the default emacs (using emacs -Q) simply work out,

but I am not sure, the only thing I changed from the .spacemacs and .emacs.d is the above code

Also the x-server I use is the x410 downloaded from Micosoft Store

@Zxrcoming Zxrcoming changed the title spacemacs in wsl2 can't open links in windows browser while the puer Emacs can spacemacs in wsl2 can't open links in windows browser while the default Emacs (using emacs -Q) can Mar 16, 2020
@Zxrcoming
Copy link
Author

Zxrcoming commented Mar 16, 2020

update the .spacemacs.env file when you install packages, will be good to remain the function of jumping to browser.

@BenedictHW
Copy link
Contributor

I have the exact same problem as you and running
...
$ emacs26 -nw
...
has browse-url-generic working correctly. Can you please clarify what did you meant by updating the .spacemacs.env file? I've already tried spacemacs/force-init-spacemacs-env (SPC f e C-e) with no avail. I am on develop branch. Would be overjoyed if someone could shed some light on this.

@enriched
Copy link

@HanshenWang were you ever able to get an answer?

@BenedictHW
Copy link
Contributor

BenedictHW commented Feb 22, 2021

@enriched

@HanshenWang were you ever able to get an answer?

Unfortunately no. I was able to set the WSL_INTEROP to the proper internal IP address and launch explorer.exe and win10 firefox through emacs ansi-term (and v term). Provided I cd into /mnt/c/Program\ Files/Mozilla\ Firefox/firefox.exe

I was also able to install the wolfram engine for developers onto my wsl2 ubuntu and successfully point the emacs-jupyter package to the wolfram kernel by editing my spacemacs .env file. So I know my .env file works and that the WSL2 interop (apparently) works.

I'm not a programmer and I've pretty much exhausted all my google-fu. For now, I've resigned myself to install firefox inside my wsl2 ubuntu. It really is only useful for viewing html mail inside mu4e.

Let me know if you or somebody else manages to find a solution!

Cheers,

@BenedictHW
Copy link
Contributor

My issue (and maybe yours) is most similar to microsoft/WSL#6170 and microsoft/WSL#3806.

There doesn't seem to be an easy solution as of now.

@enriched
Copy link

enriched commented Aug 3, 2021

@HanshenWang don't know if you found the solution to this, but for me this was an issue with the WSL_INTEROP environment variable. It had been set in my .spacemacs.env and needed to come from the environment of the terminal.

I found the hint through this medium article. And I believe that solution is based on the comments on this WSL issue: microsoft/WSL#5065

So I also added this to my .zshrc file

fix_wsl2_interop() {
        for i in $(pstree -np -s $$ | grep -o -E '[0-9]+'); do
                if [[ -e "/run/WSL/${i}_interop" ]]; then
                        export WSL_INTEROP=/run/WSL/${i}_interop
                fi
        done
}

fix_wsl2_interop

@BenedictHW
Copy link
Contributor

BenedictHW commented Aug 3, 2021

@enriched Thanks for the tip! I now get what the O.P. meant by updating the
.spacemacs.env. It turned out I had your snippet above in my .bashrc, but
spacemacs//init-spacemacs-env mangles it slightly when creating the
.spacemacs.env. After removing spacemacs/load-spacemacs-env and installing the
MELPA package exec-path-from-shell as suggested in the .spacemacs.env header,
browse-url-generic now works as in the original post! Many thanks!

Mu4e users will want to redefine mu4e-action-view-in-browser as well.

(defun mu4e-action-view-in-browser (msg)
    (browse-url (concat "file://///wsl$/Ubuntu" (mu4e~write-body-to-html msg))))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants