@openzeppelin/cli ignores contracts_build_directory setting in truffle-config.js

In truffle-config.js I have set contracts_build_directory:

var path = require('path');
module.exports = {
contracts_build_directory: path.join(__dirname, "app/src/web3/contracts"),

Now while trying to deploy I get the error message:
“At least one contract name must be provided to add.”

oz skips the step asking for the contract name. Seems like it looks for the contract jsons only in “/build/contracts”

@openzeppelin/cli”: “^2.7.1”,
node: 13.2

Issue posted in https://github.com/OpenZeppelin/openzeppelin-sdk/issues/1480

1 Like

Hi @vikram,

In the OpenZeppelin CLI project.json file the default artifactsDir is build/contracts.

We can specify the required artifactsDir to use:


  "manifestVersion": "2.2",
  "contracts": {},
  "dependencies": {},
  "name": "rc",
  "version": "1.0.0",
  "compiler": {
    "compilerSettings": {
      "optimizer": {
        "enabled": false,
        "runs": "200"
    "typechain": {
      "enabled": false
    "manager": "openzeppelin",
    "solcVersion": "0.5.16",
    "artifactsDir": "mybuilddir",
    "contractsDir": "contracts"
  "telemetryOptIn": false

When using OpenZeppelin CLI with Truffle, then artifactsDir should match contracts_build_directory in the Truffle config
See Truffle documentation for Truffle config:

I originally closed the GitHub Issue (https://github.com/OpenZeppelin/openzeppelin-sdk/issues/1480) as a question, but have reopened as I couldn’t find documentation on using artifactsDir

It would have been wonderful if oz could read the contracts_build_directory from truffle config and set the artifactsDir in .openzeppelin/project.json

1 Like

Hi @vikram,

I have added that feedback to the Issue.

Hopefully you can configure your setup manually. Let me know if you have any questions.

1 Like

A post was split to a new topic: “networks” entry not added to the contract json after npx oz create when chaning the artifactsDir in .openzeppelin/project.json