Closed elimisteve closed 2 years ago
Without this change I get errors like compile error: unknown symbol dyn:binpath
in Janet 1.18
FWIW, in the jpm codebase, there are things like (dyn:cflags)
:
https://github.com/janet-lang/jpm/blob/57d18b1f1bace7cc55aed2013eda376511fa68bd/jpm/pm.janet#L46
that come into existence via defdyn
:
There are many calls to defdyn
here:
I think the usages of the form (dyn:*)
in shutil.janet
are intentional.
May be you could share how you were trying to use shutil.janet
?
Ah, I think I see that an ordinary import would lead to that sort of compile error
message.
I don't know if it's a recommended method, but FWIW, the following sort of thing works for me:
$ janet
Janet 1.18.1-66c4e5a5 linux/x64 - '(doc)' for help
repl:1:> (import jpm)
@{_ @{:value <cycle 0>} jpm/cc/archive-c @{:private true} jpm/cc/compile-c @{:private true} jpm/cc/create-buffer-c @{:private true} jpm/cc/create-buffer-c-impl @{:private true} jpm/cc/create-executable @{:private true} jpm/cc/embed-name @{:private true} jpm/cc/entry-name @{:private true} jpm/cc/entry-replace @{:private true} jpm/cc/link-c @{:private true} jpm/cc/make-bin-source @{:private true} jpm/cc/make-define @{:private true} jpm/cc/make-defines @{:private true} jpm/cc/modpath-to-meta @{:private true} jpm/cc/modpath-to-static @{:private true} jpm/cc/out-path @{:private true} jpm/cgen/ir @{:private true} jpm/cgen/mangle @{:private true} jpm/cgen/print-ir @{:private true} jpm/commands/build @{:private true} jpm/commands/clean @{:private true} jpm/commands/deps @{:private true} jpm/commands/enable-local-mode @{:private true} jpm/commands/help @{:private true} jpm/commands/install @{:private true} jpm/commands/jpm-debug-repl @{:private true} jpm/commands/list-installed @{:private true} jpm/commands/list-pkgs @{:private true} jpm/commands/list-rules @{:private true} jpm/commands/quickbin @{:private true} ...}
repl:2:> (jpm/config/load-config jpm/default-config/config false)
nil
repl:3:> (jpm/shutil/is-win)
false
I found the load-config
bits here:
Yeah, this very much should work. Example with latest master:
$ janet
Janet 1.18.1-66c4e5a5 linux/x64 - '(doc)' for help
repl:1:> (import jpm/shutil)
@{_ @{:value <cycle 0>} shutil/abspath @{:private true} shutil/clear-cache @{:private true} shutil/clear-manifest @{:private true} shutil/copy @{:private true} shutil/copyfile @{:private true} shutil/create-dirs @{:private true} shutil/devnull @{:private true} shutil/exec-slurp @{:private true} shutil/filepath-replace @{:private true} shutil/find-cache @{:private true} shutil/find-manifest @{:private true} shutil/find-manifest-dir @{:private true} shutil/is-win @{:private true} shutil/path-splitter @{:private true} shutil/rimraf @{:private true} shutil/rm @{:private true} shutil/shell @{:private true} :macro-lints @[]}
repl:2:>
FWIW, for getting some functionality like shutil/shell
and shutil/exec-slurp
to work, in addition to calling load-config
, I set the :modpath
dynamic variable:
$ janet
Janet 1.18.1-66c4e5a5 linux/x64 - '(doc)' for help
repl:1:> (do (import jpm/config) (import jpm/default-config) (import jpm/shutil) 1)
1
repl:2:> (config/load-config default-config/config false)
nil
repl:3:> (shutil/is-win)
false
repl:4:> (if (= nil (dyn :modpath)) (setdyn :modpath (dyn :syspath)))
"/home/user/.local/lib/janet"
repl:5:> (shutil/shell "echo" "hi")
hi
0
repl:6:> (shutil/exec-slurp "echo" "smile")
"smile"
Okay, I guess I wasn't loading the right config or something :+1: .
As in turning
dyn:*
intodyn :*