-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
REPL: script directory-relative requires fail with 'cannot find module' #1035
Comments
Looks like this worked under 0.9.4 but hasn't worked since 0.9.5. I'm trying |
[Edit: As satyr points out below, this post actually provides a fix to a different bug, not the REPL one.] Found it. Ah, I'm a little embarrassed—it looks like I introduced this bug (when fixing
to
which is an awfully inelegant way of saying "Let's not run |
Right on, thanks Trevor! |
This is from |
Ah, quite right satyr—what I posted does fix a bug, but it's a different bug! Try this:
On the current master, that gives you an error ("Cannot find module './hi'"); change the line I suggested, and it runs fine. Still investigating the REPL bug (which, it seems, has been around forever)... |
So here's the problem: When you run input in the REPL, it goes into this function:
If it weren't for these That's great—but, of course, these lines really just create new variables named In the meantime, nolanw, here's a workaround:
|
Trevor, that works great. As a next step I'm trying to make
Neither of which seem to run This isn't all that surprising, as I suppose the And that's all good, in which case I ask: is there a way to make |
Good point, nolanw—it looks like there's no way to do that now. I might raise that as a separate issue... I got an answer on the Node mailing list, and it turns out there's a pretty easy fix to the original bug: I've combined this and the other fix mentioned above as a patch here. (Interestingly, a comment in command.coffee alludes to this—"If evaluating the script directly sets |
I've posted a pull request as issue 1045 for the other issue you pointed out, nolanw. If that patch is merged into master, it'll be possible to require
|
Very cool Trevor, you're a star! |
Thanks, Trevor, well done ... I've merged in your branches here: |
I previously deleted my comment to allow myself time to read through this issue list. It seems that this has been fixed before, but I'm experiencing the same exact issue in version 1.1.1, so I don't really know what the deal is. I'll provide any additional information you guys may need. |
Re-opening because @blaenk claims this issue has regressed. |
I'm new to both CoffeeScript and Node, but I'm having the same issue with 1.1.1/0.4.6. I don't know if this will help, but the coffee REPL doesn't seem to know about module.paths. Is this just a by-product of the problem, or could it indicate a cause?
Whereas node REPL seems to know what's going on:
If I write a little .coffee script, it knows about node_modules. paths.coffee
When I run paths.coffee, I get the correct module.paths:
|
If you look at the last commit that fixed this: 7815138 You will see that the variables have changed since then, I don't know if that was to mirror changes in the node.js architecture, but I imagine the problem stems from those changes. |
Having this issue myself - #1485 |
Sorry for not looking at this sooner. The REPL went through some major changes for 1.1.0 (mostly for the better—thanks Michael), but a few things broke along the way. Here's what went wrong: When you call
to the sandbox = The sandbox's The solution: Use a real |
@TrevorBurnham: wow, I've been having some serious coincidences today. I was actually just working on a fix for this issue and coming up with virtually the same solution. I'll take a look at your pull request right now. |
Ah, sorry for the duplicated effort! Pull request posted at #1487. |
Fixed by fff4c9c |
Looks good -- with @satyr's revisions. Following the Node REPL's example is always progress. |
…verhaul of REPL and CoffeeScript.eval. Instead of writing about all the changes and why I made those decisions, I'll just answer any questions in the commit comments, so add a commit comment if you want to question anything. Thanks to @TrevorBurnham and @satyr for their help/contributions. Also, closes jashkenas#1487. And still no REPL tests...
so.. when will it be released? im still having this problem on 1.1.1/0.4.9 |
@vitaly: As soon as @jashkenas packages and tags 1.1.2 (and who knows when that will be at this point). You can just clone |
If I have
hi.coffee
in the current directory, I can't userequire './hi'
in CoffeeScript's REPL to load it. However, it works with node's REPL. For example:The text was updated successfully, but these errors were encountered: