deployProxy giving Unexpected token error

I am having trouble deploying an upgradeable contract. The contract deploys just fine if I deploy regularly, but having trouble reading some artifact when doing deployProxy. Any ideas?

:computer: Environment
Truffle v5.3.4 (core: 5.3.4)
Solidity - 0.6 (solc-js)
Node v12.18.3
Web3.js v1.3.5

:memo:Details

SyntaxError: Unexpected token . in JSON at position 1
    at JSON.parse (<anonymous>)
    at C:\...\npm\node_modules\@openzeppelin\truffle-upgrades\src\utils\validations.ts:25:41
    at Array.map (<anonymous>)
    at readArtifacts (C:\...\npm\node_modules\@openzeppelin\truffle-upgrades\src\utils\validations.ts:25:27)
    at Object.validateArtifacts (C:\...\npm\node_modules\@openzeppelin\truffle-upgrades\src\utils\validations.ts:16:21)
    at Object.deployImpl (C:\...\npm\node_modules\@openzeppelin\truffle-upgrades\src\utils\deploy-impl.ts:29:23)
    at deployProxy (C:\...\npm\node_modules\@openzeppelin\truffle-upgrades\src\deploy-proxy.ts:46:16)
    at module.exports (C:\...\2_deploy_contracts.js:5:3)
    at Migration._deploy (C:\...\npm\node_modules\truffle\build\webpack:\packages\migrate\Migration.js:79:1)
    at Migration._load (C:\...\npm\node_modules\truffle\build\webpack:\packages\migrate\Migration.js:61:1)
    at Migration.run (C:\...\npm\node_modules\truffle\build\webpack:\packages\migrate\Migration.js:212:1)
    at Object.runMigrations (C:\...\npm\node_modules\truffle\build\webpack:\packages\migrate\index.js:150:1)
    at Object.runFrom (C:\...\npm\node_modules\truffle\build\webpack:\packages\migrate\index.js:110:1)
    at Object.runAll (C:\...\npm\node_modules\truffle\build\webpack:\packages\migrate\index.js:114:1)
    at Object.run (C:\...\npm\node_modules\truffle\build\webpack:\packages\migrate\index.js:79:1)
    at runMigrations (C:\...\npm\node_modules\truffle\build\webpack:\packages\core\lib\commands\migrate.js:263:1)
    at Object.run (C:\...\npm\node_modules\truffle\build\webpack:\packages\core\lib\commands\migrate.js:228:1)
    at Command.run (C:\...\npm\node_modules\truffle\build\webpack:\packages\core\lib\command.js:140:1)

Truffle v5.3.4 (core: 5.3.4)
Node v12.18.3

:1234: Code to reproduce
deploy contract:

const { deployProxy } = require('@openzeppelin/truffle-upgrades');
var token = artifacts.require("Token");

module.exports = async function(deployer) {
  await deployProxy(token , [], { deployer, initializer: 'init' });
};

Can you share the list of files found in your artifacts directory? I’m assuming there’s a file in there that is not a JSON file, but I don’t know what it’s doing there.

1 Like

Thanks for the prompt response! I started playing around with it this morning and it magically worked.

It seems to work if I delete the build/contracts folder right before deploying…sometimes. I am on a windows machine and perhaps it is picking up a hidden windows file or something.

Anyway, now I am getting a new error: " Unable to update lock within the stale threshold".

I see there is a thread about that so I will comment there.

1 Like

Ok. I’ve published a new version of the Truffle plugin that will filter out non-JSON files found in the artifacts directory so this shouldn’t happen again.

2 Likes

im hitting same issue on windows, unexpected token in multiple locations ‘;’

1 Like

Im sorry how did you solve this? I cant delete that folder because it has code in it right?!

1 Like

the build/contracts folder is rebuilt each time you compile (e.g., before each deployment). Just don’t delete the main contracts folder!

2 Likes

oh right thanks, im a noob and there’s not a lot of info for people using windows out there!

1 Like

I can’t even remember what the thing was that solved it for me because I tried a huge number of things (some of which are not recommended, but like you said, doing this on windows can be a pain):

removing the build/contracts folder before each run
shutting off syncing programs while deploying
upgrading the newest version of the truffle plugin
commenting out portions of plugin code in libraries that were throwing inexplicable errors
making sure my folders had the proper access permissions
setting “skipDryRun” in truffle config to “true”
playing with just about every other truffle config parameter
removing ropsten.json.lock file manually
… and more

1 Like

Wow thanks for the run down deffo save me some time being able to use your references, I’m off to bed now but I’ll try some of things again tomorrow

Cheers

1 Like