# Working locally but failing submit #ue6

**URL:** https://forum.codecrafters.io/t/working-locally-but-failing-submit-ue6/16188
**Category:** Challenges
**Tags:** challenge:shell
**Created:** [June 30, 2026, 2:47pm UTC](https://forum.codecrafters.io/t/working-locally-but-failing-submit-ue6/16188 "2026-06-30T14:47:22Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Gautam1608](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/gautam1608/32/27102_2.png) [@Gautam1608](https://forum.codecrafters.io/u/Gautam1608)
#### Post date: [June 30, 2026, 2:47pm UTC](https://forum.codecrafters.io/t/working-locally-but-failing-submit-ue6/16188/1 "2026-06-30T14:47:22Z")

</div>

I’m stuck on Stage #ue6.

Here are my logs:

```auto
[tester::#ZV2] ✓ Prompt line matches "$ wc grape-"
[tester::#ZV2] Pressed "<TAB>" (expecting autocomplete to "wc grape-90.txt" followed by a space)
[your-program] $ wc grape-grape-90.txt 
[tester::#ZV2] ^ Line does not match expected value.
[tester::#ZV2] Expected: "$ wc grape-90.txt "
[tester::#ZV2] Received: "$ wc grape-grape-90.txt "

```

Locally when I run it, It is working correctly.

Python Completer code:

```auto
builtin=["exit", "echo", "type", "pwd","cd"]
autocomplete_list=builtin.copy()
for path in os.environ.get("PATH", "").split(os.pathsep):
    if os.path.exists(path):
        autocomplete_list.extend(os.listdir(path))

def completer(text,state):
    buffer = readline.get_line_buffer()
    last_word = buffer.split()[-1] if buffer else ""
    prev_path = Path(last_word)
    if not prev_path.is_dir():
        prev_path = Path()
    if not text:
        options=([cmd for cmd in os.listdir(prev_path)])
    else:
        if '/' not in text and '\\' not in text:
            options = [cmd for cmd in autocomplete_list if cmd.startswith(text)]
            options.extend([cmd for cmd in os.listdir() if cmd.startswith(text)])
        else:
            path = prev_path/Path(text)
            prefix = ".\\" if not path.is_absolute else ""
            if path.is_dir():
                options = [prefix+str(path/cmd) for cmd in os.listdir(path)]
            else:
                path_dir = path.parent.absolute()
                path_text = path.name
                options = [cmd for cmd in os.listdir(path_dir) if cmd.startswith(path_text)]
    if state < len(options):
        option = Path(options[state])
        if option.is_dir():
            return str(option)+"/"
        return options[state]+" "
    return None

```

What am I here?

---

<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: [June 30, 2026, 5:41pm UTC](https://forum.codecrafters.io/t/working-locally-but-failing-submit-ue6/16188/3 "2026-06-30T17:41:02Z")

</div>

Hey @Gautam1608, 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: ![Gautam1608](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/gautam1608/32/27102_2.png) [@Gautam1608](https://forum.codecrafters.io/u/Gautam1608)
#### Post date: [June 30, 2026, 6:21pm UTC](https://forum.codecrafters.io/t/working-locally-but-failing-submit-ue6/16188/4 "2026-06-30T18:21:03Z")

</div>

I… dont know haha.

So 1st thing I did is to stop using powershell(default terminal in vscode).

I change it to git bash.

That meant I didnt need to worry about windows and posix, so I changed the completion to posix output:

```auto
def completer(text,state):
    if not text:
        options=([cmd for cmd in os.listdir()])
    else:
        if '/' not in text and '\\' not in text:
            options = [cmd for cmd in autocomplete_list if cmd.startswith(text)]
            options.extend([cmd for cmd in os.listdir() if cmd.startswith(text)])
        else:
            path = Path(text)
            prefix = "./" if not path.is_absolute() else ""
            if path.is_dir():
                options = [prefix+(path/cmd).as_posix() for cmd in os.listdir(path)]
            else:
                path_dir = path.parent.absolute() if path.parent.absolute().is_dir() else Path()
                path_text = path.name
                options = [(path.parent/cmd).as_posix() for cmd in os.listdir(path_dir) if cmd.startswith(path_text)]
    if state < len(options):
        option = Path(options[state])
        if option.is_dir():
            return option.as_posix()+"/"
        return options[state]+" "
    return None

```

I am not a pro, and I have written so much code that I am feeling a little lost myself.

The changes I made was to remove the readline.get\_line\_buffer() as in bash text is the full “word” unlike powershell, which I still dont know what text it was giving me.

I believe something here solved the problem.

Although I am facing a similar problem yet again:

```auto
[tester::#LC6] Running tests for Stage #LC6 (Filename Completion - Directory completion)
[tester::#LC6] [working_dir] - rat/
[tester::#LC6] [working_dir] - pig/ (empty)
[tester::#LC6] Running ./your_program.sh
[tester::#LC6] ✓ Received prompt ($ )
[tester::#LC6] Typed "ls" followed by a <SPACE>
[tester::#LC6] ✓ Prompt line matches "$ ls "
[tester::#LC6] Pressed "<TAB>" (expecting autocomplete to "ls rat/")
[tester::#LC6] ✓ Prompt line matches "$ ls rat/"
[tester::#LC6] Pressed "<TAB>" (expecting autocomplete to "ls rat/pig/")
[your-program] $ ls rat/rat/
[tester::#LC6] ^ Line does not match expected value.
[tester::#LC6] Expected: "$ ls rat/pig/"
[tester::#LC6] Received: "$ ls rat/rat/"
[tester::#LC6] Test failed                                                                                                                                                                                      

```

But the code locally is working fine:

> $ ls  
> app codecrafters.yml grape-90.txt pig pyproject.toml README.md uv.lock your\_program.sh  
> $ cd pig  
> $ ls  
> owl  
> $ cd ..  
> $ cd pig/owl/  
> $

I did the exercise step for step. I am not able to replicate the failure locally.

FYI I typed: cd pig/ and it gave me cd pig/owl/

This time it should not be posix and windows issue, atleast thats what i believe.

Edit: I think this is important and I forgot to mention, readline doesnt work for windows.

So I am using the below import to resolve this. Took me good few tries to come up with this idea and I dont even know if it works or not.

```auto
try:
    import readline
except ImportError:
    try:
        from pyreadline3 import Readline
        readline = Readline()
        def input(txt):
            readline.readline(txt)
    except ImportError:
        readline = None

```

---

<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: [June 30, 2026, 6:50pm UTC](https://forum.codecrafters.io/t/working-locally-but-failing-submit-ue6/16188/5 "2026-06-30T18:50:57Z")

</div>

@Gautam1608 To make sure any earlier stages are not broken, you can use [our CLI](https://docs.codecrafters.io/cli/installation) to test against previous stages by running:

```auto
codecrafters test --previous

```

This is a handy way to catch regressions.

---

<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 5, 2026, 6:51pm UTC](https://forum.codecrafters.io/t/working-locally-but-failing-submit-ue6/16188/6 "2026-07-05T18:51:13Z")

</div>

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