Open
Description
It seems like (current-load-relative-directory)
is unavailable during background expansion and no working REPL loaded, while the code runs and compiles just fine from the command line:
#lang racket
(require (for-syntax syntax/parse/pre
compiler/cm-accomplice))
(define-syntax (require/phantom stx)
(syntax-parse stx
[(_ relpath:string)
(register-external-module (path->complete-path (syntax-e #'relpath)
(current-load-relative-directory)))
#'(begin)]))
(require/phantom "test.rkt")
#|
Welcome to DrRacket, version 8.15.0.12 [cs].
Language: racket, with debugging [custom]; memory limit: 128 MB.
. . ../../racket/gitdev/racket/collects/syntax/wrap-modbeg.rkt:46:4: path->complete-path: contract violation
expected: (and/c (or/c path-string? path-for-some-system?) complete-path?)
given: #f
>
|#
Here, (current-load-relative-directory)
returns #f
in DrRacket but not in Racket REPL:
● [Jan10 20:47:44] $ racket
Welcome to Racket v8.15.0.12 [cs].
> (enter! "phantom-require.rkt")
"phantom-require.rkt">
During compilation, (current-load-relative-directory)
also returns the load path:
● [Jan10 20:47:54] $ raco make -v phantom-require.rkt
"phantom-require.rkt":
making #<path:....../phantom-require.rkt>
[output to "compiled/phantom-require_rkt.zo"]
● [Jan10 20:48:04] $ raco make -v phantom-require.rkt
"phantom-require.rkt":
making #<path:....../test.rkt>
test.rkt:(syntax-local-phase-level 0)
making #<path:....../phantom-require.rkt>
[output to "compiled/phantom-require_rkt.zo"]
● [Jan10 20:48:06] $