6

I'm trying to use Truffle to test some contracts by following their docs. As specified, I have installed truffle, testrpc, created the migration contract and worked fine.

Ran truffle compile

$ truffle compile
Compiling ./contracts/User1.sol...
Compiling ./contracts/User2.sol...
Compiling ./contracts/Registry.sol...

Writing artifacts to ./build/contracts

and truffle migrate

$ truffle migrate
Using network 'development'.

Network up to date.

and both seemed ok.

The problem was running trying to interact with a contract using truffe console

$ truffle console
Unexpected error: Cannot provision contracts while instantiating the console.
: Unexpected end of JSON input
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:213724:27
    at tryToString (fs.js:456:3)
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:443:12)
truffle(development)> User1.deployed()
ReferenceError: User1 is not defined

If it helps, the structure of the dir is

├── build
│   ├── Icon\r
│   └── contracts
│       ├── ConvertLib.json
│       ├── User1.json
│       ├── Icon\r
│       ├── MetaCoin.json
│       ├── Migrations.json
│       ├── User2.json
│       ├── Registry.json
│       ├── Storage.json
├── contracts
│   ├── User1.sol
│   ├── Migrations.sol
│   ├── User2.sol
│   ├── Registry.sol
├── migrations
│   ├── 1_initial_migration.js
│   ├── 2_user1_migration.sol
│   ├── 3_user2_migration.sol
│   ├── 4_registry_migration.sol
│   └── Icon\r
├── test
│   ├── Icon\r
│   ├── TestMetacoin.sol
│   └── metacoin.js
└── truffle.js

How can I fix this?

3 Answers 3

1

I asked on Truffle's Gitter and the way to solve it was by creating another directory and changing the project there. Also, my default documents folder is on Google Drive and I've found that whenever I had issues like this (also had a private ethereum blockchain that would't start), moving it to a folder which is not on Google Drive (Desktop, etc.) would make it work.

Not sure if this is really a thing or not but could be worth a try if you're stuck in the same situation.

2
  • "my default documents folder is on Google Drive" bahah
    – 0TTT0
    Commented Feb 20, 2018 at 3:36
  • Thanks. Saved lot of debugging on my side. Don't know why Google Drive syncing should be an issue. Commented Apr 3, 2019 at 0:58
0

That may be because you do not have the @truffle/contract package. I had the same problem. After running sudo npm install -g @truffle/contract the problem was solved. Check more at https://github.com/trufflesuite/truffle/tree/master/packages/contract.

0

thanks mcansado, i had the same problem with Dropbox. no way to see the contracts deployed in Ganache, until moving from Dropbox to local disk folder. seems to be a problem when using RPC service with Dropbox or Google Drive...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.