NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.48k stars 13.66k forks source link

RStudio's visual markdown editor stays loading forever #210826

Open kotatsuyaki opened 1 year ago

kotatsuyaki commented 1 year ago

Describe the bug

When trying to switch to the "visual editor" for Quarto markdown files, the editor stays loading with a spinning indicator in the middle forever (20 minutes+), without any error messages both on the GUI and on stdout/stderr. See the screenshot below.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Run RStudio by nix run nixpkgs#rstudio, where my nixpkgs is pinned to commit b3818a4.
  2. Create a Quarto .qmd file by clicking New Blank File => Quarto Doc... in the Files panel, and insert the following Markdown content.

    ---
    title: Test Document
    ---
    
    # Test Heading
    
    ## Test Heading
    
    Test body
  3. On the top-left corner of the editor panel, click Visual to switch from the source editor to the visual editor.

Expected behavior

The visual editor should be able to render the content and provide editing functionalities.

Screenshots

Screenshot_20230115_125814

Additional context

rstudio/rstudio#10674 - This closed issue in the RStudio repository suggests that the problem may have something to do with the RSTUDIO_PANDOC environment variable. On my RStudio, the value of this environment variable is a path under RStudio in /nix/store:

> Sys.getenv('RSTUDIO_PANDOC')
[1] "/nix/store/1fdbg2jzmmvysbrq3dck04zsjflaln0s-RStudio-2022.07.1+554/lib/rstudio/bin/quarto/bin/tools"

However, this path does not exist:

$ ls /nix/store/1fdbg2jzmmvysbrq3dck04zsjflaln0s-RStudio-2022.07.1+554/lib/rstudio/bin/quarto/bin/tools
ls: cannot access '/nix/store/1fdbg2jzmmvysbrq3dck04zsjflaln0s-RStudio-2022.07.1+554/lib/rstudio/bin/quarto/bin/tools': No such file or directory

This seems odd, since the Nix derivation for RStudio already patches the path to be "@pandoc@" and uses substituteInPlace to replace @pandoc@ with a path to the pandoc binary from Nixpkgs.

Notify maintainers

@ciil and @cfhammill

Metadata

nixpkgs pinned in the registry.

$ nix registry list | grep nixpkgs
system flake:nixpkgs path:/nix/store/d02gi2ddx87l037ghfpxg8z7nxkd6f7n-source?lastModified=1673027386&narHash=sha256-Wjt+oDhRLcf3opIjUKHGN+Xrp3w2ZDms6bO4pCLvsco=&rev=b3818a46e686f24561a28eaa9fcf35e18b8d8e89

Information other than nixpkgs version (which is inaccurate due to me using Flakes) obtained by nix-info.

$ nix-info -m
 - system: `"x86_64-linux"`
 - host os: `Linux 6.0.17, NixOS, 23.05 (Stoat), 23.05.20230106.b3818a4`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.12.0`
hervyqa commented 1 year ago

i confirm it.

RStudio 2022.07.1+554 "Spotted Wakerobin" Release (99999999999999999999999999999999, 1980-01-01) for Linux Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/5.15.13 Chrome/87.0.4280.144 Safari/537.36

Screenshot_20230606_071730

nviets commented 11 months ago

@kevinushey, @jgutman, @jmcphers - Hi there! Huge Posit/RStudio fans here :) We've been supporting a version of the open source RStudio in nixpkgs for several years now (desktop and server), but we haven't had any luck getting the Visual Editor to work. Nixpkgs is a unique package manager that handles dependencies all the way down the stack, and we've done a bit of hacking to get it working nicely here. The Visual Editor has been tricky for us to crack, however, because we don't understand the mechanics under the hood. Would any of you be available to answer a few questions? We're happy to do the leg work and heavy lifting, but we could really use a few hints. @Kupac, @jbedo, @b-rodrigues, @cfhammill

kevinushey commented 11 months ago

I can try to help. The main thing that stands out for this issue -- RStudio now bundles Quarto, and uses the version of Pandoc bundled with Quarto -- hence the new path seen for RSTUDIO_PANDOC.

Perhaps the key bit is that the default Pandoc path is now read from here:

https://github.com/rstudio/rstudio/blob/7afe4f1a25b8426727c92ec7345e60c311238931/src/cpp/session/session-options.json#L713-L719

and also see how the Pandoc path is set here:

https://github.com/rstudio/rstudio/blob/7afe4f1a25b8426727c92ec7345e60c311238931/src/cpp/session/include/session/SessionConstants.hpp#L144-L148

Based on that, and given the patch in https://github.com/NixOS/nixpkgs/blob/b3818a46e686f24561a28eaa9fcf35e18b8d8e89/pkgs/applications/editors/rstudio/pandoc-nix-path.patch, I think both of the Pandoc path constants need to be patched.

nviets commented 11 months ago

Hi @kevinushey - thanks so much for your quick reply and for taking a look. This issue has been open awhile, and I should have included a link to the master branch. @Kupac just updated to Rstudio 2023 09 0 463, and I think he addresses some of what you pointed out. @Kupac does your patch adjust for both of the Pandoc path constants? Latest patch from master: here.

We might move this discussion to a branch soon to get some build logs going.

kevinushey commented 11 months ago

The other thing you might try, to get a bit more information -- if you right click somewhere in the IDE surface, you should get Inspect Element as a menu option; click that to open the RStudio developer tools. If you then try to open the visual editor while those tools are up, you might get some extra information in the console there regarding what's going wrong.

You can also click on the Source tab, and try to stop on exception, to see if you can get some useful backtraces -- unfortunately the JS is likely to be obfuscated so it may be challenging to divine the issue just form that.

Kupac commented 11 months ago

Thanks, this is great advice for troubleshooting the issue. Exactly what I was missing. But I'll check the patches first, I don't think I patched the json file, I think we missed that it's referred to in two places

biscotty666 commented 4 months ago

Has any progress been made on this? Ty.

b-rodrigues commented 4 months ago

A new Rstudio got released, it'll be a good opportunity to revisit visual mode https://docs.posit.co/ide/news/

biscotty666 commented 4 months ago

Cool. I'm happy to test it or otherwise help if I can.

⁣Get BlueMail for Android ​

On May 1, 2024, 09:13, at 09:13, Bruno Rodrigues @.***> wrote:

A new Rstudio got released, it'll be a good opportunity to revisit visual mode https://docs.posit.co/ide/news/

-- Reply to this email directly or view it on GitHub: https://github.com/NixOS/nixpkgs/issues/210826#issuecomment-2088612511 You are receiving this because you commented.

Message ID: @.***>

6d6f6d656e746f commented 4 days ago

Did someone end up with a solution?

biscotty666 commented 4 days ago

No, and it's really frustrating. I guess people who use R don't use NixOS much. The best thing I've come up with is running it in a Fedora distrobox. I can't seem to do R Markdown documents but Quarto documents work. I haven't been doing anything in R recently, but when I return to it I may just dual-boot :-(