Bug in "Build you own Shell" - Autocompletion

I cannot get past the first step in the Autocompletion module in Build your own Shell. It seems there is a bug in the test script as can be seen below:

For some reason it seems that the “Expected” string and the test input does not match (input’s missing the letter “b”)

Hey @mikkel-larsen, it doesn’t appear to be a bug on our end. You can try running the program locally to verify that the letter b is indeed being swallowed by readline:

The issue seems to stem from this line: readline.parse_and_bind("bind ^I rl_complete"). Removing it allows your code to pass all tests.

That’s strange. It works for me when I try locally.

I can’t, however, use tab-completion if I remove readline.parse_and_bind("bind ^I rl_complete"). Though I can see that the tests run successfully on your end without that line.

But that means that I cannot use tab-completion on my machine for the rest of the assignments if I want to complete this :frowning:

That’s definitely peculiar. By the way, how did you come across the workaround "bind ^I rl_complete"? Curious why Control-I would map to Tab. :thinking:


To help confirm whether you’re using GNU Readline or libedit under the hood, could you share the result of running print(readline.__doc__)?

Definitely!

And I agree, I was sceptical of the command when I found it (on Reddit), but as it worked I admit I did not think further of it.

Looks like your readline is using libedit instead of GNU Readline.

The issue can be resolved by installing GNU Readline:

brew install readline

Was already installed. Do I need to do something to make it the default instead of libedit?

My Python is installed via Anaconda, and I just confirmed that readline is installed through conda as well:

Not sure if pip install would work in this case.

@mikkel-larsen You might be able to move that workaround to ~/.editrc instead of including it in your code:

the .editrc config file did the trick for me!

Thank you for the help.

1 Like

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