Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: SHA could not be resolved, git returned: b'' #1287

Closed
yigengjiang opened this issue May 22, 2024 · 2 comments
Closed

ValueError: SHA could not be resolved, git returned: b'' #1287

yigengjiang opened this issue May 22, 2024 · 2 comments

Comments

@yigengjiang
Copy link

Bug description

when I execute metagpt "Create a 2048 game" , it outputs error:

ValueError: Reference at 'refs/heads/master' does not exist
ValueError: SHA could not be resolved, git returned: b''

I have try to create a branch to fix the bug by executing git checkout -b master , however it still fails.

I just wanna use the codes locally and do not want to use git to commit to MetaGPT.
Please help me fix the bug, thanks!

Environment information

  • LLM type and model name:OpenAI gpt-3.5-turbo
  • System version:ubuntu 22.04
  • Python version:conda python 3.9
  • MetaGPT version or branch:newest

Screenshots or logs

2024-05-22 01:06:27.179 | ERROR | metagpt.utils.common:wrapper:631 - Exception occurs, start to serialize the project, exp:
Traceback (most recent call last):
File "/mnt/82_store/jyg/envs/metagpt/lib/python3.9/site-packages/git/objects/commit.py", line 613, in create_from_tree
repo.head.set_commit(new_commit, logmsg=message)
File "/mnt/82_store/jyg/envs/metagpt/lib/python3.9/site-packages/git/refs/symbolic.py", line 313, in set_commit
self.set_object(commit, logmsg)
ValueError: Reference at 'refs/heads/master' does not exist

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/mnt/42_store/jyg/research_project/agent/MetaGPT/metagpt/utils/common.py", line 640, in wrapper
return await func(self, *args, **kwargs)
File "/mnt/42_store/jyg/research_project/agent/MetaGPT/metagpt/roles/role.py", line 550, in run
rsp = await self.react()
ValueError: SHA could not be resolved, git returned: b''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/mnt/42_store/jyg/research_project/agent/MetaGPT/metagpt/utils/common.py", line 626, in wrapper
result = await func(self, *args, **kwargs)
File "/mnt/42_store/jyg/research_project/agent/MetaGPT/metagpt/team.py", line 131, in run
await self.env.run()
Exception: Traceback (most recent call last):
File "/mnt/82_store/jyg/envs/metagpt/lib/python3.9/site-packages/git/objects/commit.py", line 613, in create_from_tree
repo.head.set_commit(new_commit, logmsg=message)
File "/mnt/82_store/jyg/envs/metagpt/lib/python3.9/site-packages/git/refs/symbolic.py", line 313, in set_commit
self.set_object(commit, logmsg)
File "/mnt/82_store/jyg/envs/metagpt/lib/python3.9/site-packages/git/refs/symbolic.py", line 346, in set_object
return self._get_reference().set_object(object, logmsg)
File "/mnt/82_store/jyg/envs/metagpt/lib/python3.9/site-packages/git/refs/reference.py", line 82, in set_object
oldbinsha = self.commit.binsha
File "/mnt/82_store/jyg/envs/metagpt/lib/python3.9/site-packages/git/refs/symbolic.py", line 274, in _get_commit
obj = self._get_object()
File "/mnt/82_store/jyg/envs/metagpt/lib/python3.9/site-packages/git/refs/symbolic.py", line 267, in _get_object
return Object.new_from_sha(self.repo, hex_to_bin(self.dereference_recursive(self.repo, self.path)))
File "/mnt/82_store/jyg/envs/metagpt/lib/python3.9/site-packages/git/refs/symbolic.py", line 159, in dereference_recursive
hexsha, ref_path = cls._get_ref_info(repo, ref_path)
File "/mnt/82_store/jyg/envs/metagpt/lib/python3.9/site-packages/git/refs/symbolic.py", line 258, in _get_ref_info
return cls._get_ref_info_helper(repo, ref_path)
File "/mnt/82_store/jyg/envs/metagpt/lib/python3.9/site-packages/git/refs/symbolic.py", line 241, in _get_ref_info_helper
raise ValueError("Reference at %r does not exist" % ref_path)
ValueError: Reference at 'refs/heads/master' does not exist

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/mnt/42_store/jyg/research_project/agent/MetaGPT/metagpt/utils/common.py", line 640, in wrapper
return await func(self, *args, **kwargs)
File "/mnt/42_store/jyg/research_project/agent/MetaGPT/metagpt/roles/role.py", line 550, in run
rsp = await self.react()
File "/mnt/42_store/jyg/research_project/agent/MetaGPT/metagpt/roles/role.py", line 519, in react
rsp = await self._react()
File "/mnt/42_store/jyg/research_project/agent/MetaGPT/metagpt/roles/role.py", line 474, in _react
rsp = await self._act()
File "/mnt/42_store/jyg/research_project/agent/MetaGPT/metagpt/roles/role.py", line 403, in _act
response = await self.rc.todo.run(self.rc.history)
File "/mnt/42_store/jyg/research_project/agent/MetaGPT/metagpt/actions/prepare_documents.py", line 46, in run
self._init_repo()
File "/mnt/42_store/jyg/research_project/agent/MetaGPT/metagpt/actions/prepare_documents.py", line 41, in _init_repo
self.context.git_repo = GitRepository(local_path=path, auto_init=True)
File "/mnt/42_store/jyg/research_project/agent/MetaGPT/metagpt/utils/git_repository.py", line 55, in init
self.open(local_path=local_path, auto_init=auto_init)
File "/mnt/42_store/jyg/research_project/agent/MetaGPT/metagpt/utils/git_repository.py", line 71, in open
return self._init(local_path)
File "/mnt/42_store/jyg/research_project/agent/MetaGPT/metagpt/utils/git_repository.py", line 85, in _init
self._repository.index.commit("Add .gitignore")
File "/mnt/82_store/jyg/envs/metagpt/lib/python3.9/site-packages/git/index/base.py", line 1050, in commit
rval = Commit.create_from_tree(
File "/mnt/82_store/jyg/envs/metagpt/lib/python3.9/site-packages/git/objects/commit.py", line 617, in create_from_tree
master = git.refs.Head.create(
File "/mnt/82_store/jyg/envs/metagpt/lib/python3.9/site-packages/git/refs/symbolic.py", line 661, in create
return cls._create(repo, path, cls._resolve_ref_on_create, reference, force, logmsg)
File "/mnt/82_store/jyg/envs/metagpt/lib/python3.9/site-packages/git/refs/symbolic.py", line 602, in _create
target = repo.rev_parse(str(reference))
File "/mnt/82_store/jyg/envs/metagpt/lib/python3.9/site-packages/git/repo/fun.py", line 378, in rev_parse
obj = cast(Commit_ish, name_to_object(repo, rev))
File "/mnt/82_store/jyg/envs/metagpt/lib/python3.9/site-packages/git/repo/fun.py", line 187, in name_to_object
return Object.new_from_sha(repo, hex_to_bin(hexsha))
File "/mnt/82_store/jyg/envs/metagpt/lib/python3.9/site-packages/git/objects/base.py", line 94, in new_from_sha
oinfo = repo.odb.info(sha1)
File "/mnt/82_store/jyg/envs/metagpt/lib/python3.9/site-packages/git/db.py", line 40, in info
hexsha, typename, size = self._git.get_object_header(bin_to_hex(binsha))
File "/mnt/82_store/jyg/envs/metagpt/lib/python3.9/site-packages/git/cmd.py", line 1384, in get_object_header
return self.__get_object_header(cmd, ref)
File "/mnt/82_store/jyg/envs/metagpt/lib/python3.9/site-packages/git/cmd.py", line 1371, in __get_object_header
return self._parse_object_header(cmd.stdout.readline())
File "/mnt/82_store/jyg/envs/metagpt/lib/python3.9/site-packages/git/cmd.py", line 1330, in _parse_object_header
raise ValueError("SHA could not be resolved, git returned: %r" % (header_line.strip()))
ValueError: SHA could not be resolved, git returned: b''

@usamimeri
Copy link
Contributor

Hi, it seems that the bug occurred when the team attempted to make the first commit to the newly initialized git repository.

File "/mnt/42_store/jyg/research_project/agent/MetaGPT/metagpt/actions/prepare_documents.py", line 46, in run
    self._init_repo()
File "/mnt/42_store/jyg/research_project/agent/MetaGPT/metagpt/actions/prepare_documents.py", line 41, in _init_repo
    self.context.git_repo = GitRepository(local_path=path, auto_init=True)
File "/mnt/42_store/jyg/research_project/agent/MetaGPT/metagpt/utils/git_repository.py", line 55, in __init__
    self.open(local_path=local_path, auto_init=auto_init)
File "/mnt/42_store/jyg/research_project/agent/MetaGPT/metagpt/utils/git_repository.py", line 71, in open
    return self._init(local_path)
File "/mnt/42_store/jyg/research_project/agent/MetaGPT/metagpt/utils/git_repository.py", line 85, in _init
    self._repository.index.commit("Add .gitignore")

I tried to reproduce your issue with conda create -n metagpt python=3.9 and git clone https://github.com/geekan/MetaGPT && cd MetaGPT && pip install --upgrade -e . but it completed successfully.

could you provider more information to better reproduction ?

@yigengjiang
Copy link
Author

Hi, it seems that the bug occurred when the team attempted to make the first commit to the newly initialized git repository.

File "/mnt/42_store/jyg/research_project/agent/MetaGPT/metagpt/actions/prepare_documents.py", line 46, in run
    self._init_repo()
File "/mnt/42_store/jyg/research_project/agent/MetaGPT/metagpt/actions/prepare_documents.py", line 41, in _init_repo
    self.context.git_repo = GitRepository(local_path=path, auto_init=True)
File "/mnt/42_store/jyg/research_project/agent/MetaGPT/metagpt/utils/git_repository.py", line 55, in __init__
    self.open(local_path=local_path, auto_init=auto_init)
File "/mnt/42_store/jyg/research_project/agent/MetaGPT/metagpt/utils/git_repository.py", line 71, in open
    return self._init(local_path)
File "/mnt/42_store/jyg/research_project/agent/MetaGPT/metagpt/utils/git_repository.py", line 85, in _init
    self._repository.index.commit("Add .gitignore")

I tried to reproduce your issue with conda create -n metagpt python=3.9 and git clone https://github.com/geekan/MetaGPT && cd MetaGPT && pip install --upgrade -e . but it completed successfully.

could you provider more information to better reproduction ?

Thanks! I have solved the error. This is because the ownership of the whole project MetaGPT is another user not meprobably because i mkdir under a NFS directory. So I do not have the permission to do some git operations which results the error.
To solve the error, you need to have the ownership of the whole project. For example, you can clone the project under "/home/username" on Linux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants