Fork me on GitHub
#cider
<
2024-06-27
>
Harold17:06:56

Slightly weird one - I'm using C-c C-k, which is bound to the default cider-load-buffer, but I'm cider-connected to a repl that doesn't have access to my local filesystem, so I'm getting an error like:

------ REPL Error while processing ---------------------------------------------
(cljs.core/load-file "/home/harold/src/stuff/otherstuff/filename.cljs")
FileNotFoundException: /home/harold/src/stuff/otherstuff/filename.cljs (No such file or directory)
Is there a way to just send the buffer contents (maybe, as a string) rather than loading the file? e.g., C-M-x successfully evaluates the ns form at the top of the file. --- Or (maybe even cooler) is there a way to have it use relative rather than absolute paths? Because (due to some clever mounting) the repl does have the updated code locally at the same relative (but different absolute) path.

iarenaza18:06:25

I think what you are looking for is cider-path-translations defcustom variable See https://docs.cider.mx/cider/config/basic_config.html#translate-file-paths We use exactly that, as we cider-connect to a REPL running inside a Docker container (for various reasons) and we mount the local files inside the Docker container using a different absolute path. You can even set the value per project, by leveraging .dirs-local.el. We have something like this at the root of the (local) project

((clojure-mode . ((eval . (setq-local cider-path-translations (list (cons "/app" (clojure-project-dir (buffer-file-name (current-buffer))))))))))
where /app is where we mount the project files inside the Docker container.

Harold18:06:52

That sounds relevant! Thank you. I'll look into it.

vemv21:06:12

cider-path-translations works, it's typically meant for Docker containers. Another way is to use tramp - integration should be automatic If neither approach works for you, feel free to create a detailed issue and we'll take it from there

👍 1