Rust Project Euler Error

Everytime I click the Run Tests button it seems to die with the following error:

Restarting using npm run dev:curriculum && npm run start doesn’t seem to help either.

Any ideas?

Listening on port 8080
node:fs:1392
  handleErrorFromBinding(ctx);
  ^

'project-euler no such file or directory, scandir './tooling/locales/english
    at Object.readdirSync (node:fs:1392:3)
    at getLessonFromDirectory (/home/camper/curriculum/.freeCodeCamp/tooling/parser.js:30:6)
    at runLesson (/home/camper/curriculum/.freeCodeCamp/tooling/lesson.js:14:18)
    at handleConnect (/home/camper/curriculum/.freeCodeCamp/tooling/server.js:40:3)
    at Object.connect (/home/camper/curriculum/.freeCodeCamp/tooling/server.js:49:5)
    at WebSocket.message (/home/camper/curriculum/.freeCodeCamp/tooling/server.js:62:31)
    at WebSocket.emit (node:events:526:28)
    at Receiver.receiverOnMessage (/home/camper/curriculum/.freeCodeCamp/node_modules/ws/lib/websocket.js:1137:20)
    at Receiver.emit (node:events:526:28)
    at Receiver.dataMessage (/home/camper/curriculum/.freeCodeCamp/node_modules/ws/lib/receiver.js:528:14) {
  errno: -2,
  syscall: 'scandir',
  code: 'ENOENT',
  path: './tooling/locales/english\r/project-euler\r'
}

Welcome there,

Where are you running npm run dev:curriculum from?

from the terminal inside the Docker container image … do you mean the actual path or were you asking about the dev environment?

I mean the path.

I suppose it would be best, if you could provide a rundown of the steps you took to get where you are.

Sorry, I should have just done it like this to begin with …

Prerequisites

Expected Behavior

Clicking Run Tests would run tests

Current Behavior

Clicking Run Tests doesn’t do anything - produces error in console output

Failure Information

node:fs:1392
  handleErrorFromBinding(ctx);
  ^

'project-euler no such file or directory, scandir './tooling/locales/english
    at Object.readdirSync (node:fs:1392:3)
    at getLessonFromDirectory (/home/camper/curriculum/.freeCodeCamp/tooling/parser.js:30:6)
    at runLesson (/home/camper/curriculum/.freeCodeCamp/tooling/lesson.js:14:18)
    at handleConnect (/home/camper/curriculum/.freeCodeCamp/tooling/server.js:40:3)
    at Object.connect (/home/camper/curriculum/.freeCodeCamp/tooling/server.js:49:5)
    at WebSocket.message (/home/camper/curriculum/.freeCodeCamp/tooling/server.js:62:31)
    at WebSocket.emit (node:events:526:28)
    at Receiver.receiverOnMessage (/home/camper/curriculum/.freeCodeCamp/node_modules/ws/lib/websocket.js:1137:20)
    at Receiver.emit (node:events:526:28)
    at Receiver.dataMessage (/home/camper/curriculum/.freeCodeCamp/node_modules/ws/lib/receiver.js:528:14) {
  errno: -2,
  syscall: 'scandir',
  code: 'ENOENT',
  path: './tooling/locales/english\r/project-euler\r'
}

Steps to Reproduce

  1. Install VSCode plugins and bring up Project Euler docker container
  2. Modify src/lib.rs
  3. Build project via npm run build
  4. Click Run Tests in browser window (preview or separate)

Environment

  • Host OS: Windows 11 (x64)
  • Applications: VS Code (w/plugins), Docker

Failure Logs

  • See above for error output
  • npm run dev:curriculum && npm run start doesn’t resolve the issue
    • path:
      root@e067846eeaae:/home/camper/curriculum/.freeCodeCamp#

Thank you, for all the information.

So we are on the same page, are you using the freeCodeCamp Courses VSCode extension or not?

If not, I do notice a slight typo in one of the commands in my article.

Instead of cd .freeCodeCamp && sample.env .env && npm run dev:curriculum && npm run start

It should be:

cd .freeCodeCamp && cp sample.env .env && npm run dev:curriculum && npm run start

I have adjusted it, but will take a while to reflect in the production article.


Otherwise, can you share the contents of the .freeCodeCamp/.env file?

