sui
sui copied to clipboard
Sui Move VSCode Language Support Plugin gives false error in Hello World Program, builds fine
Following the standard hello world tutorial yields an error in using the official Move VS Code Plugin gives:
Compilation in test mode requires passing the UnitTest module in the Move stdlib as a dependency
for the module definition hello world.
Yet the hello world package builds fine.
Steps to Reproduce Issue
Following step by step introduction of Move Book/Hello World
e.g.
- Standard Setup Sui
- Install VSCode Plugin Move v0.0.3
Expected Result
No errors, no warnings.
Actual Result
hello_world.move
Compilation in test mode requires passing the UnitTest module in the Move stdlib as a dependency
What is this test mode?
System Information
- OS: Mac 14.4.1
- sui-client 1.24.0
Code
/// The module `hello_world` under named address `hello_world`.
/// The named address is set in the `Move.toml`.
module hello_world::hello_world {
// Imports the `String` type from the Standard Library
use std::string::String;
/// Returns the "Hello, World!" as a `String`.
public fun hello_world(): String {
b"Hello, World!".to_string()
}
}
This should not be happening if Sui framework (or just Move stdlib) is correctly specified as a dependency in the Move.toml file.
Context - currently, we need to build all projects in the VSCode plugin in "test mode". In this mode, all test code is included into the project (otherwise, in non-test mode, it is removed during compilation). Perhaps incorrectly, but I consider this a minor inconvenience as Mysten's VSCode plugin is meant for development of Sui smart contracts and any contract beyond the most trivial ones would already require inclusion of Sui framework code as a dependency.
All that being said, I followed the instructions from https://move-book.com/your-first-move/hello-world.html. up to the Compiling the Package chapter and I don't see any errors...
Thank you for your prompt support and the context; I much appreciated it. I've just switched my VS Code Move Extension version to v0.0.2, and the error disappears.
To be clear, it builds perfectly fine; it's just the red underlining / flagging an error by the move language support.
I've attached the compressed folder of my project state. Yet it's probably something with my setup. Let me know if I can supply other setup details to reproduce the behaviour. hello_world.zip
Please feel free to close this issue at your judgment.
I tried it on my side with code attached and cannot repro... Let's try a few more things (I am assuming you did not change any options for the VSCode plugin, such as location of the Move analyzer binary, etc.):
- uninstall Move VSCode plugin
- quit VSCode
- remove VSCode extension from the filesystem: remove directory representing the extension (starting with
mysten) from the~/.vscode/extensions/directory - remove Move analyzer binary from
~/.sui/bin/directory - start VSCode
- install the newest version of the VSCode extension from the marketplace
- restart VSCode
The issue persists – with the v0.0.3 version of the Move VSCode plugin.
Correct, I did not change any options – default installation via the VSCode GUI. Followed your clean install instructions meticulously, yet the issue appears again.
When I switch to the v0.0.2 version of the Move VSCode plugin, the false positive error disappears.
This is really strange and I would like to get to the bottom of this if possible. Could you perhaps restart VSCode and let me know what the extension logs are saying (View->Output menu and then both Move and Move Client options from the drop-down menu on the right-hand side).
Could you also please list the content of the ~/.vscode/extensions directory?
Certainly, here are the outputs as screenshots:
Move Output
Move Client
Move Language Server
- also found this
Extensions Directory
Nothing looks out of ordinary other than perhaps that you seem to also have movebit's extension files in your ~/.vscode/extensions directory. I wonder if this extension is actively installed in your VSCode instance - if it is, perhaps you can uninstall it and then (regardless if it was actively installed or not) remove the movebit-sui-move-analyzer-1.1.6 directory from ~/.vscode/extensions.
Another thing to try (if you are not yet too annoyed with this - and my apologies, I am grasping at straws here...) is to change Sui dependency in hello_world's manifest file to the local one. Please clone Sui to your main directory (unless you already have it there):
cd ~/
git clone https://github.com/MystenLabs/sui.git
And replace Sui dependency in the manifest file with:
Sui = { local = "/Users/gordonkoehn/sui/crates/sui-framework/packages/sui-framework/" }
Good Morning again. No apologies are needed; I am happy to contribute to smoothening the start of the next ones with Sui in VSCode.
-
sui-move-analyzer: I probably did install it when I first searched for a language support plugin. Wasn't sure which was the official one, this one had more downloads. It was disabled the whole time during our debugging. Uninstalled it now and deleted
movebit.sui-move-analyzer-1.1.6. I closed VSCode and restarted the Move plugin, but the false postie error persists. -
changing the Sui dependency to local: Cloned as described, edited my
.tomlsee below. I closed and reloaded my VSCode. Here is the output of myOutput/Move Extension; see below. Error persists.
I have the same issue with Move extension v0.0.3 Compilation in test mode requires passing the UnitTest module in the Move stdlib as a dependency. I followed the steps above, but the error persists
Could you try running sui move test (assuming sui command is on your path) in the hello_world directory and let me know what happens?
Works, perfectly fine.
Let's see if you are using move-analyzer binary from the expected location.
- quit VSCode
- move Move analyzer binary from
~/.sui/bin/directory some temporary one - start VSCode
You should get a different error now due to missing Move analyzer binary. Please let me know if you did (and restore Move analyzer binary to ~/.sui/bin/)
I closed VSCode, and deleted ~.sui/bin/move-analyzer accidentally, yet it came back upon opening VSCode. No errors thrown upon opening VSCode.
That false positive error persists.
I still can't shake of a suspicion that your VSCode somehow picks up a wrong move-analyzer binary (though I am not sure how this could be possible). Let's try something else to see if this is what's happening.
- build a new move-analyzer binary (I am assuming you have Rust toolchain installed):
cargo install --git https://github.com/MystenLabs/sui move-analyzer
- In "Code->Settings->Settings" choose "Workspace", and then from drop-down menu choose "Extensions" and then "Move"
- change value of
Server:Pathoption fromnull(which is what it should be) to "~/.cargo/bin" (keep the double-quotes) - Restart VSCode
YES!! Move v0.0.3 works for my hello world !
I followed your suggestions, but I assume you meant "~/.cargo/bin/move-analyzer," not just "~/.cargo/bin". Adding the latter led to Move failing upon VSCode restart.
First, thanks for debugging this with me.
What did I do wrong upon installation? Do you have a guess what happened?
I followed your suggestions, but I assume you meant "~/.cargo/bin/move-analyzer," not just "~/.cargo/bin"
Yes, sorry for the imprecision
What did I do wrong upon installation? Do you have a guess what happened?
I honestly don't know. I plan to re-work the automated move-analyzer binary installation path in the extension soon, so hopefully next time you upgrade this is not going to be a problem.
This was a really weird one - I tried your own code with the same binary that is packaged with the v0.0.3 of the extension and I could not reproduce the problem. The only thing I was left thinking of was that somehow on your machine a different (earlier) version of move-analyzer was being picked up as I know the problem you reported but it was fixed before v0.0.2 and nothing I could see was indicating that it was re-introduced in v.0.0.3. An even more unlikely alternative was that indeed the analyzer bundled with v.0.0.3 did not work in your local setup. The last attempt to solve it was trying to address both these problems - provide an explicit custom path to the analyzer and have you work with the newest version.
In any case, my apologies for this - it's certainly not how we want developer experience to look like. Also, thank you for your patience! If you haven't lost it completely, I would ask you at some point to try a newer version (with a different move-analyzer installation path) to see if things work correctly.
Thanks for enhancing the sui development experience! I am happy to support; just let me know when I shall test the new version on my system.
Thank you for the context of what might have happened. I appreciated it.
Until the next version, Thanks for investigating this with me! Feel free to close this issue/tag for later.
@gordonkoehn , I realized that there might have been another problem and I was wondering if you'd be willing to give it a shot.
- remove custom Server:Path from "Workspace" settings in "Code->Settings->Settings" (you can remove the whole line containing value for this option once the editor opens)
- reinstall the newest version of the extension
- restart VSCode
Yes, this solves it as well!
What I did:
- I removed the custom path and set it to "null", as it was before our edits.
- Then, I updated the Move extension to the brand-new version, v1.0.2, and it worked.
- The 'Hello World' error is gone.
I verified that downgrading to v0.0.3 still gives the error in my current setup.
Thank you for the seamless fix; I can't wait to build on Sui at the Consensus24 Hackathon with this setup.
Please close this issue at your discretion.
v.1.0.2 of the extension finally solved the problem