Ah, now I know what is going on. You are using `dump-scsh-program'
(or, equivalently ,build) to write the image, while I was using
,dump. The difference is that ,dump automatically includes the
command interpreter while `dump-scsh-program' does not. Both
,user-package-is and `get-package' depend on the command interpreter.
The following works because it bypasses the command interpreter
by using the lower-level procedure `with-interaction-environment'.
% ./scshvm -i scsh/scsh.image
> ,open environments package-commands-internal
> ,config (define-structure test (export)
(begin (define bar 10)))
> (let ((env (get-package 'test)))
(load "test.scm")))) ; prints out the value of `bar'
Load structure test (y/n)? y
% ./scshvm -i test.image
bar = 10
I will track down the code responsible for the original
(record-ref #f 3)
message and have it produce somthing more perspicacious.