org-roam-ui icon indicating copy to clipboard operation
org-roam-ui copied to clipboard

[BUG] 404 errors

Open fleimgruber opened this issue 3 years ago • 12 comments
trafficstars

Describe the bug Server returns 404

To Reproduce

  1. In an Org mode buffer: org-roam-ui-mode
  2. org-roam-ui-open
  3. See error in *httpd* buffer
(stop "Mon Jan  3 21:27:05 2022")
(start "Mon Jan  3 21:27:19 2022")
(request
  (date "Mon,  3 Jan 2022 20:27:35 GMT")
  (address "127.0.0.1")
  (get "/")
  (headers
   ("GET" "/" "HTTP/1.1")
   ("Host" "localhost:35901")
   ("User-Agent" "Mozilla/5.0 (X11; Linux x86_64; rv:95.0) Gecko/20100101 Firefox/95.0")
   ("Accept" "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8")
   ("Accept-Language" "en-US,en;q=0.5")
   ("Accept-Encoding" "gzip, deflate")
   ("Dnt" "1")
   ("Connection" "keep-alive")
   ("Upgrade-Insecure-Requests" "1")
   ("Sec-Fetch-Dest" "document")
   ("Sec-Fetch-Mode" "navigate")
   ("Sec-Fetch-Site" "none")
   ("Sec-Fetch-User" "?1")
   ("Sec-Gpc" "1")
   ("Content" "")))
(error 404 nil)

Browser shows a page with

Not Found

The requested URL was not found on this server.

Expected behavior Server starts and can be interacted with

What browser were you using? Firefox

Additional context Emacs 27.2 on GNU/Linux (NixOS).

fleimgruber avatar Jan 03 '22 20:01 fleimgruber

I have the same problem with Emacs 28 on guix.

chuchana avatar Feb 01 '22 23:02 chuchana

Hmmmm that is strange, did it work for you before? Have you tried this?

Otherwise, could you open the devtools (F12) and copy the output of the console here?

tefkah avatar Feb 08 '22 07:02 tefkah

The console doesn't seem to have anything interesting to say:

GET 
http://localhost:35901/
[HTTP/1.1 404 Not Found 2ms]

The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol.
localhost:35901

GET
http://localhost:35901/favicon.ico

org-roam-ui used to work on my system when I still used straight.el.

I stopped using it for a while when I switched to a guix home based configuration. When I added org-roam-ui to that new configuration, it didn't work anymore. I tried adding it via straight.el again, but I couldn't get it to work that way either.

I still wonder if it's a configuration problem, though, since nix and guix are both structured similarly and quite differently from most other systems. Does org-roam-ui rely on standard paths like /usr/bin/ etc?

Do you have any pointers for me to follow up on emacs's side?

chuchana avatar Feb 08 '22 10:02 chuchana

tl;dr: make sure the out directory is installed.

I encountered the same when I first tried to use org-roam-ui with guix. Since its not packaged in the main channel of guix, I used:

guix import elpa -a melpa org-roam-ui

to generate a package definition from melpa, then imported it to my guix channel and installed it. When I ran org-roam-ui-mode I got the same 404 error. I looked around the issues here on github and found this issue and #77. And the answer on #77 pointed me in the right direction.

The guix package definition did not install the out directory. As I noticed when inspecting the output with:

tree $(guix build emacs-org-roam-ui)  

It was due to the regex matching in the #:include list in the arguments of the package definition. It was ^out$, which means it will ignore any files in that directory. To fix it simply remove the $ and it will install the out directory as well.

Here's the package definition I am using:

(define-public emacs-org-roam-ui
  (package
    (name "emacs-org-roam-ui")
    (version "20220225.2151")
    (source
      (origin
        (method git-fetch)
        (uri (git-reference
               (url "https://github.com/org-roam/org-roam-ui.git")
               (commit "df1f9522c5a9cdb248208427fa9df4f2a7666e2a")))
        (sha256
          (base32 "03kyg95f012ql0gpzy58kzxgdfksig5zlbr1p9m9ycgqmmxyq4jp"))))
    (build-system emacs-build-system)
    (propagated-inputs (list emacs-org-roam emacs-simple-httpd emacs-websocket))
    (arguments
      '(#:include
        (cons "^out" %default-include)))
    (home-page "https://github.com/org-roam/org-roam-ui")
    (synopsis "User Interface for Org-roam")
    (description
      "  Org-roam-ui provides a web interface for navigating around notes created
  within Org-roam.")
    (license license:gpl3+)))

And guix describe

Generation 170  mar 07 2022 15:00:38    (current)
  guix e7886fd
    repository URL: https://git.savannah.gnu.org/git/guix.git
    branch: master
    commit: e7886fd6746267e26cf11628f96d8082680b496f
  flat ece373b
    repository URL: https://github.com/flatwhatson/guix-channel.git
    branch: master
    commit: ece373bcd1e00ef746fb7b104e56ab610cc4af2a
  plattfot 8b2cb1b
    repository URL: file:///home/plattfot/projects/plattfot-guix-channel
    branch: master
    commit: 8b2cb1b49cd953b67a06ce1e99687df197d1b728

And org-roam-ui seems to be working fine for me on emacs-28.0.91.

edit: Fix typo mepla -> melpa

plattfot avatar Mar 07 '22 23:03 plattfot

Thank you for both the solution and the detailed answer!

I modified my package definition, so I did not try it, but I assume the first code snippet has a typo and should read like this:

guix import elpa -a melpa org-roam-ui

chuchana avatar Mar 08 '22 11:03 chuchana

You are correct. I have fixed the typo in my previous answer. Thank you for pointing it out, took me a few seconds to actually see what what was wrong when comparing the two.

plattfot avatar Mar 08 '22 18:03 plattfot

Tried again with latest version org-roam-ui-20220225.2151 from MELPA and that works. So from my side this can be closed, will leave it open for others to confirm solved.

fleimgruber avatar Mar 09 '22 06:03 fleimgruber

Another Guix user here, using commit 16a8da9e5107833032893bc4c0680b368ac423ac. I haven't played with all the features yet but the ui is working.

@plattfot - Do you plan to submit your package to upstream Guix?

trev-dev avatar Sep 14 '22 19:09 trev-dev

@trev-dev - Yes, that is the plan. I just forgot about it, so thanks for the reminder :slightly_smiling_face:. I'm actually planning on submitting a few other packages upstream this weekend, so I'll include this one as well.

plattfot avatar Sep 14 '22 21:09 plattfot

Here's the guix issue 57891 for it.

plattfot avatar Sep 17 '22 22:09 plattfot

Quick update, the package wont be going to guix's main channel until the minified JS code is packaged properly. I have too little experience to take that on and guix right now doesn't handle JS that well.

plattfot avatar Sep 19 '22 17:09 plattfot

It's not that guix doesn't handle JS well. It's that nobody is writing guix packages for NPM modules.

This is largely because NPM moves at a break-neck speed. The Guix build environment is sanitary and contained so one cannot simply "npm install" and pull code from the Internet from within the build environment.

The package.json file seems to have in the neighborhood of 70 dependencies, all which may have their own dependencies.

So our options really are:

  1. Make some effort to port what will likely be over a hundred NPM packages to the Guix package manager

  2. Accept that we all just need to package this ourselves by following some of the directions in this thread.

Obviously option 1 comes with all of the same problems NPM has only it will undoubtedly fall behind much faster.

NPM is a wild, wonderful thing but some feel like it's slightly dystopian. Welcome to dependency hell!

If anyone stumbling upon this thread wants a working example of a custom package, they are welcome to use my channel or copy my definition found here. Fair warning though, I may not maintain it as I am looking pretty favorably at simpler solutions for my note-taking.

trev-dev avatar Sep 19 '22 17:09 trev-dev