Build your own shell - Single Quote - permission denied

Hello,

I am a bit stuck on the challenge with single quote in the challenge building your own shell.

It looks to me that my args are correctly parsed but the file can’t be accessed on the file system during the tests.

This is the error I get

remote: [tester::#NI6] Running tests for Stage #NI6 (Quoting - Single quotes)
remote: [tester::#NI6] [setup] export PATH=/tmp/blueberry/pear/grape:$PATH
remote: [tester::#NI6] Running ./your_program.sh
remote: [tester::#NI6] [setup] echo -n “pear blueberry.” > “/tmp/ant/f 78”
remote: [tester::#NI6] [setup] echo -n “pear orange.” > “/tmp/ant/f 60”
remote: [tester::#NI6] [setup] echo “apple pear.” > “/tmp/ant/f 90”
remote: [your-program] $ echo ‘script world’
remote: [your-program] script world
remote: [tester::#NI6] ✓ Received expected response
remote: [your-program] $ echo world example
remote: [your-program] world example
remote: [tester::#NI6] ✓ Received expected response
remote: [your-program] $ echo ‘hello shell’ ‘example’‘script’ world’'test
remote: [your-program] hello shell examplescript worldtest
remote: [tester::#NI6] ✓ Received expected response
remote: [your-program] $ cat ‘/tmp/ant/f 78’ ‘/tmp/ant/f 60’ ‘/tmp/ant/f 90’
remote: [your-program] Traceback (most recent call last):
remote: [tester::#NI6] ^ Line does not match expected value.
remote: [tester::#NI6] Expected: “pear blueberry.pear orange.apple pear.”
remote: [tester::#NI6] Received: “Traceback (most recent call last):”
remote: [your-program] File “”, line 198, in _run_module_as_main
remote: [your-program] File “”, line 88, in _run_code
remote: [your-program] File “/app/app/main.py”, line 74, in
remote: [your-program] main()
remote: [your-program] ~~~~^^
remote: [your-program] File “/app/app/main.py”, line 65, in main
remote: [your-program] subprocess.run(args)
remote: [your-program] ~~~~~~~~~~~~~~^^^^^^
remote: [your-program] File “/usr/local/lib/python3.14/subprocess.py”, line 554, in run
remote: [your-program] with Popen(*popenargs, **kwargs) as process:
remote: [your-program] ~~~~~^^^^^^^^^^^^^^^^^^^^^^
remote: [your-program] File “/usr/local/lib/python3.14/subprocess.py”, line 1038, in init
remote: [your-program] self._execute_child(args, executable, preexec_fn, close_fds,
remote: [your-program] ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
remote: [your-program] pass_fds, cwd, env,
remote: [your-program] ^^^^^^^^^^^^^^^^^^^
remote: [your-program] …<5 lines>…
remote: [your-program] gid, gids, uid, umask,
remote: [your-program] ^^^^^^^^^^^^^^^^^^^^^^
remote: [your-program] start_new_session, process_group)
remote: [your-program] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
remote: [your-program] File “/usr/local/lib/python3.14/subprocess.py”, line 1970, in _execute_child
remote: [your-program] raise child_exception_type(errno_num, err_msg, err_filename)
remote: [your-program] PermissionError: [Errno 13] Permission denied: ‘/tmp/ant/f 78’
remote: [tester::#NI6] Assertion failed.
remote: [tester::#NI6] Test failed

If I run my program and pass the cat example, I get this when printing args (subprocess.run(args))

$ cat ‘/tmp/ant/f 78’ ‘/tmp/ant/f 60’ ‘/tmp/ant/f 90’
[‘/tmp/ant/f 78’, ‘/tmp/ant/f 60’, ‘/tmp/ant/f 90’]

which seems to be correct.

Note that in the in block quote above, the tabs in the file name seem to have been replaced by single space. The input during the test is like this:

remote: [your-program] $ cat ‘/tmp/ant/f 78’ ‘/tmp/ant/f 60’ ‘/tmp/ant/f 90’

this contains multiple spaces, this is not the case in the block quote somehow.

edit: same issue without the block quote, it looks like your editor on the forum replaces multiple spaces by a single one.

Any idea ? Thanks.

Hey @gillouche, looks like your shell is executing only the arguments and skipping the actual command:

To dig into this more easily, try re-running the previous tests using our CLI:

codecrafters test --previous

Let me know if you’d like any further clarification!

Oh, you are right indeed. Refactoring gone wrong, sorry about that.

I’ll need to find a better working setup to work locally because I don’t have a good flow for debugging my local code for the moment. I’ll install the CLI and try again tonight, thanks!

Thanks again, I could fix my problem with your help.

I also tried to install the CLI but it fails because of the mysterious absence of /usr/local/bin folder on my brand new macbook. I created the folder myself and the script worked so I now have the CLI.

That may be something you want to check but I don’t know if it is normal that I don’t have that folder created especially when it was in the PATH.

1 Like

@gillouche Thanks for highlighting the issue! We’re addressing it in this PR. Let us know if you spot anything else.

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