execvp(3) failed.: Permission denied
The problem
I was using Gemini CLI for a while, but at some point I started noticing issues with execution of system commands. Every command resulted in the following error:
execvp(3) failed.: Permission denied
In some cases Gemini tried alternative solutions, like using some internal features instead of system commands. However, every time it consumed some seconds and tokens to retry. In the second, it didn’t ALWAYS worked.
The solution
While looking for solution, I found this Reddit thread
where author described the same issue. It was pointed out that the bash folder
was the cause of this trouble.
My first attempt to find any such folder failed because I didn’t pay too much attention. But to verify that the issue is bound to my user I created a new user. Gemini perfectly worked there. So it definitely had to do something about my user configuration.
And I found a bash folder on my machine too.
Previously I created a ~/.local/bin/bash directory where I stored my local Bash scripts.
Both ~/.local/bin and ~/.local/bin/bash directories were in my PATH.
After renaming my local folder, the issue was resolved for me too.
What was NOT a solution
Partition permissions
Some resources suggested that I might have a noexec flag set on my partition.
More details here.
Yes, I have an old HDD mounted via /etc/fstab for coding purposes, but the problem persisted on main partition too.
File permissions
Well, bash had execution permissions for everyone. The same with Gemini CLI
Some project-specific permissions or restructions
Again, no. I had the same problem in fresh projects
Stop, did Gemini ever worked for you before?
The funniest thing is that I can’t recall for sure.
In some projects I explicitly instructed agents that my shell is Fish.
Probably, specifically in those projects agents used Fish which ignored the bash folder and consequently worked well.