Skip to content
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

ER: import from a specified location #130

Open
pkoppstein opened this issue Nov 19, 2021 · 6 comments
Open

ER: import from a specified location #130

pkoppstein opened this issue Nov 19, 2021 · 6 comments

Comments

@pkoppstein
Copy link

pkoppstein commented Nov 19, 2021

Over at wren-lang/wren#346 I see:

munificent commented on Jun 1, 2016
| it's designed to allow the user to load the modules from wherever it needs to, right?
Exactly right.

That does not seem to be true of wren-cli. I think it should be possible to specify an absolute path. Or am I missing something?

Example

$ cd /tmp

$ wren --version
wren 0.4.0

$ cat float.wren
import "/Users/user/github/wren-essentials/src/modules/json" for JSON
var x = JSON.parse("1.24")

$ file /Users/user/github/wren-essentials/src/modules/json.wren
/Users/peter/github/wren-essentials/src/modules/json.wren: C++ source text, ASCII text

$ wren float.wren
Could not load module './Users/peter/github/wren-essentials/src/modules/json'.
[./float line 1] in (script)

Changing the first / in the import to // did not help.

@ruby0x1
Copy link
Member

ruby0x1 commented Nov 19, 2021

you might be looking for https://github.com/joshgoebel/wren-console/ ?

@pkoppstein
Copy link
Author

@ruby0x1 - No, this question has nothing to do with wren-console or JSON. It is about specifying the location of a module in an arbitrary location, as per the "subject". Thanks anyway.

@ruby0x1
Copy link
Member

ruby0x1 commented Nov 20, 2021

Module resolution is handled by the host, so for example how dome handles modules is different to wren cli, and the log you linked mentioned stuff from wren console (specifically wrenc) which implied the resolution question might be host specific. @joshgoebel can check, I haven't read into the issue just yet.

@joshgoebel
Copy link
Contributor

joshgoebel commented Nov 20, 2021

@ruby0x1 I don't know what this is (from the log)... wren-console shows both the host and wren version when asked. (the prior --version output from 0.2.91 was even longer)

% wrenc --version
wrenc v0.3 (with wren v0.4)

My guess was they were using wren-cli renamed to Wren but compiled from source (hence the 0.4, but I didn't look to confirm)?

@pkoppstein wren-essentials contains binary modules (including JSON)... so that's not going to work well with just an import anyways (even if you get the path sorted)... you'll need to build it into your binary CLI (or use wren-console which does that for you).

There is of course the experimental binary module loading support, but as mentioned in the, very experimental.

@joshgoebel
Copy link
Contributor

joshgoebel commented Nov 20, 2021

@pkoppstein I think you'll find wren-cli simply doesn't know how to resolve absolute paths. Only "relative" and simple paths (ie, built-ins)...

Reference:
https://github.com/wren-lang/wren-cli/blob/main/src/cli/vm.c#L135

This is something wren-console supports IIRC (there are several PRs along those lines) - as it's module loading system has been mostly/entirely re-written (in Wren). I'd suggest this issue be renamed to be a feature request asking that wren-cli add absolute path support.

@pkoppstein pkoppstein changed the title import from a specified location ER: import from a specified location Nov 20, 2021
@pkoppstein
Copy link
Author

@joshgoebel - I've added ER to the "subject" as you suggested. I was originally going to do so, but then I came across the munificent quotation at the very top of this thread, so it began to look more like a bug. Thanks.

@ruby0x1 - Sorry for the confusion about wren-console vs wren-cli. I guess you saw my original post via Discord, rather than the revision that I posted almost immediately afterwards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants