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

Error when runnning upgrade safety validation #85

Open
clauBv23 opened this issue Nov 20, 2024 · 5 comments
Open

Error when runnning upgrade safety validation #85

clauBv23 opened this issue Nov 20, 2024 · 5 comments

Comments

@clauBv23
Copy link

I carefully followed all the installation and configuration steps, and everything was working perfectly.

However, it has suddenly started failing with the following error

[Revert] revert: Failed to run upgrade safety validation: sh: openzeppelin-upgrades-core: command not found

I didn’t upgrade forge-sdt or any other library.

@ericglau
Copy link
Member

ericglau commented Nov 20, 2024

Can you try increasing verbosity when running your script/test, and provide the output? e.g. forge script ... -vvv

@clauBv23
Copy link
Author

Hey, sorry for the lack of context.

I'm running a simple test to check the upgrade, the test looks like this:

function test_validateUpgrade() external {
        Options memory ops;
        ops.referenceContract = "ContractA.sol:ContractA";
        ops.unsafeAllow = "delegatecall";
        Upgrades.validateUpgrade("ContractB.sol", ops);
    }

command : forge test --mt test_validateUpgrade -vvvv

and output

[FAIL: revert: Failed to run upgrade safety validation: sh: openzeppelin-upgrades-core: command not found
] 

The last logs are:

├─ [0] VM::envOr("OPENZEPPELIN_BASH_PATH", "bash") [staticcall]
│   └─ ← [Return] <env var value>
├─ [0] VM::tryFfi(["bash", "-c", "npx @openzeppelin/upgrades-core@^1.37.0 validate out/build-info --contract src/StagedProposalProcessor.sol:StagedProposalProcessor --reference \"test/utils/harness/DummySPP.sol:DummySPP\" --requireReference --unsafeAllow delegatecall"])
│   └─ ← [Return] (127, 0x, 0x73683a206f70656e7a657070656c696e2d75706772616465732d636f72653a20636f6d6d616e64206e6f7420666f756e640a)
└─ ← [Revert] revert: Failed to run upgrade safety validation: sh: openzeppelin-upgrades-core: command not found

and reverts here

@ericglau
Copy link
Member

Thanks for the context. This might be a local installation issue with the @openzeppelin/upgrades-core NPM package which is used for validations.

Can you try reinstalling the package by running

npm install @openzeppelin/upgrades-core@latest

then try the test again?

@clauBv23
Copy link
Author

clauBv23 commented Nov 21, 2024

Thanks for the fast response.

I didn’t have @openzeppelin/upgrades-core on my dependencies since I don't use it.

However, after installing it (on my dependencies) seems to work.

But would like to know what is the real issue and why would I need to add upgrades-core to my dependencies? Shouldn’t openzeppelin-foundry-upgrades dependencies be managed after installing the package?

@ericglau
Copy link
Member

openzeppelin-foundry-upgrades just runs npx @openzeppelin/upgrades-core..., and since the npx command can fetch the @openzeppelin/upgrades-core package to your npm cache, typically there is no need to install it in your dependencies.

In your case, it seems that the fetched package in your local npm cache is somehow missing some files, resulting in the command not found error when trying to run a script from the package. As this occurred on your local environment, I don't know what caused it.

Manually installing the package to your dependencies solves the issue so that npx will run it from your installed dependencies.

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