-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
FileNotFoundException when running cljr-clean-ns #380
Comments
i checked with the same version of cljr on a project of mine, worked fine. this only means that there is no general regression in this feature in 2.3.1. your buffer needs to be backed by an actual file visible for the nrepl middleware part of the project. any chance it is not the case? also can you please share further specifics of your project? any chance you can share a link to the project itself? |
Thanks for checking in on this. I'm not able to share the project with you, sorry. It is a standard lein project, with a file in the The message of the exception is suspicious to me:
Typically,
Perhaps the full path isn't being sent to nrepl? |
You can check what's being sent to the middleware by checking the There's nothing else special with your setup? Everything is local? E.g. no docker containers, tramp connections to a remote server etc? I use |
Hmm... I don't have a I added some log messages to
It seems to think that the project directory is the directory of the Clojure file I'm trying to clean. Ah hah! Looking at Ugh, that is frustrating. I wonder if there's a better way to implement |
Ah, damn! Yeah, that function is probably a bit too naive. I suppose the next step would be to just peek into the file and ensure a
Sorry about that, it's invisible by default, but you can toggle it with FWIW, the relative path stuff was added to fix #286, so clean-ns would work in a Vagrant setup. To get on with your day you can just send down the absolute path, instead of the project relative one, until this one is patched properly. Thanks for taking the time to dig into this yourself! 👍 |
I'm also running into this, in a situation where I'm editing a file that's part of a different project, but that's also on the classpath (e.g. when a code base is split across multiple repos). I imagine this scenario will become ever more common, as tools.deps makes it so easy with The easiest way to fix this is to pass the absolute rather than the relative path, so to revert the "fix" for #286, which is essentially about making things work when running nREPL on a remote machine. Neither of these approaches is totally correct, because they both make assumptions that aren't always true.
A better approach could be to determine from the Emacs side which namespace the user is editing, and then on the JVM side looking up the corresponding file on the classpath. This also makes an assumption, namely that if you're editing a file that declares To really make this foolproof you could try in order
Looking at it this way, I think for starters doing 2 & 3 would already fix a lot cases. Happy to put together a PR for this. The current behaviour assumes that the project root (the first parent directory to contain (cljr--project-relative-path filename) And then pass the result to the JVM and do (io/file relative-path) and that the result is again the original file. |
Allow the client to send both the absolute path and a relative path to a file, we use the first one that we can find. The absolute path is used when the client (Emacs) and the JVM are on the same filesystem/same machine. The second is used when they are not on the same filesystem (e.g. running nREPL on a remote machine or in a VM), but the JVM runs in the (mounted) project directory, so that relative file lookups still work. See clojure-emacs/clj-refactor.el#380 (comment)
I'm pretty certain I fixed this one in refactor-nrepl at some point |
Expected behavior
I expect
cljr-clean-ns
to run without error.Actual behavior
Steps to reproduce the problem
cider-jack-in
for a projectM-x cljr-clean-ns
on that bufferEnvironment & Version information
The text was updated successfully, but these errors were encountered: