AutoGPT: Error: 'PosixPath' object has no attribute 'is_relative_to'

⚠️ Search for existing issues first ⚠️

  • I have searched the existing issues, and there is no existing issue for my problem

GPT-3 or GPT-4

  • I am using Auto-GPT with GPT-3 (GPT-3.5)

Steps to reproduce 🕹

Working on stable

Prompt: You are a ai designed to create source code. Goal: First write a sample file to test that you are working

Current behavior 😯

When it tries to write a file it gives that error

{ “thoughts”: { “text”: “Let’s create a new file named sample.txt and write a sample text to it.”, “reasoning”: “This will test if we can successfully write to a file and check if the file is created in the correct location.”, “plan”: “- Use the write_to_file command to create a new file named sample.txt and write a sample text to it.”, “criticism”: “I should always double-check the file path before creating or modifying files to prevent errors.”, “speak”: “Let’s create a new file named sample.txt and write a sample text to it.” }, “command”: { “name”: “write_to_file”, “args”: { “file”: “./sample.txt”, “text”: “This is a sample text.” } } }


This will create a new file named `sample.txt` in the current working directory and write the sample text "This is a sample text." to it. After running this command, you can verify that the file was created and has the correct content by using the command `read_file` and passing the file path as the argument for the `file` parameter.

Let me know if there's anything else I can help you with!

  System: Command write_to_file returned: Error: 'PosixPath' object has no attribute 'is_relative_to'

  User: GENERATE NEXT COMMAND JSON

  Assistant: I apologize for the error in the previous command. It seems that the file path was not specified correctly. Let's try again to create the `sample.txt` file.

### Expected behavior 🤔

_No response_

### Your prompt 📝

```yaml
Role: You are a ai designed to create source code.
Goal 1: First write a sample file to test that you are working

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 23 (8 by maintainers)

Most upvoted comments

This solved the issue for me:

Change this line to:

return WORKSPACE_PATH.joinpath(relative_path)

Hi @Pwuts . I did a full rebuild of the .devcontainer and this resolved the issue.

Windows 10 Devcontainer + VSCode Python 3.10.11 Auto-GPT 0.2.2

I think this is now safe to close. Apologies for the confusion.

Edit: i was wrong here, fix is to update your python

This solved the issue for me:

Change this line to:

return WORKSPACE_PATH.joinpath(relative_path)

This change fixed my version also!

never mind I tried 3.10 and it worked. If anyone else is on Mac and uses 3.11 the voice will not work for some reason. I think there is a problem with that on 3.11. Also, make sure to install pyobjc.

@rocks6 I am getting the same error. What version should I upgrade my python to?