terminal cd . results in following weird error in the terminal buffer:

executing job failed: No such file or directory

The same error appears for term_start('cd .'). It doesn't matter which directory I cd to, the error doesn't change.

If I execute terminal without command, then execute cd . in the opened terminal, everything works fine.

I'm using vim8.1 include patches 1-1282 on Ubuntu 16.04.6 .

Based on help from comment and answer, I changed the command to

terminal bash -c 'cd .'

but it results in following error:

.': -c: line 0: unexpected EOF while looking for matching `''
.': -c: line 1: syntax error: unexpected end of file

buffer name of the terminal is:

!bash -c 'cd .'

If I replace the single quotes with double quotes the command works. But why?

  • Im not sure i understand why you would do this—the terminal would just execute a cd and then exit, so the net effect for you is absolutely nothing.
    – D. Ben Knoble
    May 6, 2019 at 13:15
  • I need to cd to bin and do something, i thought that doesn't change the problem, so i make the case as simple as possible.
    – dedowsdi
    May 6, 2019 at 13:20
  • Gotcha. That makes sense.
    – D. Ben Knoble
    May 6, 2019 at 13:21
  • 2
    I believe cd is actually an internal shell command and not actually a binary. See also this answer: unix.stackexchange.com/a/50025/303213 and here: unix.stackexchange.com/a/116972/303213 May 6, 2019 at 17:08
  • @ChristianBrabandt Thanks, very helpful.
    – dedowsdi
    May 6, 2019 at 23:50

1 Answer 1


Based on Chris’s comments on the OP, I would make the shell do the work, using a level of indirection:

terminal bash -c "cd wherever && do_something"

The issue is that the bare :terminal command doesn’t ever execute a shell—it executes the name of the external program you give it (which, by default, happens to be the shell). So, terminal cd . tries to run a command on disk named cd. For reasons, you don’t have one, and it wouldn’t work if you did.

  • Not working well, see update.
    – dedowsdi
    May 7, 2019 at 2:23
  • @dedowsdi dang. Must be vim’s command line doing something weird with the quotes. Ill check it out in the morning
    – D. Ben Knoble
    May 7, 2019 at 2:25
  • 1
    use double quotes. not sure what single quotes do here. May 7, 2019 at 5:42
  • @ChristianBrabandt theyre just easier to type. I wouldn’t have thought it made a difference in this particular case
    – D. Ben Knoble
    May 7, 2019 at 13:35
  • 2
    :terminal run command as job, job_start split command by white space and pass result list to execvp(), only arguments in double quotes can contain white space. Don't know the reason behind the choice of double quotes, but i can settle for that.
    – dedowsdi
    May 12, 2019 at 2:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.