# (Kotlin) "Build your own shell" -Stage #RA6 Output does not match expected value

**URL:** <https://forum.codecrafters.io/t/kotlin-build-your-own-shell-stage-ra6-output-does-not-match-expected-value/3516>\
**Category:** Bug Reports\
**Tags:** challenge:shell\
**Created:** [December 17, 2024, 7:29pm UTC](https://forum.codecrafters.io/t/kotlin-build-your-own-shell-stage-ra6-output-does-not-match-expected-value/3516 "2024-12-17T19:29:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![DanielUH2019](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/danieluh2019/32/3553_2.png) [@DanielUH2019](https://forum.codecrafters.io/u/DanielUH2019)\
**Post date:** [December 17, 2024, 7:29pm UTC](https://forum.codecrafters.io/t/kotlin-build-your-own-shell-stage-ra6-output-does-not-match-expected-value/3516/1 "2024-12-17T19:29:03Z")

</div>

I’m stuck on Stage #RA6.

I’ve tried to reproduce what the tester says manually running my program but I haven’t had any luck.

Here are my logs:

```auto
[tester::#RA6] Running tests for Stage #RA6 (Navigation - The cd builtin: Absolute paths)
[tester::#RA6] Running ./your_program.sh
[your-program] $ cd /tmp/apple/strawberry/mango
[tester::#RA6] Output does not match expected value.
[tester::#RA6] Expected: "$ pwd"
[tester::#RA6] Received: "pwd"
[your-program] pwd
[your-program] $ /tmp/apple/strawberry/mango
[your-program] $ 
[tester::#RA6] Assertion failed.
[tester::#RA6] Test failed

```

And here’s a snippet of my code:

```kotlin
fun main() {
    val shellState = ShellState(
        currentDirectory = File(System.getProperty("user.dir")).canonicalFile,
        environmentVariables = mutableMapOf(
            EnvVar.PATH to (System.getenv("PATH") ?: ""),
            EnvVar.HOME to (System.getProperty("user.home") ?: "/")
        )
    )

    do {
        print("$ ")
        val userInput = readln()
        val splitUserInput = userInput.split(" ")
        val command = splitUserInput[0]
        val args = if (splitUserInput.size > 1) splitUserInput.subList(1, splitUserInput.size) else emptyList()

        val builtin = BuiltinCommand.fromCommand(command)
        if (builtin != null) {
            handleBuiltinCommand(builtin, args, shellState)
        } else {
            executeExternalCommand(command, args, shellState)
        }
    } while (true)
}

fun changeDirectory(shellState: ShellState, newPath: String) {
    val targetDirectory = if (newPath.startsWith("/")) {
        File(newPath)
    } else {
        File(shellState.currentDirectory, newPath)
    }

    if (targetDirectory.exists() && targetDirectory.isDirectory) {
        shellState.currentDirectory = targetDirectory.canonicalFile
    } else {
        println("cd: $newPath: No such file or directory: $newPath")
    }
}

```

---

<div class="post-metadata">

**Author:** ![DanielUH2019](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/danieluh2019/32/3553_2.png) [@DanielUH2019](https://forum.codecrafters.io/u/DanielUH2019)\
**Post date:** [December 17, 2024, 7:29pm UTC](https://forum.codecrafters.io/t/kotlin-build-your-own-shell-stage-ra6-output-does-not-match-expected-value/3516/2 "2024-12-17T19:29:41Z")

</div>

link to my code: [GitHub - DanielUH2019/codecrafters-shell-kotlin](https://github.com/DanielUH2019/codecrafters-shell-kotlin)

---

<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:** [December 17, 2024, 8:33pm UTC](https://forum.codecrafters.io/t/kotlin-build-your-own-shell-stage-ra6-output-does-not-match-expected-value/3516/3 "2024-12-17T20:33:15Z")

</div>

Thanks for sharing your code! I’ll take a look and get back to you by the end of the week.

---

<div class="post-metadata">

**Author:** ![jaikherajani](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/jaikherajani/32/3554_2.png) [@jaikherajani](https://forum.codecrafters.io/u/jaikherajani)\
**Post date:** [December 17, 2024, 8:45pm UTC](https://forum.codecrafters.io/t/kotlin-build-your-own-shell-stage-ra6-output-does-not-match-expected-value/3516/5 "2024-12-17T20:45:52Z")

</div>

Hi,  
I am also stuck at this point, with same error. My code is in java. Can someone please help me as well?

```auto
[tester::#RA6] Running tests for Stage #RA6 (Navigation - The cd builtin: Absolute paths)
[tester::#RA6] Running ./your_program.sh
[your-program] $ cd /tmp/apple/apple/banana
[tester::#RA6] Output does not match expected value.
[tester::#RA6] Expected: "$ pwd"
[tester::#RA6] Received: "pwd"
[your-program] pwd
[your-program] $ 
[tester::#RA6] Assertion failed.
[tester::#RA6] Test failed

```

Thanks.

> **[GitHub - jaikherajani/codecrafters-shell-java](https://github.com/jaikherajani/codecrafters-shell-java)**
>
> Contribute to jaikherajani/codecrafters-shell-java development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![noam-no](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/noam-no/32/3558_2.png) [@noam-no](https://forum.codecrafters.io/u/noam-no)\
**Post date:** [December 17, 2024, 11:57pm UTC](https://forum.codecrafters.io/t/kotlin-build-your-own-shell-stage-ra6-output-does-not-match-expected-value/3516/6 "2024-12-17T23:57:19Z")

</div>

Same here, there must be a problem in the test it should expect `pwd` not `$ pwd` probably a bad copy-paste they did on their end.

---

<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:** [December 22, 2024, 3:09pm UTC](https://forum.codecrafters.io/t/kotlin-build-your-own-shell-stage-ra6-output-does-not-match-expected-value/3516/7 "2024-12-22T15:09:43Z")

</div>

We fixed the issue in [this PR](https://github.com/codecrafters-io/shell-tester/pull/74). Let us know if it’s persisting for you.

---

<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:** [December 29, 2024, 3:09pm UTC](https://forum.codecrafters.io/t/kotlin-build-your-own-shell-stage-ra6-output-does-not-match-expected-value/3516/9 "2024-12-29T15:09:52Z")

</div>

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