"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,
                },
            },
        },
    },
};