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

Preview not opening in Windows WSL subsystem #5

Open
sambaPython24 opened this issue Jul 28, 2024 · 17 comments
Open

Preview not opening in Windows WSL subsystem #5

sambaPython24 opened this issue Jul 28, 2024 · 17 comments

Comments

@sambaPython24
Copy link

While texpresso is running well in WSL for Windows, the texpresso-vscode extension seems to be not working.
I am using the VSCode WSL extension in which also the standart Latex Workshop is working.

Unfortunately, I am not sure how to debug this a VSCode package to give you a more precise log.

@DominikPeters
Copy link
Owner

Thanks for the report. I don't have easy access to a Windows system unfortunately. Can you say more precisely what isn't working? My impression was that other users managed with WSL. You run the run texpresso command and nothing happens? Did you set the path to texpresso correctly in settings?

@sambaPython24
Copy link
Author

@DominikPeters Thank you for your work! For both paths/.../texpresso/build/texpresso and /.../texpresso/build,
the window is not opening. Do you know a way to print out a log-file (or any debugging message) for this texpresso package?

@wu7zh
Copy link

wu7zh commented Jul 31, 2024

I tried the same and did not manage to get it to work on WSL. Seems like texpresso in WSL cannot be opened from Windows VSCode.

My current workaround is installing VSCode inside WSL aswell, so @sambaPython24 might want to check out. Downside is obviously that you don't get to use your existing VSCode setup, but for me installing Latex Workshop and this plugin in a new setup was fine.

@DominikPeters
Copy link
Owner

Thanks @wu7zh for suggesting this.

It might be possible by doing something like what's suggested in this stackoverflow answer for how to spawn a WSL command from node, and appropriately adjust it in the extension code here:

texpresso = spawn(command, ['-json', filePath]);

But it's difficult for me to play with this. Can you tell me with what command it is possible to start texpresso, based on something starting with wsl?

DominikPeters added a commit that referenced this issue Aug 18, 2024
@DominikPeters
Copy link
Owner

It should now be working (extension version v1.5.1), with the new useWSL setting activated and with the command setting pointing to the path within WSL of the texpresso binary, such as /home/user/texpresso/build/texpresso.

@DominikPeters
Copy link
Owner

It would be useful to know if it works now for other people, I hope it does but am not completely sure how robust it is.

@zongpingding
Copy link

It should now be working (extension version v1.5.1), with the new useWSL setting activated and with the command setting pointing to the path within WSL of the texpresso binary, such as /home/user/texpresso/build/texpresso.

@DominikPeters In my condition, this extention still can't find texpresso, my setting is:

// texpresso settings
"texpresso.useWSL": true,
"texpresso.command": "/home/<name>/texpresso/build/texpresso",

and when click TeXPresso:Start Document, a error will occur:

TeXpresso command '/home/<name>/texpresso/build/texpresso' does not exist or is not executable. Please check the 'texpresso.command' setting.

but this path is right. When i install code-oss in WSL and set this path to variable texpresso.command, using the code-oss installed in WSL instead of vscode in windows, everything works right. There are 2 error messages in Developer Tools console:

console.ts:137 [Extension Host] /bin/sh: line 1: wsl: command not found
TeXpresso command '/home/<name>/texpresso/build/texpresso' does not exist or is not executable. Please check the 'texpresso.command' setting.

I have no idea how to deal with it. If additional information needed, i am willing to provide.

@DominikPeters DominikPeters reopened this Sep 22, 2024
@DominikPeters
Copy link
Owner

Thanks for reporting. Unfortunately, I usually do not have easy access to a Windows machine to try things out myself.

Could you run the following in the command line from outside WSL and tell me what happens?

wsl -e test -x /home/<name>/texpresso/build/texpresso

and

wsl -e /home/<name>/texpresso/build/texpresso

@zongpingding
Copy link

zongpingding commented Sep 23, 2024

Thanks for reporting. Unfortunately, I usually do not have easy access to a Windows machine to try things out myself.

Could you run the following in the command line from outside WSL and tell me what happens?

wsl -e test -x /home/<name>/texpresso/build/texpresso

and

wsl -e /home/<name>/texpresso/build/texpresso

@DominikPeters My WSL config:

$ uname -r
6.6.36.3-microsoft-standard-WSL2

$ lsb_release -a
LSB Version:    n/a
Distributor ID: Arch
Description:    Arch Linux
Release:        rolling
Codename:       n/a

I will use <name> to denote the user's name for my Linux in WSL. PC is my user's name for windows.

  1. Output of the first case:
wsl -e test -x /home/<name>/texpresso/build/texpresso

Nothing happens and there is no output and log message.

  1. The second case:
wsl -e /home/<name>/texpresso/build/texpresso

[info] working directory: /mnt/c/Users/PC/Desktop
[info] executable path: /home/<name>/texpresso/build/texpresso
Usage: texpresso [-I path]* [-json] root_file.tex

