foundry: forge update - Unable to find revision in submodule path

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

0.2.0

What command(s) is the bug in?

forge update

Operating System

macOS (Apple Silicon)

Describe the bug

Hi there!

I’ve just started using foundry as a replacement of the hardhat (I really love the foundry idea ❤️ ). I’m following the documentation and I realized that I have a small issue with forge update.

Basically I installed openzeppelin contracts:

forge install openzeppelin/openzeppelin-contracts

and if I execute a command forge update then I get an error:

Error:
fatal: Unable to find refs/remotes/origin/v4.8.0 revision in submodule path 'lib/openzeppelin-contracts'

The git submodule status returns:

 a24d813f6bd4ab40e07e8ba940dbbe9cca03f9cd lib/forge-std (v1.1.0-4-ga24d813)
 49c0e4370d0cc50ea6090709e3835a3091e33ee2 lib/openzeppelin-contracts (v4.8.0)

Any idea what I’m doing wrong?

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 3
  • Comments: 17 (3 by maintainers)

Most upvoted comments

rn forge update just does

git submodule update --init --remote

unclear what this error even means. I think this is somehow related to the git tag of the dependency but no idea honestly.

So not sure what to actually do on forge update

I’m also encountering this issue, and can reproduce it in a brand new forge project by running:

> forge init
> forge update
fatal: Needed a single revision
Unable to find current origin/v1.2.0 revision in submodule path 'lib/forge-std'

The workaround as of right now seems to be removing and reinstalling my submodules.

@mattsse after more investigation, i think the issue is the branch specification in the .gitmodules. some comments:

  1. submodule set-branch only adds the entry in .gitmodules file, no additional magic behind the scenes. the submodule still points to the same commit at which it was added. stackoverflow
  2. from the same stackoverflow answer: branch entry accepts branch name only. tags and shas are not supported.
  3. some magical attempts to properly update submodules