I’m stuck on Stage #IP1.
I’ve tried to follow working code examples, chatting with ChatGPT and Co-Pilot but i just cant seam to find the problem that is causing this error.
Here are my logs:
[compile] Determining projects to restore...
[compile] All projects are up-to-date for restore.
[compile] codecrafters-shell -> /tmp/codecrafters-build-csharp/codecrafters-shell.dll
[compile]
[compile] Build succeeded.
[compile] 0 Warning(s)
[compile] 0 Error(s)
[compile]
[compile] Time Elapsed 00:00:04.23
[compile] Moved ./.codecrafters/run.sh → ./your_program.sh
[compile] Compilation successful.
[tester::#IP1] Running tests for Stage #IP1 (Run a program)
[tester::#IP1] [setup] export PATH=/tmp/quz:$PATH
[tester::#IP1] [setup] Available executables:
[tester::#IP1] [setup] - custom_exe_3579
[tester::#IP1] Running ./your_program.sh
[your-program] $ custom_exe_3579 Emily
[your-program] $ Program was passed 2 args (including program name).
[tester::#IP1] Output does not match expected value.
[tester::#IP1] Expected: "Program was passed 2 args (including program name)."
[tester::#IP1] Received: "$ Program was passed 2 args (including program name)."
[your-program] Arg #0 (program name): /tmp/quz/custom_exe_3579
[your-program] Arg #1: Emily
[your-program] Program Signature: 8866694463
[tester::#IP1] Assertion failed.
[tester::#IP1] Test failed (try setting 'debug: true' in your codecrafters.yml to see more details)
And here’s a snippet of my code:
_paths = Environment.GetEnvironmentVariable("PATH")?.Split(':') ?? [];
private static void Repl()
{
Console.Write("$ ");
var userInput = Console.ReadLine();
RunCommand(userInput);
}
private static void RunCommand(string? userInput)
{
if (string.IsNullOrEmpty(userInput))
{
return;
}
var command = userInput.Split(' ');
var builtin = command[0];
if (builtin == "exit")
Exit(command);
else if (builtin == "echo")
Echo(command);
else if (builtin == "type")
Type(command);
else if (ExecutableInPath(builtin, out var location))
Process.Start(location, string.Join(' ', command[1..]));
else
Console.WriteLine($"{userInput}: command not found");
}
private static bool ExecutableInPath(string arguments, out string location)
{
location = string.Empty;
foreach (var path in _paths)
{
var fullPath = Path.Combine(path, arguments);
if (File.Exists(fullPath))
{
location = fullPath;
return true;
}
}
return false;
}
If my code snippets isnt sufficient enough I will provide this link to my GitHub.
Any help is greatly appreciated
Best Regards,
A fella programmer!