Skip to content

forge install modifies top-level .gitmodules in existing project repo instead of where foundry.toml lives #3962

@opqpop

Description

@opqpop

Component

Forge

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

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (d3d8c0b 2022-12-26T00:04:10.853709324Z)

What command(s) is the bug in?

forge install

Operating System

Linux

Describe the bug

Repro

  • Make any git repro so you have an existing repro. For ex: src/admin, src/analysis, src/some_project, src/blockchain_proj, also touch .gitmodules so there's one at the top level

image

  • blockchain_proj needs to write .sol, so will use foundry. Go make the backend there w/ cd src/blockchain_proj && foundry init backend_contract_proj1

  • cd backend_contract_proj1, Run forge install openzeppelin/openzeppelin-contracts --no-commit

This will add new code into my top-level .gitmodules, instead of creating a src/blockchain_proj/backend_contract_proj1/.gitmodules, which is diff from how npm, pip/poetry, etc all do it. They will detect the top-level "for the project" (i.e. where foundry.tml lives @ src/blockchain_proj/backend_contract_proj1/foundry.toml) and modify any .git files there, instead of always going all the way up to the top of the root.

What's the best way to get forge install to stop doing this? I tried creating a src/blockchain_proj/backend_contract_proj1/.gitmodules but everytime I install it still installs into my top-level .gitmodules and I have to copy paste it over

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions