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

Honor terminal.integrated.shellArgs #2282

Closed
bersbersbers opened this issue Sep 14, 2020 · 12 comments
Closed

Honor terminal.integrated.shellArgs #2282

bersbersbers opened this issue Sep 14, 2020 · 12 comments
Labels
external issue Issue with something else than LaTeX-Wokshop

Comments

@bersbersbers
Copy link

bersbersbers commented Sep 14, 2020

Is your feature request related to a problem? Please describe.
I'm always frustrated when I use LaTeX-Workshop with Remote SSH into my Linux system. I (have to) use bash as a shell on that system (zsh is not installed). I have set up $PATH in .bashrc, .bash_profile, .profile, and whatnot. In the terminal, latexmk works. latexindent works. But in order to make these commands work for LaTeX-Workshop, a lot of environment-variable gymnastics is required for each individual command. (I have not been able to achieve that for latexindent, yet: I have been able to set latex-workshop.latexindent.path, but that does not set the Perl library path, obviously.) There does not see to be an equivalent of .zshenv in bash (which is always called, regardless of whether the shell is login/interactive, compare https://github.com/James-Yu/LaTeX-Workshop/wiki/FAQ#environment-variables-in-zshrc-dont-take-effect-with-vs-code-remote).

Describe the solution you'd like
I can set

    "terminal.integrated.shellArgs.linux": [
        "-i", // force interactive, to source .bashrc
        // "-l", // force login, sources .bash_profile
    ],

and this is honored by this task, for example:

    "tasks": [
        {
            "label": "Test $PATH",
            "type": "shell",
            "command": "echo $PATH",
        }
    ]

When run without terminal.integrated.shellArgs.linux, this task prints the default, non-working $PATH. When run with terminal.integrated.shellArgs.linux set to -i/-l, the correct, working $PATH set by .bashrc/.bash_profile is printed.

Additional context
From https://github.com/James-Yu/LaTeX-Workshop/wiki/Install#setting-path-environment-variable:

If VS Code cannot find executables of TeX, it means that the setting of your system is broken.

