[Newbie Question] - Invalid 'use'. Unbound module: '0x1::Debug'

Hi,

I’m new to Move and following this tutorial, but somehow I’m unable to execute this script. I’m using move-cli from the latest master branch.

    script {
        // Import the Debug module published at account address 0x1.
        // 0x1 is shorthand for the fully qualified address
        // 0x00000000000000000000000000000001.
        use 0x1::Debug;

        const ONE: u64 = 1;

        fun main(x: u64) {
            let sum = x + ONE;
            Debug::print(&sum)
        }
    }

This is the command I’m using when trying to run the script:

move-cli run demo1/src/scripts/script1.move

This is the error message I get:

error: 

   ┌── demo1/src/scripts/script1.move:5:9 ───
   │
 5 │     use 0x1::Debug;
   │         ^^^^^^^^^^ Invalid 'use'. Unbound module: '0x1::Debug'
   │

error: 

    ┌── demo1/src/scripts/script1.move:11:9 ───
    │
 11 │         Debug::print(&sum)
    │         ^^^^^ Unbound module alias 'Debug'
    │

Regards,

Hi @brakmic,
Sorry that this isn’t working for you. A couple of questions that might help us diagnose the issue:

  • Did you run the cargo install command shown in the tutorial?
  • Could you share the git hash of the version you are using? I just tried with eb4fad3f9c49a03760f89a91d82ccd96fa2a11d0 and didn’t encounter any problems.

Sam

1 Like

Hi @sblackshear,

I’ve installed the binaries by following the tutorial from here. Not sure if there is any difference if I use the scripts from there (/scripts/dev_setup.sh) instead of cargo install --git https://github.com/libra/libra move-cli.

However, I just deleted everything and reinstalled move-cli via cargo install.

And there seems to be a difference between execution of move-cli and move. Until now, the only binary available in my $HOME/.cargo/bin was move-cli (and I don’t really get the difference between move-cli and move). But after I installed the packages via cargo install the other binary, move, became available as well. And I can now run the script with move. However, trying to do the same with move-cli still returns the same error.

Many thanks for your help.

At some point, we renamed the binary from move-cli to move, so I think your move-cli binary is an artifact of an earlier installation that may not work with the current Diem branch. I think if you remove the move-cli binary (note that cargo install does not do this for you) and use the move one, everything should work as expected.

1 Like

there is no code of Debug.move in this tutorial: https://developers.diem.com/docs/move/move-tutorial-creating-coins

script {

use 0x1::Debug;
use 0x2::Coin;

fun main() {
    let coin = Coin::mint(100);

    Debug::print(&Coin::value(&coin));

    Coin::burn(coin);
}

}

and I have searched it in github and found this one: https://github.com/diem/diem/blob/master/language/diem-framework/nursery/Debug.move
but the conent of func print is empty:

address 0x1 {

/// Module providing debug functionality.
module Debug {
native public fun print(x: &T);

native public fun print_stack_trace();

}

}

then I copy this file Debug.move into our local folder toycoin/src/modules, and run:

move publish src/modules --ignore-breaking-changes
$move run src/scripts/test-burn.move

there is no errors any more, but neigher any output.

so, I have no idea how to get the same output [debug] 100 as shown in the demo:

$ move run src/scripts/test-burn.move
[debug] 100

There should be no need to manually publish a Debug module. Debug is a Move standard library module, so it is automatically included in the default CLI mode.

Can you identify the point in the tutorial when you see an unexpected error + post the git hash you installed the CLI from?

Thanks a lot for your reminding that Debug is a Move standard library module.
I delete the Debug.move I added into our local folder toycoin/src/modules, then
move clean move publish src/modules
$ move run src/scripts/test-burn.move
[debug] 100

It works now. Great thanks again!

At first, I install move-cli following this guide:
https://developers.diem.com/docs/move/move-tutorial-creating-coins
but it failed:

$ cargo install --git GitHub - diem/diem: Diem’s mission is to build a trusted and innovative financial network that empowers people and businesses around the world. move-cli
Compiling subtle v2.4.0
error[E0210]: type parameter T must be used as the type parameter for some local type (e.g., MyStruct<T>)
→ /Users/wenke/.cargo/registry/src/github.com-1ecc6299db9ec823/subtle-2.4.0/src/lib.rs:513:6
|
513 | impl From<CtOption> for Option {
| ^ type parameter T must be used as the type parameter for some local type
|
= note: only traits defined in the current crate can be implemented for a type parameter

error: aborting due to previous error

For more information about this error, try rustc --explain E0210.
Compiling core-foundation-sys v0.8.2
error: could not compile subtle.
warning: build failed, waiting for other jobs to finish…
error: failed to compile move-cli v0.1.0 (https://github.com/diem/diem#e2ae98e9), intermediate artifacts can be found at /var/folders/sk/4bwcy4nj24s02zkgcw0194rm0000gn/T/cargo-install8IOX1c

Caused by:
build failed

Then I change to this guide:
https://developers.diem.com/docs/core/run-local-network/

git clone git@github.com:diem/diem.git cd diem
./scripts/dev_setup.sh source ~/.cargo/env
$ cargo run -p diem-node – --test

this time, every thing goes well.

Then, I retry the demo in https://developers.diem.com/docs/move/move-tutorial-creating-coins( first delete Debug.move I added before)
cd ../toycoin rm src/modules/Debug.move
move clean move publish src/modules
$ move run src/scripts/test-burn.move
[debug] 100

Now, it works. Thanks.

1 Like