Error from course-sdk-js-tools while attempting to add/test a language to BYO HTTP Server

I’m attempting to add Swift to the BYO HTTP Server challenge. I have read through the contributor guidelines, created a language folder in starter_templates, and added a docker file to dockerfiles. I ran the course-sdk test swift– everything looked pretty good and it started running tests on the app built by my code. I fixed some minor problems with my source code and tried to test again, but now I get an error I don’t know how to diagnose. It seems to be from the course-sdk-js-tools container.

What do I need to fix? I don’t know what file it wants that doesn’t exist. Thanks for your time - any help with this is most appreciated.


Edited to add text version of the error:

[docker-build] View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/8ccjevzdqw5movm2o0b5jkvf2

js-tools Docker image built.

Compiling language: swift...
17156 |     return course3.languages.map((language8) => {
17157 |       const globalFileDefinitions = glob2.sync(`${course3.globalStarterTemplatesDir}/**/*`, { dot: true }).filter((starterTemplateFilePath) => fs11.statSync(starterTemplateFilePath).isFile()).map((starterTemplateFilePath) => {
17158 |         const destinationPath = path12.relative(course3.globalStarterTemplatesDir, starterTemplateFilePath);
17159 |         return new SingleTemplateFileDefinition(destinationPath, path12.relative(course3.directory, starterTemplateFilePath));
17160 |       });
17161 |       const languageFileDefinitions = glob2.sync(`${starterTemplatesDir}/**/*`, { dot: true }).filter((starterTemplateFilePath) => fs11.statSync(starterTemplateFilePath).isFile()).map((starterTemplateFilePath) => {
                                                                                                                                                        ^
ENOENT: No such file or directory
   errno: -2
 syscall: "stat"

      at /$bunfs/root/main.out:17161:145
      at filter (:1:11)
      at /$bunfs/root/main.out:17161:102
      at map (:1:11)
      at definitions (/$bunfs/root/main.out:17461:67)
      at /$bunfs/root/main.out:17426:28
      at compileForLanguage (/$bunfs/root/main.out:17425:30)
      at /$bunfs/root/main.out:17514:44

Bun v1.1.17 (macOS x64)

@ShonFrazier I’ve been trying to replicate this but haven’t been able to yet. For context, the error occurs here:

That’s supposed to be listing all items under starter_templates/swift and then running stat on them. I’m sure there’s a simpler explanation here, but according to the code, the only expected case for this to fail would be if a file existed during glob and was deleted before fs.statSync ran, which seem… highly unlikely :thinking:

@ShonFrazier some questions that could help narrow this down:

(a) Is this error persistent?
(b) Could you try adding a console.log to the line, re-compiling course-sdk and seeing what you get? i.e. apply this diff:

Thanks for looking into this!

Question a): It is persistent. Cleaning and re-running the process results in the same error. I started from scratch on another Mac and got the same result.

Question b):

  • the last file logged before the error is .../build-your-own-http-server/starter_templates/swift/code/.build/x86_64-apple-macosx/debug/swift-nio_NIOPosix.bundle/PrivacyInfo.xcprivacy
  • that file is lrwxr-xr-x 1 shon staff 28B Jul 21 22:11 .../build-your-own-http-server/starter_templates/swift/code/.build/x86_64-apple-macosx/debug/swift-nio_NIOPosix.bundle/PrivacyInfo.xcprivacy@ -> ../../.PrivacyInfo.xcprivacy
  • the file that the link points to is non-existent:

I assume this file isn’t actually generated, but the link to it is. I’ll have to dig some more to know for certain.

EDIT: forgot the -a when I did the ls command for the screenshot, but it only adds . and ... The file .PrivacyInfo.xcprivacy is not there.

Giving this a bit more thought, it might be the difference between lstat on Linux, and stat on macOS (instructions say to link lstat to stat.) I can see about running this all on a Linux VM or container.

On Linux, this error does not occur. But then it looks like there are some fragile string searches in the tests. First:

and if I comment out that assertion:

This problem was with Docker itself. The version installed by apt did not include buildx. Installing Docker with instructions from the Docker website solved it.

1 Like

@ShonFrazier so the missing file error doesn’t happen now?

Think I’ve found the error! This happened to me locally when trying to add OCaml support, and it was because the file was a broken symlink. Working on a fix…

Fixed here! Fix error with broken symlinks + add OCaml support by rohitpaulk · Pull Request #35 · codecrafters-io/course-sdk · GitHub