JonyEpsilon / gorilla-repl

A rich REPL for Clojure in the notebook style.
http://gorilla-repl.org
MIT License
888 stars 104 forks source link

.nrepl-port written to $PWD, which may not be writable #229

Closed mattexx closed 8 years ago

mattexx commented 8 years ago

We have gorilla-repl running on an app we distribute so we can debug things easily. We have many users who try to run the app when $PWD is a folder where they don't have write access. The app fails to run, and they get confused.

Suggested resolution: Write .nrepl-port in $HOME.

mattexx commented 8 years ago

PR #230 -- but happy to facilitate resolving this another way if preferred. :smile:

JonyEpsilon commented 8 years ago

Interesting ... there are so many unexpected ways for things to fail!

I don't think writing to $HOME is the right thing to do. The idea of the .*-port files is to allow other tooling to connect to running nREPL instances without user configuration. So it's a "per nREPL instance" configuration - you might have more than one nREPL running at a time (I usually have many) - and so it isn't really right for it to live in $HOME. At the minute the way it works is that it's per-project, which still isn't quite right, as you can have more than one nREPL running in a given project, but it's the best you can do easily.

I can see two ways of fixing the problem: first is just to handle the error and not crash out when we can't write the file. The second is to not try and write anything if gorilla is not invoked by lein-gorilla, or maybe more explicitly offer a way to choose whether the file is written when Gorilla is run directly.

p.s. would love to know about the app you're distributing, if you're at liberty to discuss. Always interested to know what Gorilla is being used for :-)

mattexx commented 8 years ago

I like the last idea you mentioned a lot: give the option to specify the location. Something like

(defn start-and-connect
  ([nrepl-requested-port]  (start-and-connect nrepl-requested-port (io/file ".nrepl-port"))
  ([nrepl-requested-port repl-port-file]
  ...)

And then allow it to be set with (:repl-port-file conf) in run-gorilla-server. How does that sound?

Our use case is an internal app we have written to apply SOA principles to work that needs to happen locally for file operations and things like that. We have researchers who are working in various languages but require identical functionality, so we provide a daemon that exposes a service on localhost and then provide thin clients for each research language. They can run the daemon on any research environment they want to use. The portability inevitably leads to all kinds of interesting debugging, so we keep gorilla-repl handy for that.

mattexx commented 8 years ago

233