benwbooth / quick-clojure

Run clojure scripts and lein commands quickly using a persistent nREPL session
Eclipse Public License 1.0
47 stars 4 forks source link

namespace-not-found #1

Closed hillman closed 10 years ago

hillman commented 10 years ago

Hi,

Really like the project, sounds promising. I've just tried it on a fairly simple 'hello world' project and I'm getting an error though. "lein run" works, but "quick lein run" gives this:

Traceback (most recent call last): File "/usr/local/bin/quick", line 267, in elif len(sys.argv) > 1 and sys.argv[1] == 'lein': exit_code = lein(*sys.argv[2:]) File "/usr/local/bin/quick", line 250, in lein result = evaluate(code, ns='leiningen.core.main') File "/usr/local/bin/quick", line 173, in evaluate raise Exception('Eval returned bad exit status: %s' % (message['status'][0])) Exception: Eval returned bad exit status: namespace-not-found

Am I doing something stupid?

Thanks,

Jamie

benwbooth commented 10 years ago

No, it's probably a bug. I'll try to fix it later today. Thanks!

benwbooth commented 10 years ago

I'm having trouble reproducing this error. Here is what I tried:

$ lein new app hello
$ cd hello
$ lein run
Hello, World!
$ quick lein run
Hello, World!

Is there any way you can provide some steps to reproduce what you're seeing?

hillman commented 10 years ago

Weird, maybe it's specific to a particular version of Lein? I just tried the same thing on a completely different PC - the exact steps you've given above and it produces the same namespace error. Lein 2.3.4 on Linux.

benwbooth commented 10 years ago

OK, I was able to reproduce the bug on my ArchLinux system. The weird thing is, grenchman exhibits the same bug. Which is unfortunate, as I was hoping to use grenchman to figure out what I was doing wrong :(

This only seems to affect leiningen when used in project mode. Using quick in global leiningen mode handles lein commands just fine. The only thing I can think of is that the project-mode REPL doesn't require the leiningen.core.main namespace by default. But when I tried adding a (require ...) line to my script, it didn't seem to help. I'm going to have to do some more messing around to figure out why this isn't working.

benwbooth commented 10 years ago

What I've managed to discover is that grenchman simply does not support connecting to project-local nREPL sessions. quick-clojure supports this, but trying to run a lein command in an project-local REPL session will fail. A workaround is to start a global nREPL session, by running quick start in your home directory top folder. Then cd into your project folder, and type quick lein run and it works.

benwbooth commented 10 years ago

OK, I think I have this figured out now. Any lein commands have to be run in the top-level nREPL instance, otherwise the leiningen modules won't be loaded. If you try to run a lein command in a project-level nREPL session, it won't find the leiningen libs (unless you put them in your project.clj as dependencies). So I've modified the quick script to always use a top-level nREPL session for leiningen commands. Hopefully this should fix the problem.

benwbooth commented 10 years ago

I just uploaded v0.9 to PyPI, which should fix this problem by always running leiningen commands in a top-level REPL session.

hillman commented 10 years ago

Great, thanks very much!