tecosaur / LaTeX-Utilities

An add-on to LaTeX Workshop that provides some features that go beyond the bare essentials
MIT License
474 stars 28 forks source link

Zotero citation feature in a container #375

Closed maximecharriere closed 1 year ago

maximecharriere commented 1 year ago

Bug Report

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

You still see this issue?: Yes

Describe the bug

If a Docker container is used to write a LaTeX document, it' not possible to use the Zotero citation feature. It's working fine if LaTeX is used locally.
The error is Zotero doesn't appear to be running.
It's probably due to the port, but I don't know how to correct this error.

To Reproduce

Steps to reproduce the behaviour:

  1. Open a Docker container in VSCode using the Dev Container extension,
  2. Install Latex Workshop & Utilities extensions in the container,
  3. Open Zotero,
  4. Run the Latex Utilities: Cite from Zotero command

Expected behaviour

The citaion textbox should appear

Logs

Please paste the whole log messages here, not parts of ones. It is very important to identify problems. If you think the logs are unrelated, please say so.

LaTeX Workshop Output ``` [14:19:20] Initializing LaTeX Workshop. [14:19:20] Extension root: /home/vscode/.vscode-server/extensions/james-yu.latex-workshop-9.2.1 [14:19:20] $PATH: /vscode/vscode-server/bin/linux-x64/e8a3071ea4344d9d48ef8a4df2c097372b0c5161/bin/remote-cli:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/vscode/.local/bin [14:19:20] $SHELL: /bin/bash [14:19:20] $LANG: undefined [14:19:20] $LC_ALL: undefined [14:19:20] process.platform: linux [14:19:20] process.arch: x64 [14:19:20] vscode.env.appName: Visual Studio Code [14:19:20] vscode.env.remoteName: dev-container [14:19:20] vscode.env.uiKind: 1 [14:19:20] Configuration for workspace: file:///workspaces/PV panels recycling [14:19:20] editor.acceptSuggestionOnEnter: "on" [14:19:20] latex-workshop.bind.enter.key: true [14:19:20] latex-workshop.docker.enabled: false [14:19:20] latex-workshop.docker.image.latex: "" [14:19:20] latex-workshop.hover.preview.mathjax.extensions: [] [14:19:20] latex-workshop.intellisense.package.enabled: true [14:19:20] latex-workshop.intellisense.update.aggressive.enabled: false [14:19:20] latex-workshop.intellisense.update.delay: 1000 [14:19:20] latex-workshop.latex.autoBuild.run: "onSave" [14:19:20] latex-workshop.latex.build.forceRecipeUsage: true [14:19:20] latex-workshop.latex.outDir: "%DIR%/_build" [14:19:20] latex-workshop.latex.recipes: [ { "name": "latexmk (.latexmkrc)", "tools": [ "latexmk_rconly" ] }, { "name": "latexmk (cmd)", "tools": [ "latexmk" ] } ] [14:19:20] latex-workshop.latex.tools: [ { "name": "latexmk_rconly", "command": "latexmk", "args": [ "-interaction=nonstopmode", "-file-line-error", "%DOC%" ], "env": {} }, { "name": "latexmk", "command": "latexmk", "args": [ "-synctex=1", "--shell-escape", "-interaction=nonstopmode", "-file-line-error", "-pdf", "-outdir=%OUTDIR%", "-pdflua", "%DOC%" ], "env": {} }, { "name": "bibtex", "command": "bibtex", "args": [ "%DOCFILE%" ], "env": {} } ] [14:19:20] latex-workshop.viewer.pdf.internal.keyboardEvent: "auto" [14:19:20] Creating a new file watcher. [14:19:20] watcherOptions: {"useFsEvents":false,"usePolling":false,"interval":300,"binaryInterval":1000,"awaitWriteFinish":{"stabilityThreshold":250}} [14:19:20] Creating PDF file watcher. [14:19:20] watcherOptions: {"useFsEvents":false,"usePolling":false,"interval":300,"binaryInterval":1000,"awaitWriteFinish":{}} [14:19:20] Creating Bib file watcher. [14:19:20] watcherOptions: {"useFsEvents":false,"usePolling":false,"interval":300,"binaryInterval":1000,"awaitWriteFinish":{"stabilityThreshold":250}} [14:19:20] Set $LATEXWORKSHOP_DOCKER_LATEX: "" [14:19:20] [Server] Creating LaTeX Workshop http and websocket server. [14:19:20] LaTeX Workshop initialized. [14:19:20] Trigger characters for intellisense of LaTeX documents: ["\\",",","{"] [14:19:20] Bibtex format config: {"tab":" ","case":"lowercase","left":"{","right":"}","trailingComma":false,"sort":["key"],"alignOnEqual":true,"sortFields":false,"fieldsOrder":[],"firstEntries":["string","xdata"]} [14:19:20] Current workspace folders: ["file:///workspaces/PV panels recycling"] [14:19:20] Found root file from active editor: /workspaces/PV panels recycling/ProofOfCompetence.tex [14:19:20] Root file changed: from undefined to /workspaces/PV panels recycling/ProofOfCompetence.tex [14:19:20] Start to find all dependencies. [14:19:20] Root file languageId: latex [14:19:20] Reset file watcher. [14:19:20] Parsing a file and its subfiles: /workspaces/PV panels recycling/ProofOfCompetence.tex [14:19:21] Parsing a file and its subfiles: /workspaces/PV panels recycling/glossary.tex [14:19:21] Found .bib file: /workspaces/PV panels recycling/bibresource.bib [14:19:21] Added to bib file watcher: /workspaces/PV panels recycling/bibresource.bib [14:19:21] Parsing .bib entries from /workspaces/PV panels recycling/bibresource.bib [14:19:21] [Server] Server successfully started: {"address":"127.0.0.1","family":"IPv4","port":43297} [14:19:21] Added to file watcher: /workspaces/PV panels recycling/ProofOfCompetence.tex [14:19:21] Added to file watcher: /workspaces/PV panels recycling/glossary.tex [14:19:21] Snippet data loaded. [14:19:21] [Server] valdOrigin is http://127.0.0.1:43297 [14:19:21] Parsed 34 bib entries from /workspaces/PV panels recycling/bibresource.bib. [14:19:21] Parse fls file. [14:19:21] Fls file found: /workspaces/PV panels recycling/_build/ProofOfCompetence.fls [14:19:21] Parse aux file: /workspaces/PV panels recycling/_build/ProofOfCompetence.aux [14:19:22] Checking for duplicate labels: /workspaces/PV panels recycling/ProofOfCompetence.tex. [14:19:22] Checking for duplicate labels: /workspaces/PV panels recycling/glossary.tex. [14:19:22] Added to file watcher: /home/vscode/texmf/tex/latex/bfh-ci/bfhthesis.cls [14:19:22] Added to file watcher: /home/vscode/texmf/tex/latex/bfh-ci/bfhlayout.sty [14:19:22] Added to file watcher: /home/vscode/.texlive2021/texmf-var/luatex-cache/generic/names/luaotfload-names.luc.gz [14:19:22] Added to file watcher: /home/vscode/texmf/tex/latex/bfh-ci/bfhcolors.sty [14:19:22] Added to file watcher: /home/vscode/texmf/tex/latex/bfh-ci/bfhfonts.sty [14:19:22] Added to file watcher: /home/vscode/.texlive2021/texmf-var/luatex-cache/generic/names/luaotfload-lookup-cache.luc [14:19:22] Added to file watcher: /home/vscode/texmf/tex/latex/bfh-logo/BFH-logo_4CU.pdf [14:19:22] Added to file watcher: /home/vscode/texmf/tex/latex/bfh-logo/bfhlogo.sty [14:19:22] Added to file watcher: /home/vscode/texmf/tex/latex/bfh-ci/bfhmodule.sty [14:19:22] Added to file watcher: /home/vscode/texmf/tex/latex/bfh-ci/bfhtranslations-english.trsl [14:19:22] Added to file watcher: /home/vscode/texmf/tex/latex/bfh-logo/BFH-logotext_single-en_4CU.pdf [14:19:22] Added to file watcher: /workspaces/PV panels recycling/variables.sty [14:19:22] Added to file watcher: /workspaces/PV panels recycling/_build/ProofOfCompetence.gls [14:19:22] Added to file watcher: /workspaces/PV panels recycling/pictures/circular-model.png [14:19:22] Added to file watcher: /workspaces/PV panels recycling/pictures/banner.jpg [14:19:22] Added to file watcher: /workspaces/PV panels recycling/pictures/business-model-canvas.jpg [14:19:22] Added to file watcher: /workspaces/PV panels recycling/pictures/distribution.png [14:19:23] Manager.fileWatcher.getWatched: {"/workspaces/PV panels recycling":["ProofOfCompetence.tex","glossary.tex","variables.sty"],"/home/vscode/texmf/tex/latex/bfh-ci":["bfhcolors.sty","bfhfonts.sty","bfhlayout.sty","bfhmodule.sty","bfhthesis.cls","bfhtranslations-english.trsl"],"/home/vscode/.texlive2021/texmf-var/luatex-cache/generic/names":["luaotfload-lookup-cache.luc","luaotfload-names.luc.gz"],"/home/vscode/texmf/tex/latex/bfh-logo":["BFH-logo_4CU.pdf","BFH-logotext_single-en_4CU.pdf","bfhlogo.sty"],"/workspaces/PV panels recycling/pictures":["banner.jpg","business-model-canvas.jpg","circular-model.png","distribution.png"],"/workspaces/PV panels recycling/_build":["ProofOfCompetence.gls"]} [14:19:23] Manager.filesWatched: ["/workspaces/PV panels recycling/ProofOfCompetence.tex","/workspaces/PV panels recycling/glossary.tex","/home/vscode/texmf/tex/latex/bfh-ci/bfhthesis.cls","/home/vscode/.texlive2021/texmf-var/luatex-cache/generic/names/luaotfload-names.luc.gz","/home/vscode/texmf/tex/latex/bfh-ci/bfhlayout.sty","/home/vscode/texmf/tex/latex/bfh-ci/bfhcolors.sty","/home/vscode/texmf/tex/latex/bfh-ci/bfhfonts.sty","/home/vscode/.texlive2021/texmf-var/luatex-cache/generic/names/luaotfload-lookup-cache.luc","/home/vscode/texmf/tex/latex/bfh-logo/bfhlogo.sty","/home/vscode/texmf/tex/latex/bfh-logo/BFH-logo_4CU.pdf","/home/vscode/texmf/tex/latex/bfh-ci/bfhmodule.sty","/workspaces/PV panels recycling/variables.sty","/home/vscode/texmf/tex/latex/bfh-ci/bfhtranslations-english.trsl","/home/vscode/texmf/tex/latex/bfh-logo/BFH-logotext_single-en_4CU.pdf","/workspaces/PV panels recycling/pictures/banner.jpg","/workspaces/PV panels recycling/_build/ProofOfCompetence.gls","/workspaces/PV panels recycling/pictures/business-model-canvas.jpg","/workspaces/PV panels recycling/pictures/circular-model.png","/workspaces/PV panels recycling/pictures/distribution.png"] [14:19:23] BibWatcher.bibWatcher.getWatched: {"/workspaces/PV panels recycling":["bibresource.bib"]} [14:19:23] BibWatcher.bibsWatched: ["/workspaces/PV panels recycling/bibresource.bib"] [14:19:23] PdfWatcher.pdfWatcher.getWatched: {} [14:19:23] PdfWatcher.pdfsWatched: [] [14:19:23] PdfWatcher.watchedPdfVirtualUris: [] [14:19:23] PdfWatcher.ignoredPdfUris: [] ```
LaTeX Utilities Output ``` [14:19:20] Initializing LaTeX Utilities. [14:19:20] Live Snippets Loaded [14:19:20] Completion Watcher Initialised [14:19:20] TexCount args: -merge,-brief [14:19:20] LaTeX Utilities Started [14:19:21] TeXCount output for word: !!! Could not identify document class. !!! 1218+119+27 (50/5/0/0) File: ProofOfCompetence.tex (errors:1) [14:19:21] TexCount args: -merge,-brief,-char [14:19:21] LaTeX Utilities version: 0.4.9 [14:19:22] TeXCount output for char: !!! Could not identify document class. !!! 5705+765+133 (50/5/0/0) File: ProofOfCompetence.tex (errors:1) [14:20:44] citeZotero ```
Developer Tools Console ``` logs here ```

Desktop

maximecharriere commented 1 year ago

I added the forwardPorts option in the .devontainer file, but the problem remains

{
    "name": "BFH LaTeX CI",
    "image": "registry.gitlab.ti.bfh.ch/bfh-latex/registry/vscode:2.1.3",

    "extensions": [
        "james-yu.latex-workshop",
        "tecosaur.latex-utilities",
        "mathematic.vscode-latex"
    ],
    "forwardPorts": [23119],

    "remoteUser": "vscode",
    "postCreateCommand": "sudo tlmgr update --self && sudo tlmgr install pdfcol biblatex-apa"
 }
leoleoasd commented 1 year ago

I think forwardPorts forward ports from containers to the outside world? We actually need to access the Zotero instance on the outer world from within the container.

leoleoasd commented 1 year ago

Try changing latex-utilities.zotero.zoteroUrl config, replace localhost with the ip address of your machine?

maximecharriere commented 1 year ago
In the latex-utilities.zotero.zoteroUrl setting, I tried the following options with the corresponding results:
(The Popup is the message Zotero doesn't appear to be running.)
Address Result
http://localhost:23119/ Popup & Zotero doesn't react
http://127.0.0.1:23119/ Popup & Zotero doesn't react
http://127.0.0.1:XXXX/ (any port) Popup & Zotero doesn't react
http://127.XXX.XXX.XXX:XXXX/ (any sub-address & port) Popup & Zotero doesn't react
http://host.docker.internal:23119/ No Popup & Zotero doesn't react
http://192.168.65.2:23119/ No Popup & Zotero doesn't react
http://qwerty123ABC:12345/ (any address & port) No Popup & Zotero doesn't react

So unfortunately it still doesn't work.

leoleoasd commented 1 year ago

Maybe Zotero is only listening on 127.0.0.1. Try other port forwarding tools that can forward a host port into the container? Like ssh to the host within the container?

leoleoasd commented 1 year ago

Sorry I mean maybe Zotero is only listening on 127.0.0.1 so trying to access it with 182.168.65.2 doesn't work.

leoleoasd commented 1 year ago

According to https://github.com/zotero/zotero/blob/master/chrome/content/zotero/xpcom/server.js#L64 and https://github.com/zotero/zotero/blob/master/chrome/content/zotero/xpcom/zotero.js#L683, Zotero does only listen on 127.0.0.1. We need to set a port forwarding to do this.

For example, if you want to use ssh to forward port, you can try:

  1. enable ssh server on your host machine
  2. execute this inside container ssh -L 23119:127.0.0.1:23119 ${HOST_IP}
  3. try accessing zotero from container curl 127.0.0.1:23119 You can also try setting up a port forwarding service on your host machine that forwards another port to 127.0.0.1:23119, and set it to listen on all addresses and update the config to http://hostip:new_port.