I feel this is incorrect. (It may apply to local installations, where the $PATH is inherited by from local VS Code. This is not the case with Remote SSH. My system and the server are set up correctly. The terminal and tasks find latexmk - it's just that LaTeX-Workshop ignores terminal.integrated.shellArgs.* (probably because it does not even use a shell if I am not mistaken).

My proposal: use a shell, add shellArgs with cs.spawn, for example, here:

const worker = cs.spawn(this.formatter, args, { stdio: 'pipe', cwd: documentDirectory })

Maybe like this, where "/bin/bash -i" is from terminal.integrated.shell(Args):

cs.spawn(this.formatter, args, { stdio: 'pipe', cwd: documentDirectory, shell: "/bin/bash -i" })
@bersbersbers bersbersbers added the feature request Feature request label Sep 14, 2020
@jlelong
Copy link
Collaborator

jlelong commented Sep 14, 2020

I believe that if you set the correct paths in .bash_profile and read .bash_profile inside your .bashrc, your paths should be fine with both login and interactive shells. I am afraid forcing the use of a shell in cs.spawn is not a portable approach.

@bersbersbers
Copy link
Author

bersbersbers commented Sep 14, 2020

I believe that if you set the correct paths in .bash_profile and read .bash_profile inside your .bashrc, your paths should be fine with both login and interactive shells.

This is correct, I have checked both variants. However, the $PATH seen by this extension is still incorrect since it does not use a shell, or if it does, it's a non-interactive, non-login shell.

I am afraid forcing the use of a shell in cs.spawn is not a portable approach.

I wonder why that is. Isn't that the purpose of the cross-spawn package?

@tamuratak tamuratak added the need more info More information needed to identify the issue label Sep 14, 2020
@tamuratak

This comment has been minimized.

@tamuratak tamuratak removed the feature request Feature request label Sep 14, 2020
@bersbersbers
Copy link
Author

Thanks - this looks like some work, will do over the weekend!

@tamuratak tamuratak added the can't reproduce Issue cannot be reproduced label Sep 15, 2020
@tamuratak
Copy link
Contributor

Please notify if any progress.

@bersbersbers
Copy link
Author

Preliminary questions [Required]

Disable all the other extensions except for LaTeX Workshop, and check that you still see this issue. [Required]

You still see this issue?: N/A (I do need Remote SSH)

Make sure to visit the wiki FAQ before filling an issue.

You visited the wiki?: Yes

If your issue is with compiling a document (not having to do with finding the root file of a project), check first that you can compile manually.

You can compile a TeX document manually?: Yes

Describe the bug [Required]

See above - there is no LatTeX-global PATH setting that I can use, and LaTeX Workshop does not allow me to use interactive/login shell which are the usual way through which I configure my PATHs.

You can also formulate this issue differently: The environment variables seen by build tasks and the integrated console are different, and there is no way to make them the same.

To Reproduce

Steps to reproduce the behavior:

  1. Use bash as your SSH login shell
  2. Configure .bashrc to set PATHs
  3. Set up VS Code Remote
  4. Check in integrated terminal that you can find latex binaries

Expected behavior

LaTeX workshop should be able to find the binaries, too, but it does not.

Logs [Required]

Please paste the whole log messages here, not parts of ones. The log should start with Initializing LaTeX Workshop. It is very important to identify problems.

LaTeX Workshop Output [Required]

[09:12:28] Initializing LaTeX Workshop.
[09:12:28] Extension root: /home/bers/.vscode-server/extensions/james-yu.latex-workshop-8.13.2
[09:12:28] Creating PDF file watcher.
[09:12:28] Cannot run pdflatex to determine if we are using MiKTeX
[09:12:28] Creating LaTeX Workshop http and websocket server.
[09:12:28] LaTeX Workshop initialized.
[09:12:28] Current workspace folders: ["file:///home/bers/proj1","file:///home/bers/proj2","file:///home/bers/proj3"]
[09:12:28] Current workspaceRootDir: /home/bers/proj3
[09:12:28] Found root file from active editor: /home/bers/proj3/proj3_jrnl.tex
[09:12:28] Root file changed: from undefined to /home/bers/proj3/proj3_jrnl.tex
[09:12:28] Start to find all dependencies.
[09:12:28] Instantiating a new file watcher for /home/bers/proj3/proj3_jrnl.tex
[09:12:28] Creating Bib file watcher.
[09:12:28] Parsing a file and its subfiles: /home/bers/proj3/proj3_jrnl.tex
[09:12:28] Found .bib file: /home/bers/proj3/journals.bib
[09:12:28] Added to bib file watcher: /home/bers/proj3/journals.bib
[09:12:28] Parsing .bib entries from /home/bers/proj3/journals.bib
[09:12:28] Cannot find .bib file: \jobname
[09:12:28] Parse fls file.
[09:12:28] Fls file found: /home/bers/proj3/_out/proj3_jrnl.fls
[09:12:28] Parse aux file: /home/bers/proj3/_out/proj3_jrnl.aux
[09:12:28] Found .bib file: /home/bers/proj3/journals.bib
[09:12:28] Found .bib file: /home/bers/proj3/proj3_jrnl.bib
[09:12:28] Added to bib file watcher: /home/bers/proj3/proj3_jrnl.bib
[09:12:28] Parsing .bib entries from /home/bers/proj3/proj3_jrnl.bib
[09:12:28] Server created on 127.0.0.1:37087
[09:12:28] Added to file watcher: /home/bers/proj3/proj3_jrnl.tex
[09:12:28] Added to file watcher: [some file]
[09:12:28] Added to file watcher: [some file]
[09:12:28] Added to file watcher: [some file]
[09:12:28] Added to file watcher: [some file]
[09:12:28] Added to file watcher: [some file]
[09:12:28] Snippet data loaded.
[09:12:28] LaTeX Workshop version: 8.13.2
[09:12:28] Parsed 0 bib entries from /home/bers/proj3/journals.bib.
[09:12:28] Parsed 4 bib entries from /home/bers/proj3/proj3_jrnl.bib.
[09:12:31] Current workspace folders: ["file:///home/bers/proj1","file:///home/bers/proj2","file:///home/bers/proj3"]
[09:12:31] Current workspaceRootDir: /home/bers/proj3
[09:12:31] Found root file from active editor: /home/bers/proj3/proj3_jrnl.tex
[09:12:31] Keep using the same root file: /home/bers/proj3/proj3_jrnl.tex.
[09:12:35] Current workspace folders: ["file:///home/bers/proj1","file:///home/bers/proj2","file:///home/bers/proj3"]
[09:12:35] Current workspaceRootDir: /home/bers/proj3
[09:12:35] Found root file from active editor: /home/bers/proj3/proj3_jrnl.tex
[09:12:35] Keep using the same root file: /home/bers/proj3/proj3_jrnl.tex.

Developer Tools Console [Required]

Nothing suspicious

Screenshots

I think this sums it up nicely:
image

Desktop [Required]

  • OS: Windows 10
  • VS Code version: 1.49.1
  • Extension version: 8.13.2
  • TeX distribution version: TeX Live 2020

Additional questions

Are you using VSCodium?

No

Are you using LaTeX Workshop with VS Code Remote?

Yes

If the answer is Yes, please write which one you are using. Write the versions of the remote extension.

  • Remote SSH
  • Remote Extension Version: 0.55.0

Additional context

Add any other context about the problem here.

@bersbersbers
Copy link
Author

@tamuratak Done.

@bersbersbers
Copy link
Author

Adding one more thing: I can (currently) run a task like this in tasks.json:

        {
            "label": "latexmk",
            "type": "shell",
            "command": "latexmk",
        }

So even "Tasks" find the binary. My environment must be configured correctly, but LaTeX workshop is not reading it correctly.

@tamuratak
Copy link
Contributor

Please paste the log when you executed the build command of LaTeX and it failed. The current one is useless.

@bersbersbers
Copy link
Author

@tamuratak here you go. I'm surprised to see the correct PATH, but then again I am surprised that it still does not launch latexmk in /home/bers/opt/texlive/2020/bin/x86_64-linux/latexmk

[09:34:34] Initializing LaTeX Workshop.
[09:34:34] Extension root: /home/bers/.vscode-server/extensions/james-yu.latex-workshop-8.13.2
[09:34:34] Creating PDF file watcher.
[09:34:34] Cannot run pdflatex to determine if we are using MiKTeX
[09:34:34] Creating LaTeX Workshop http and websocket server.
[09:34:34] LaTeX Workshop initialized.
[09:34:34] Current workspace folders: ["file:///home/bers/proj1","file:///home/bers/proj2","file:///home/bers/proj3"]
[09:34:34] Current workspaceRootDir: /home/bers/proj3
[09:34:34] Found root file from active editor: /home/bers/proj3/proj3_jrnl.tex
[09:34:34] Root file changed: from undefined to /home/bers/proj3/proj3_jrnl.tex
[09:34:34] Start to find all dependencies.
[09:34:34] Instantiating a new file watcher for /home/bers/proj3/proj3_jrnl.tex
[09:34:34] Creating Bib file watcher.
[09:34:34] Parsing a file and its subfiles: /home/bers/proj3/proj3_jrnl.tex
[09:34:34] Found .bib file: /home/bers/proj3/journals.bib
[09:34:34] Added to bib file watcher: /home/bers/proj3/journals.bib
[09:34:34] Parsing .bib entries from /home/bers/proj3/journals.bib
[09:34:34] Cannot find .bib file: \jobname
[09:34:34] Parse fls file.
[09:34:34] Fls file found: /home/bers/proj3/_out/proj3_jrnl.fls
[09:34:34] Parse aux file: /home/bers/proj3/_out/proj3_jrnl.aux
[09:34:34] Found .bib file: /home/bers/proj3/journals.bib
[09:34:34] Found .bib file: /home/bers/proj3/proj3_jrnl.bib
[09:34:34] Added to bib file watcher: /home/bers/proj3/proj3_jrnl.bib
[09:34:34] Parsing .bib entries from /home/bers/proj3/proj3_jrnl.bib
[09:34:34] Server created on 127.0.0.1:33323
[09:34:34] Added to file watcher: /home/bers/proj3/proj3_jrnl.tex
[09:34:34] Added to file watcher: /home/bers/proj3/[some file]
[09:34:34] Added to file watcher: /home/bers/proj3/[some file]
[09:34:34] Added to file watcher: /home/bers/proj3/[some file]
[09:34:34] Added to file watcher: /home/bers/proj3/[some file]
[09:34:34] Added to file watcher: /home/bers/proj3/[some file]
[09:34:34] Snippet data loaded.
[09:34:34] LaTeX Workshop version: 8.13.2
[09:34:34] Parsed 0 bib entries from /home/bers/proj3/journals.bib.
[09:34:34] Parsed 4 bib entries from /home/bers/proj3/proj3_jrnl.bib.
[09:34:42] BUILD command invoked.
[09:34:42] Current workspace folders: ["file:///home/bers/proj1","file:///home/bers/proj2","file:///home/bers/proj3"]
[09:34:42] Current workspaceRootDir: /home/bers/proj3
[09:34:42] Found root file from active editor: /home/bers/proj3/proj3_jrnl.tex
[09:34:42] Keep using the same root file: /home/bers/proj3/proj3_jrnl.tex.
[09:34:42] Building root file: /home/bers/proj3/proj3_jrnl.tex
[09:34:42] Build root file /home/bers/proj3/proj3_jrnl.tex
[09:34:42] Recipe step 1: latexmk, -synctex=1,-interaction=nonstopmode,-file-line-error,-pdf,-outdir=_out,/home/bers/proj3/proj3_jrnl
[09:34:42] cwd: /home/bers/proj3
[09:34:42] LaTeX build process spawned. PID: undefined.
[09:34:42] LaTeX fatal error: spawn latexmk ENOENT, . PID: undefined.
[09:34:42] Does the executable exist? PATH: /home/bers/.vscode-server/bin/58bb7b2331731bf72587010e943852e13e6fd3cf/bin:/home/bers/perl5/bin:~/opt/texlive/2020/bin/x86_64-linux:/home/bers/.pyenv/shims:~/.pyenv/bin:/usr/local/cuda/bin:/home/bers/perl5/bin:~/opt/texlive/2020/bin/x86_64-linux:/home/bers/.pyenv/shims:~/.pyenv/bin:/usr/local/cuda/bin:/home/bers/.vscode-server/bin/58bb7b2331731bf72587010e943852e13e6fd3cf/bin:/home/bers/perl5/bin:~/opt/texlive/2020/bin/x86_64-linux:/home/bers/.pyenv/shims:~/.pyenv/bin:/usr/local/cuda/bin:/usr/local/bin:/usr/bin:/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin
[09:34:42] The current SHELL: /bin/bash
[09:34:49] Current workspace folders: ["file:///home/bers/proj1","file:///home/bers/proj2","file:///home/bers/proj3"]
[09:34:49] Current workspaceRootDir: /home/bers/proj3
[09:34:49] Found root file from active editor: /home/bers/proj3/proj3_jrnl.tex
[09:34:49] Keep using the same root file: /home/bers/proj3/proj3_jrnl.tex.

@tamuratak
Copy link
Contributor

tamuratak commented Sep 20, 2020

How about stopping using ~ in PATH?

@tamuratak tamuratak added external issue Issue with something else than LaTeX-Wokshop and removed need more info More information needed to identify the issue can't reproduce Issue cannot be reproduced labels Sep 20, 2020
@bersbersbers
Copy link
Author

How about stopping using ~ in PATH?

Wow, it seems that has helped. I'll report back if it does not work long-term, but if I don't, this information might be a good candidate for the FAQ.

Repository owner locked as resolved and limited conversation to collaborators Sep 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
external issue Issue with something else than LaTeX-Wokshop
Projects
None yet
Development

No branches or pull requests

3 participants