Skip to content

DeclarationError: Identifier already declared when using Initializable #6082

@0xAllan123

Description

@0xAllan123

When importing both @openzeppelin/contracts and @openzeppelin/contracts-upgradeable, the Solidity compiler throws:

DeclarationError: Identifier already declared.
This happens because both versions define a contract named Initializable.

Steps to Reproduce:

  1. Install both packages:
    npm install @openzeppelin/contracts @openzeppelin/contracts-upgradeable
  2. Import both in a single contract:
    import "@openzeppelin/contracts/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
  3. Compile using Hardhat or Foundry.
    Expected Behavior:
    Either a clearer compiler error or a unified import strategy in docs to avoid confusion.

💻 Environment

  • Solidity: 0.8.26
  • Hardhat: 2.22.x
  • OpenZeppelin Contracts: 5.x
  • OpenZeppelin Contracts Upgradeable: 5.x

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions