Require: namespace mismatch

I've now ended up in this situation twice:

require: namespace mismatch;
 reference to a module that is not instantiated
  module: "/usr/local/racket/share/pkgs/drracket/drracket/private/drracket-errortrace-key.rkt"
  phase: 0

Interactions disabled: racket/base does not support a REPL (no #%top-interaction)

Note this only happens in DrRacket. When I run the same code from the command-line REPL it's OK. There is an old issue (now closed) that describes the same problem.

Yesterday I fussed with this quite a while. I finally had to uninstall Racket, reboot my system, and re-install Racket to get it to go away. Today it's happening again, but in a different file.

It seems to go away if I comment out specific require statements, but I need those statements in the code. Different ones yesterday and today. However the specific DrRacket file (drracket-errortrace-key.rkt) was the same yesterday as it is today.

Anyone have any clues about this?

OK, I got it to go away. I left my original post to describe what I was seeing. Here's what I did:

Added (require racket/logging) before using define-logger.

OK, stupid mistake. Not sure what yesterday's mistake was, I never actually fixed anything AFAIK.

What's going on with that error message (see original post)?

This sounds to me like a bug, either in the code that DrRacket uses to give the nicer error messages or possibly in the code that DrRacket uses to automatically compile the files in your project to .zo files. The error message itself, however, doesn't give enough of a hint for me to see what's actually going wrong so if you do find a way to reproduce it I'd be interested!

PS: you may be able to work around the bug next time it appears by opening the "Language|Choose Language..." dialog, clicking "show details" and either turning off debugging (choose the "No debugging or profiling" radio button) or by unchecking the "Populate compiled directories (for faster loading)" radio button.

I thought maybe I could re-create the condition by removing the (require racket/logging) line. But no, apparently it's not required after all. I had it in two different files. Removed it from both. No clue.

I'm using #lang racket/base if that makes any difference.

$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.2 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.2 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
$ racket --version
Welcome to Racket v8.9 [cs].
Welcome to DrRacket, version 8.9, english by PLT.

Loaded from snap:

$ snap info racket
name:      racket
summary:   Racket Language
publisher: Sam Tobin-Hochstadt (samth)
store-url: https://snapcraft.io/racket
license:   MIT
description: |
  Racket is a general-purpose programming language and an
  ecosystem for language-oriented programming.
commands:
  - racket.drracket
  - racket
  - racket.raco
  - racket.slideshow
snap-id:      NxTKtjBiXwSfqrP5RJSArdVObhzPxuAS
tracking:     latest/stable
refresh-date: yesterday at 21:24 PDT
channels:
  latest/stable:    8.9 2023-05-13 (13) 243MB -
  latest/candidate: ↑                         
  latest/beta:      ↑                         
  latest/edge:      ↑                         
installed:          8.9            (13) 243MB -
$ ls -lR compiled
compiled:
total 4
drwxrwxr-x 3 marc marc 4096 Jun 15 16:19 drracket

compiled/drracket:
total 4
drwxrwxr-x 2 marc marc 4096 Jun 15 16:20 errortrace

compiled/drracket/errortrace:
total 116
-rw-rw-r-- 1 marc marc   493 Jun 15 16:19 display_rkt.dep
-rw-rw-r-- 1 marc marc 51146 Jun 15 16:19 display_rkt.zo
-rw-rw-r-- 1 marc marc   703 Jun 15 16:20 web-display_rkt.dep
-rw-rw-r-- 1 marc marc 55770 Jun 15 16:20 web-display_rkt.zo

I suspect that the error is caused by Racket-level dependency tracking of compiled bytecodes, probably further related to macros. Restart DrRacket after removing **/compiled/drracket/errortrace in the project directory may help.

I've encountered similar namespace mismatch errors for background expansions when creating custom #langs. Unfortunately, I can't reliably reproduce the error either. I think it has to do with the compilation state of the individual bytecode file, the dependency required by each module, and their interaction with errortrace instrumentation.

1 Like