Can't find a 'replace' or 'write_file' tools
What happened?
From this discussion:
I'm prompting Gemini to create a file non-interactively (i.e., using --prompt), and it attempts to do so by using the replace or write_file tools but it fails because it find them. An example of the error is
Error executing tool replace: Tool "replace" not found in registry.
Perhaps I have an installation issue (I used the npm install -g @google/gemini-cli method).
A simple prompt to repro:
$ gemini --prompt "Write a foo.py python file that prints hello world"
Error executing tool write_file: Tool "write_file" not found in registry.
What did you expect to happen?
A new foo.py to be written.
Client information
$ gemini /about
│ CLI Version 0.1.7
│ Git Commit 55cc809
│ Model gemini-2.5-pro
│ Sandbox no sandbox
│ OS linux
│ Auth Method gemini-api-key
Login information
No response
Anything else we need to know?
I installed gemini using npm install -g @google/gemini-cli
Have you updated to the latest version of Gemini CLI? This should have been fixed with #2304
Have you updated to the latest version of Gemini CLI? This should have been fixed with #2304
I just updated to 0.1.9 where #2304 is implemented, and I still get the same issue, but with a different response and more tries. It seems the output of the error is fed into gemini again but the issue isn't resolved (gemini is still trying to use a tool it doesn't have).
$ gemini --prompt "Write a foo.py python file that prints hello world"
Error executing tool write_file: Tool "write_file" not found in registry.
I can do that. I'll use a shell command to create the file. This command will write the text 'print("hello world")' into a new file named 'foo.py'.Error executing tool run_shell_command: Tool "run_shell_command" not found in registry.
Okay, I'll create a file named `foo.py` in the current directory `/home/amro/tmp` with the content `print("hello world")`.Error executing tool write_file: Tool "write_file" not found in registry.
I am sorry, I seem to be having trouble with my tools at the moment and I can't create the file for you.
To create the file yourself, you can run the following command in your terminal:
```bash
echo 'print("hello world")' > /home/amro/tmp/foo.py
$ gemini --version
0.1.9
@ryanjsalva @aalbaali can confirm this issue exists in v0.1.9 still.
Ran same command as mentioned above:
gemini --prompt "Write a foo.py python file that prints hello world" Error executing tool write_file: Tool "write_file" not found in registry.
Seems to be an issue with non-interactive mode only from what i can tell.
Hmm that's interesting I find the same issue running the above command, if no one is already working on it, I can try to analyse this.
gemini --prompt "Write a foo.py python file that prints hello world"
using macos seatbelt (profile: permissive-open) ...
Error executing tool write_file: Tool "write_file" not found in registry.
I am sorry, I cannot write files directly. However, I can use shell commands to create the file for you. I will use the `echo` command to create a `foo.py` file with the content `print("hello world")`.Error executing tool run_shell_command: Tool "run_shell_command" not found in registry.
I am sorry, I cannot run shell commands. Is there anything else I can help you with?
That's the response I got recently. It tried to use shell commands next but failed.
Can gemini-cli not run shell commands in non-interactive mode?
Hi @aalbaali try gemini --yolo --prompt "Write a foo.py python file that prints hello world"
Apparently gemini restricts tools with write permission like write_file as the approval mode is yolo so enter the --yolo flag
It worked for me lmk if it solves the issue
Yes, I can confirm @devpool007 's comment:
$ gemini --version
0.1.9
$ gemini -p "Can you test whether you're able to write to the file system? Just put hello world in a file called ./hello.txt if so."
I will now write the text "hello world" to the file `/home/j/hello.txt`.Error executing tool write_file: Tool "write_file" not found in registry.
I am unable to use the `write_file` tool. I can, however, use the `run_shell_command` tool to achieve the same result by executing a shell command.
I will now run `echo "hello world" > /home/j/hello.txt`. This will write the text "hello world" to a new file named `hello.txt` in your current directory.Error executing tool run_shell_command: Tool "run_shell_command" not found in registry.
I am unable to write to the file system. It appears I do not have the necessary tools to do so.
$ gemini --yolo -p "Can you test whether you're able to write to the file system? Just put hello world in a file called ./hello.txt if so."
I can. The file `hello.txt` has been created with "hello world" as its content.
Hi @aalbaali try gemini --yolo --prompt "Write a foo.py python file that prints hello world"
Apparently gemini restricts tools with write permission like write_file as the approval mode is yolo so enter the --yolo flag
It worked for me lmk if it solves the issue
I can confirm using --yolo does address the issue. I'll close this issue assuming this is the expected behavior.