No problem.

Yes, I’m using the freeCodeCamp VSCode extension.

Here are the contents of the .env file:

root@e067846eeaae:/home/camper/curriculum/.freeCodeCamp# cat .env
TEST_POLLING_RATE=100
CURRENT_PROJECT=project-euler
LOCALE=english
CURRENT_LESSON=1
LAST_KNOWN_LESSON_WITH_HASH=1
RUN_TESTS_ON_WATCH=false
USE_GIT_BUILD_ON_PRODUCTION=false
SEED_EVERY_LESSON=false

Let me know if there’s anything more you need me to provide. Thanks again for being so responsive. :slight_smile:

If you are using the extension, then you should not be running npm run dev:curriculum or npm run start

All you should need to do is:
a) freeCodeCamp Courses: Start
b) npm run build in the terminal, when you are wanting to build you Rust code to test.

Yeah, I’m not sure -

Steps:

  1. <ctrl> + <shift> + <p> - select freeCodeCamp: Run Course
  2. npm run build (see output below - seems like the WASM was built correctly)
  3. ??? <— it’s quite possible I’m missing something
root@e067846eeaae:/home/camper/curriculum# npm run build

> curriculum@1.0.0 build
> wasm-pack build && npm run webpack-build

[INFO]: Checking for the Wasm target...
[INFO]: Compiling to Wasm...
    Finished release [optimized] target(s) in 0.00s
[INFO]: Installing wasm-bindgen...
[INFO]: Optimizing wasm binaries with `wasm-opt`...
[INFO]: Optional fields missing from Cargo.toml: 'description', 'repository', and 'license'. These are not necessary, but recommended
[INFO]: :-) Done in 0.32s
[INFO]: :-) Your wasm pkg is ready to publish at /home/camper/curriculum/pkg.

> curriculum@1.0.0 webpack-build
> webpack --config webpack.config.js

assets by status 13.1 KiB [cached] 1 asset
asset bundle.js 9.25 KiB [compared for emit] (name: main)
runtime modules 3.76 KiB 6 modules
cacheable modules 243 bytes (javascript) 13.1 KiB (webassembly)
  ./pkg/curriculum_bg.js 193 bytes [built] [code generated]
  ./pkg/curriculum_bg.wasm 50 bytes (javascript) 13.1 KiB (webassembly) [built] [code generated]
webpack 5.72.0 compiled successfully in 96 ms

source (please don’t judge - still learning):

use wasm_bindgen::prelude::*;

// // Example format to write functions:
// #[wasm_bindgen(js_name = camelCaseName)] // js_name must equal function name tested on client
// pub fn snake_case_name(num: i32) -> i32 { // Function must be public
//     // All numbers in JS are 32-bit
//     num
// }

// First function written for you - you still need to add the logic :)
#[wasm_bindgen(js_name = multiplesOf3and5)]
pub fn multiples_of_3_and_5(n: i32) -> i32 {
    let mut acc_3  = vec![];
    let mut acc_5  = vec![];
    let mut acc_15 = vec![];

    for num in 1..n {
        if num % 3 == 0 && num % 5 == 0 {
            acc_15.push(num);
        } else if num % 3 == 0 {
            acc_3.push(num);
        } else if num % 5 == 0 {
            acc_5.push(num);
        }
    }

    acc_3.iter().sum::<i32>() + 
    acc_5.iter().sum::<i32>() + 
    acc_15.iter().sum::<i32>()
}

Not sure if it helps or not, but here is what inspect on the page says on button click:

DevTools failed to load source map: Could not load content for http://localhost:8080/requestProvider.js.map: Load canceled due to load timeout
index.js:97 WebSocket is already in CLOSING or CLOSED state.
sock @ index.js:97
runTests @ index.js:28
onclick @ (index):44

Maybe whatever that error says is killing the server listening on 8080 and closing the socket.

I am not able to see anything that stands out as being a problem.

My best suggestion at the moment is to rebuild another container - delete the first container, and/or ensure to use Remote-Containers: Rebuild Container without Cache (not necessarily exact - I am doing this from memory)

Otherwise, I suggest you try one of the other methods to run the course.

No change after rebuilding another container. I’ll give one of the other methods a shot. Thanks!