"Error: Global Truffle config not found: Truffle >=5.1.35 is required" - despite having the latest Truffle version

I'm trying to run multiple Truffle test suites. These suites all use deployProxy in a beforeEach call. The first suite runs fine, but all other suites fail with the error:

"before each" hook for <description of first test in corresponding suite>:
Error: Global Truffle config not found: Truffle >=5.1.35 is required. Truffle exec not yet supported

However, I'm not using a global Truffle installation. I'm using the latest Truffle version and calling: npx truffle test --network development.

I've searched through the forum for similar issues but they all involved removing the global Truffle package, which I don't use anyway - so I'm stuck on what to do.

Thanks!

:1234: Code to reproduce

:computer: Environment

Truffle v5.5.18 (core: 5.5.18)
Ganache v7.2.0
Solidity - pragma (solc-js) 0.8.0
Node v16.9.1
Web3.js v1.5.3

Can you share how your test suites are set up, or can you share a project to reproduce this?

Sure, my test suites are set up like this:

suite-1.ts:

    contract('Contract1Upgradeable.sol', ([owner, account1, account2, account3, account4, account5, account6, account7, account8, account9]) => {
        let contract1UpgradeableInstance: Contract1UpgradeableInstance;
     
        beforeEach(async () => {
            contract1UpgradeableInstance = (await deployProxy(contract1Upgradeable, [account8, account9], {
                initializer: 'initialize',
            })) as Contract1UpgradeableInstance;
        });

        it("tests something'", async () => {
           await ...
        });
     })

suite-2.ts

    contract('Contract2Upgradeable.sol', ([owner, account1, account2, account3, account4, account5, account6, account7, account8, account9]) => {
        let contract2UpgradeableInstance: Contract2UpgradeableInstance;
     
        beforeEach(async () => {
            contract2UpgradeableInstance = (await deployProxy(contract2Upgradeable, [account8, account9], {
                initializer: 'initialize',
            })) as Contract2UpgradeableInstance;
        });

        it("tests something'", async () => {
           await ...
        });
     })

The specific error I get is:

Error: Global Truffle config not found: Truffle >=5.1.35 is required. Truffle exec not yet supported

Unfortunately I'm working on a private repository so I can't share the exact code. If the above is not helpful, let me know what else you'd like.

Thank you!

The error message Global Truffle config not found: Truffle >=5.1.35 is required. is thrown by the upgrades plugin, and is not referring to any global installation of Truffle, but is talking about the config global variable that is available starting in Truffle 5.1.35.

The upgrades plugin reads this config variable provided by Truffle to determine some settings, and somehow it is not able to read this variable in your case.

I tried doing the beforeEach as in your example and it worked fine, so I am not sure what the difference is. If you would be able to provide a minimum repository to reproduce this, I could look into it further. Or, as a workaround, does it work if you put the deployProxy calls directly in your tests?

I tried to remove the beforeEach and place the snippet (including the deployProxy) within the test block but I still get the same error. Are you running multiple suites of tests? As I've mentioned the issue only crops up if there are multiple suites in different files.

Did you try to use the version of Truffle that I'm using? If not, which version did you use?

How are you specifying this config variable?

In case it helps, I only have a truffle-config.js which looks like:

require('ts-node').register({
    files: true,
});

module.exports = {
    plugins: ['truffle-plugin-verify'],
    networks: {
        development: {
            provider: () =>
                new HDWalletProvider(
                    testAccountsData.map(({ privateKey }) => privateKey),
                    config.AVAX.localSubnetHTTP
                ),
            network_id: '*',
            gas: 6721975,
            skipDryRun: true,
        },
        testnet: {
            provider: () => new HDWalletProvider([testAccountsData[0].privateKey, testAccountsData[1].privateKey, testAccountsData[2].privateKey], config.AVAX.testnetHTTP),
            network_id: '*',
            gas: 6721975,
            skipDryRun: true,
        },
    },
    compilers: {
        solc: {
            version: 'pragma', // Will use the relevant compiler version for each contract (experimental feature in truffle v5.2.0)
            settings: {
                optimizer: {
                    enabled: true,
                    runs: 999999999,
                },
            },
        },
    },
};

I tried multiple suites in different files, using the same version of Truffle 5.5.18 (also tried 5.5.19).

The config variable is used in the upgrades plugin here and does not need to be specified in your project.

But here's an idea to help debug this further: can you try adding console.log(config); before you call deployProxy (either in beforeEach or in the test block) to see if the config variable is available when you use it directly? This would help to determine if there is an issue outside of the upgrades plugin.

I've logged config for both suites (the working one, and the broken one) - and it's undefined for both. Which is strange because I would expect an error to be thrown by the plugin code when config === undefined and it doesn't seem to be thrown when running the first (working) suite.

Thank you for providing this information. I'm not sure what is the issue with your setup since the config variable should be available when you run npx truffle test.

In order to figure this out further, can you provide a basic repository that can reproduce this issue? Or if you find that a basic repository works fine, then you could use that to work towards getting your project to behave in a similar way.

Thanks Eric.

I've managed to isolate the problem to a specific, local network. If I run it against a custom AvalancheGo-based network I get the error. However, if I run it against a Ganache network it works fine. So must be some divergence between the two codebases that's the difference.

Are there any workarounds you can think of?

1 Like

Glad that it is working. I don't know of any workarounds but perhaps you could try checking with Truffle.

1 Like