Closed pmatos closed 4 years ago
I just tried it on my mac and I get the same error:
~/s/racket-loci (pmatos-macos-test)> racket test/test_locus-context.rkt 4
Starting core 0
standard-module-name-resolver: collection not found
for module path: (submod (lib "racket/init") configure-runtime)
collection: "racket"
in collection directories:
/Users/bogdan/Library/Racket/7.6/collects
/usr/local/collects
... [35 additional linked and package directories]
context...:
show-collection-err
standard-module-name-resolver
module-path-index-resolve
module-declared?
#%top-interaction: unbound identifier;
also, no #%app syntax transformer is bound
at: #%top-interaction
in: (#%top-interaction eval (read))
context...:
do-raise-syntax-error
expand-capturing-lifts
temp98_0
temp71_0
compile
temp65_0
^Cuser break
context...:
/Applications/Racket v7.6/share/pkgs/unix-socket-lib/racket/unix-socket.rkt:263:0: unix-socket-accept
/Applications/Racket v7.6/collects/racket/contract/private/arrow-val-first.rkt:486:18
/Users/bogdan/sandbox/racket-loci/loci/private/locus-local.rkt:99:0: dynamic-locus
/Users/bogdan/sandbox/racket-loci/test/test_locus-context.rkt:8:0: go
/Applications/Racket v7.6/collects/racket/private/more-scheme.rkt:336:52
(submod "/Users/bogdan/sandbox/racket-loci/test/test_locus-context.rkt" main): [running body]
temp35_0
for-loop
run-module-instance!
I can try to dig in a little deeper later.
Oh, I see what's going on.
(define (current-executable-path)
(parameterize ([current-directory (find-system-path 'orig-dir)])
(find-executable-path (find-system-path 'exec-file) #false)))
(define (current-collects-path)
(define p (find-system-path 'collects-dir))
(if (complete-path? p)
p
(path->complete-path p (or (path-only (current-executable-path))
(find-system-path 'orig-dir)))))
for me this resolves to
locus-local.rkt> (current-collects-path)
#<path:/usr/local/bin/../collects>
because
locus-local.rkt> (current-executable-path)
#<path:/usr/local/bin/racket>
but that's wrong because /usr/local/bin/racket
is just a symlink of the real executable in /Applications
~/s/racket-loci (pmatos-macos-test)> ls -l (which racket)
lrwxr-xr-x 1 bogdan admin 36 Feb 14 11:33 /usr/local/bin/racket@ -> /Applications/Racket v7.6/bin/racket
so the collects path it guesses is wrong.
The docs mention this problem:
'collects-dir — a path to the main collection of libraries (see Libraries and Collections). If this path is relative, then it is relative to the executable as reported by (find-system-path 'exec-file)—though the latter could be a soft-link or relative to the user’s executable search path, so that the two results should be combined with find-executable-path. The 'collects-dir path is normally embedded in the Racket executable, but it can be overridden by the --collects or -X command-line flag.
So it seems like you either need to follow the link before resolving the collection path of drop the -X
parameter in
(define worker-cmdline-list (list (current-executable-path)
;; "-X"
;; (path->string (current-collects-path))
"-e"
"(eval (read))"))
If I do that, this test passes:
~/s/racket-loci (pmatos-macos-test) [1]> racket test/test_locus-context.rkt 4
Starting core 0
(/usr/local/bin/racket -e (eval (read)))
Starting core 1
(/usr/local/bin/racket -e (eval (read)))
Starting core 2
(/usr/local/bin/racket -e (eval (read)))
Starting core 3
(/usr/local/bin/racket -e (eval (read)))
Locus 0 done
0
Locus 1 done
1
Locus 2 done
2
Locus 3 done
3
cpu time: 21 real time: 20835 gc time: 0
'(0 0 0 0)
This patch fixes the problem:
From 1e7467dfb12acc76729560fe74f1eda2fbc2bc68 Mon Sep 17 00:00:00 2001
From: Bogdan Popa <bogdan@defn.io>
Date: Fri, 17 Apr 2020 11:07:24 +0300
Subject: [PATCH] locus-local: follow links when building collects paths
---
loci/private/locus-local.rkt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/loci/private/locus-local.rkt b/loci/private/locus-local.rkt
index 75bdc19..67e9784 100644
--- a/loci/private/locus-local.rkt
+++ b/loci/private/locus-local.rkt
@@ -104,8 +104,8 @@
(define p (find-system-path 'collects-dir))
(if (complete-path? p)
p
- (path->complete-path p (or (path-only (current-executable-path))
- (find-system-path 'orig-dir)))))
+ (path->complete-path p (or (path-only (resolve-path (current-executable-path)))
+ (find-system-path 'orig-dir)))))
(define worker-cmdline-list (list (current-executable-path)
"-X"
(path->string (current-collects-path))
--
2.25.1
It worked! Great. Thanks.
(Possibly related to #4)
I am seeing an error when trying to test one of my libraries using github actions. Do you own a mac for testing by any chance. https://github.com/pmatos/racket-loci/pull/4/checks?check_run_id=592076853#step:5:10
Thanks.