Additionally, when i run texpresso in WSL, the output log is:

$ /home/<name>/texpresso/build/texpresso
[info] working directory: /home/<name>
[info] executable path: /home/<name>/texpresso/build/texpresso
Usage: texpresso [-I path]* [-json] root_file.tex

@wu7zh
Copy link

wu7zh commented Sep 23, 2024

A few colleagues of me are now using it on their Windows machines, and for them everything works fine. I set it up for them on a fresh WSL install using default settings, and the WSL option works using the path "/home//texpresso/build/texpresso".

@zongpingding My guess is it has something to do with your WSL config. Can you try on a standard WSL install using the default Ubuntu system?

@zongpingding
Copy link

zongpingding commented Sep 23, 2024

@wu7zh I have installed Ubuntu distribution using command wsl --install, system info:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.1 LTS
Release:        22.04
Codename:       jammy
$ /home/<name>/texpresso/build/texpresso
[info] working directory: /home/<name>/texpresso
[info] executable path: /home/<name>/texpresso/build/texpresso
Usage: texpresso [-I path]* [-json] root_file.tex

and build texpresso successfully, see below:

Screenshot (137)

Configuration of this extension is:

"texpresso.useWSL": true,
"texpresso.command": "/home/<name>/texpresso/build/texpresso",

but the problem persist. If this is due to my wsl config, the only problem will be in WSL config file C:\Users\<UserName>\.wslconfig. This config is:

[experimental]
autoMemoryReclaim=gradual
networkingMode=mirrored
dnsTunneling=true
firewall=true
autoProxy=true

There is no default /etc/wsl.conf provided by ubuntu. My vscode info:

> code --version
1.93.1
38c31bc77e0dd6ae88a4e9cc93428cc27a56ba40
x64

TeXPresso info:

TeXpresso v1.5.1

It is weird.

@sambaPython24
Copy link
Author

Even though I set all paths ( User / Remote [WSL:Ubuntu] / Workspace ) to /home/texpresso/build, I get the error that

TeXpresso command '/home/texpresso/build/texpresso' does not exist or is not executable. Please check the 'texpresso.command' setting.

The WSL version is: (wsl --version)

WSL-Version: 2.2.4.0
Kernelversion: 5.15.153.1-2
WSLg-Version: 1.0.61
MSRDC-Version: 1.2.5326
Direct3D-Version: 1.611.1-81528511
DXCore-Version: 10.0.26091.1-240325-1447.ge-release
Windows-Version: 10.0.22631.4169

Would the people for which it is working also share their WSL configuration?

@DominikPeters
Copy link
Owner

What the extension does is call the wsl -e test -x to see if texpresso appears to work:

try {
if (!useWSL) {
fs.accessSync(command, fs.constants.X_OK);
} else {
execSync(`wsl -e test -x ${command}`);
}
} catch (error) {

otherwise, it displays the error message you are seeing. In principle, it could be that the test command fails when the actual command would in fact work. If you feel comfortable, you could try building the extension locally so you can change the code (e.g. comment out the test whether the command exists) and see if you can get it to run. (Clone the repo, run npm install then npm run watch in the folder, open the folder in a new VS Code window, open extension.ts, then Run and Debug).

@wu7zh
Copy link

wu7zh commented Sep 24, 2024

@sambaPython24 '/home/texpresso/build/texpresso' is likely the wrong path.
Are you sure it is not /home/USERNAME/texpresso/build/texpresso ?

@sambaPython24
Copy link
Author

@wu7zh I was trying to recreate your path and running the test /home/texpresso/build/texpresso /home/texpresso/test/simple.tex works, renders and opens a window (although there is no life preview of when I change simple.tex).

@DominikPeters Thank you for that detailed description. When I see the command, I see that you call wsl which appears to mean that you run it from Windows. Do you open open VS-Code in Windows and use your extension by running (Texpresso: Start Document) or do you open VS-Code, connect to WSL within VSCode and then run the command?

Given the first option, do you need the execution path relative to WSL (after it has been compiled in WSL) or relative to Windows?

@DominikPeters
Copy link
Owner

Yes, the useWSL option is intended for use with VSCode in Windows and TeXpresso in WSL. If both are in WSL, then useWSL should be turned off.

@sambaPython24
Copy link
Author

sambaPython24 commented Sep 25, 2024

@DominikPeters Thank you, that was probably the problem and it is working very well now. Thank you for your work.

For anybody, that also has problems:

You can also connect to the WSL Server in VSCode (as a command WSL : Connect to WSL or the green field in the very left bottom corner) and run it just like in Linux. You have to set the settings to
texpresso.useWSL : false This worked for me in the end.
Also you might try to compile texpresso-tonic. I am not sure, how it is related to the solution.

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

4 participants