# Using Command in Rust

**URL:** <https://forum.codecrafters.io/t/using-command-in-rust/4520>\
**Category:** Challenges\
**Tags:** challenge:shell\
**Created:** [January 28, 2025, 3:07pm UTC](https://forum.codecrafters.io/t/using-command-in-rust/4520 "2025-01-28T15:07:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![milongo](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/milongo/32/4297_2.png) [@milongo](https://forum.codecrafters.io/u/milongo)\
**Post date:** [January 28, 2025, 3:07pm UTC](https://forum.codecrafters.io/t/using-command-in-rust/4520/1 "2025-01-28T15:07:26Z")

</div>

I’m stuck on Stage #ei0.

I implemented the earlier stages and in stage IP1 I used a rust Command. I think this may be “cheating” kind of since I can pass anything to the shell now and the Command will process it. See my code below.  
The weird thing is that I can’t pass stage ei0 even though locally I get the behaviour as explained by the instructions.

Here are my logs:

```auto
remote: Running tests on your code. Logs should appear shortly...
remote: 
remote: [compile] Compiling codecrafters-shell v0.1.0 (/app)
remote: [compile] Finished `release` profile [optimized] target(s) in 1.21s
remote: [compile] Moved ./.codecrafters/run.sh → ./your_program.sh
remote: [compile] Compilation successful.
remote: 
remote: Debug = true
remote: 
remote: [tester::#EI0] Running tests for Stage #EI0 (Navigation - The pwd builtin)
remote: [tester::#EI0] Running ./your_program.sh
remote: [your-program] $ type pwd
remote: [your-program] pwd is a shell builtin
remote: [tester::#EI0] ✓ Received expected response
remote: [your-program] $ pwd
[your-program] pwd: command not found: No such file or directory (os error 2)
remote: [tester::#EI0] Output does not match expected value.
remote: [tester::#EI0] Expected: "/app"
remote: [tester::#EI0] Received: "pwd: command not found"
remote: [your-program] $ 
remote: [tester::#EI0] Assertion failed.
remote: [tester::#EI0] Test failed
remote: 
remote: Try our CLI to run tests faster without Git: https://codecrafters.io/cli
remote: 
remote: View our article on debugging test failures: https://codecrafters.io/debug
remote:

```

And here’s a snippet of my code:  
The full link is [here](https://github.com/milongo/codecrafters-shell-rust/blob/master/src/main.rs)

```rust
_ => {
                let output = Command::new(command).args(args).output();

                match output {
                    Ok(output) => {
                        if !output.stdout.is_empty() {
                            print!("{}", String::from_utf8_lossy(&output.stdout));
                        }
                        if !output.stderr.is_empty() {
                            eprint!("{}", String::from_utf8_lossy(&output.stderr));
                        }
                    }
                    Err(_err) => println!("{}: command not found: {}", command, _err.to_string()),
                }
            }

```

Here’s my output:

```auto
vscode ➜ /workspaces/codecrafters-shell-rust (master) $ ./your_program.sh 
    Finished `release` profile [optimized] target(s) in 0.02s
$ pwd
/workspaces/codecrafters-shell-rust
$ type pwd
pwd is a shell builtin

```

Any ideas? Thanks!

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [January 28, 2025, 3:07pm UTC](https://forum.codecrafters.io/t/using-command-in-rust/4520/2 "2025-01-28T15:07:27Z")

</div>

Hi, thanks for your post!

I’m currently out of the office and will return on Feb 3. I’ll get back to you as soon as possible after I’m back.

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [July 8, 2025, 4:56pm UTC](https://forum.codecrafters.io/t/using-command-in-rust/4520/4 "2025-07-08T16:56:46Z")

</div>

Sorry for the delayed response! Looks like you’ve got past this stage. 🎉

Do you happen to remember what was wrong? Would love to see if we can improve the tester / instructions.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/7/0/700657133935c15703e22c7c8870394f6e6dc27d.svg) [@system](https://forum.codecrafters.io/u/system)\
**Post date:** [July 18, 2025, 4:07pm UTC](https://forum.codecrafters.io/t/using-command-in-rust/4520/6 "2025-07-18T16:07:46Z")

</div>

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.
