EOSIO / welcome

Documentation that covers EOSIO Overview, Getting Started and Protocol documents
38 stars 53 forks source link

Followed instructions, can't set contract #184

Closed L1Cafe closed 4 years ago

L1Cafe commented 4 years ago

Following the instructions here https://developers.eos.io/welcome/latest/getting-started/smart-contract-development/hello-world after following all the previous steps, gets me stuck on this step:

$ cleos set contract hello CONTRACTS_DIR/hello -p hello@active

When I try to run that command, I get the following message:

terminating with uncaught exception of type std::runtime_error: collate_byname<char>::collate_byname failed to construct for 
Aborted

However, I found out I can continue the tutorial by running these commands instead:

$ cleos set code hello hello.wasm -p hello@active
$ cleos set abi hello hello.abi -p hello@active

I'm a newcomer and don't know much about EOS or smart contracts (I'm doing my best), but I think the above is correct. Is there a mistake in the documentation or am I doing something wrong?

Now, after running those two commands, I can just run:

$ cleos push action hello hi '["bob"]' -p bob@active

And continue the tutorial.

dixia commented 4 years ago

hi @L1Cafe thanks for report and other good contributions

If you read a text above the command, if you should find the instructions below:

Replace "CONTRACTS_DIR" in the command below with the absolute path to your contracts directory

So that CONTRACTS_DIR is meant to be replaced with the path. But I do think it is a good idea to update the text, the latest software probably no longer required this

L1Cafe commented 4 years ago

Thanks for your comment @dixia , I'm aware that I have to set the correct folder, and I feared I would be misunderstood for my wording, but, yes, I did set the corerect folder.

In fact, it works because with the other two commands, manually setting the wasm and the abi works (and this also requires a correct path), while the other command just gives an error.

For the sake of completeness, this is happening on Ubuntu 18.04 with the official EOS repos installed (so I didn't build the tools manually myself, I simply ran the automatic installer script).

dixia commented 4 years ago

thanks for more details @L1Cafe we will try to reproduce

dixia commented 4 years ago

Hi @L1Cafe,

Could you provide the exact command you were using? and the version of cleos and nodeos?

We did try to reproduce but could not

bobgt commented 4 years ago

I tried to reproduce the error message but I could not.

L1Cafe commented 4 years ago

My apologies, I will record a screencast later today and give you further details and version numbers for this issue with my current version. I will also try updating my tools, perhaps that issue has been solved in later versions.

L1Cafe commented 4 years ago

After trying and retrying, I think I figured out what the problem is.

This is what my development directory looks like:

.
├── docker
│   ├── Dockerfile
│   ├── eosio-wallet
│   │   ├── config.ini
│   │   └── default.wallet
[...]
├── EOS
│   └── contracts
│       ├── hello.abi
│       ├── hello.cpp
│       └── hello.wasm
[...]

The line in the tutorial says: cleos set contract hello CONTRACTS_DIR/hello -p hello@active, and the way I was running it was (while inside EOS/contracts):

$ cleos set contract hello hello -p hello@active

Since the documentation says "CONTRACTS_DIR/hello" but I was already in the contracts dir, I simply removed the folder and indicated "hello" (the second "hello" there) as a filename. I thought this would tell cleos to set the contracts for the files hello.wasm and hello.abi, but what was actually happening is that apparently cleos expects each contract to be in its own folder, so what was actually trying to read was hello/hello.wasm and hello/hello.abi.

This is the reason why setting the contract manually using cleos set code and cleos set abi worked: Setting it like this receives absolute paths, not names of folders.

Creating a new hello directory, so it looks like this, fixed it and allowed me to run the command as instructed in the manual:

.
└── contracts
    └── hello
        ├── hello.abi
        ├── hello.cpp
        └── hello.wasm

Perhaps the documentation could be made a bit clear to clarify that cleos set contract expects a directory name inside which you're supposed to place .abi and .wasm files?

Additionally, and unrelated (but I don't know where to ask), is there a community channel like IRC, Rocket Chat, Mattermost, Telegram, or something similar where more general questions can be asked without having to open issues?

Many thanks for your interest, feel free to close this now, unless you want to keep it around as a reminder for updating documentation.

YaroShkvorets commented 4 years ago

Perhaps the documentation could be made a bit clear to clarify that cleos set contract expects a directory name inside which you're supposed to place .abi and .wasm files?

That's what it says though:

Replace "CONTRACTS_DIR" in the command below with the absolute path to your contracts directory.

L1Cafe commented 4 years ago

That's what it says though:

Replace "CONTRACTS_DIR" in the command below with the absolute path to your contracts directory.

Indeed, but if I tried to set the contracts directory to something like EOS/contracts, it would try setting EOS/contracts/contracts.abi and EOS/contracts/contracts.wasm, regardless of the filenames in that folder.

dixia commented 4 years ago

@L1Cafe You could give this telegram a try. it is pretty active. https://t.me/joinchat/DQRZHEPktgcLlyfbl-bDuQ.

YaroShkvorets commented 4 years ago

That's what it says though:

Replace "CONTRACTS_DIR" in the command below with the absolute path to your contracts directory.

Indeed, but if I tried to set the contracts directory to something like EOS/contracts, it would try setting EOS/contracts/contracts.abi and EOS/contracts/contracts.wasm, regardless of the filenames in that folder.

Technically, you were supposed to enter the absolute path to your contracts directory here: https://developers.eos.io/welcome/latest/getting-started/development-environment/before-you-begin/#step-3-enter-your-local-directory-below So the instructions would substitute CONTRACTS_DIR with your specific path, ready for copy-paste. Very convenient but quite confusing if you missed this step, I agree.

dixia commented 4 years ago

Perhaps the documentation could be made a bit clear to clarify that cleos set contract expects a directory name inside which you're supposed to place .abi and .wasm files?

So this tutorial does assume you created a folder called hello with the following prior steps :

mkdir hello
cd hello

In case a different folder name is used, then the wasm and abi files can be specified with this command link options:

cleos set contract [OPTIONS] account [contract-dir] [wasm-file] [abi-file]

I will create an issue on cleos repo to clarify this. Thanks for the feedback!