How to start and debug Pyrsia Node using IDE
This tutorial describes how to start and debug Pyrsia using Microsoft Visual Code and IntelliJ IDEA.
Prerequisites
Before continuing please make sure that you have cloned and compiled the Pyrsia sources. For more information please see Developer Environment Setup. In this tutorial PYRSIA_HOME
refers to the Pyrsia repository folder.
IntelliJ IDEA Configuration
- Open the IDE and install Rust plugin. If you use IDEA Ultimate make sure Native Debugging Support plugin is installed.
- From the main menu select
File > Open
. Alternatively selectOpen
in theWelcome to IntelliJ IDEA
wizard and select thePYRSIA_HOME
folder. - When prompted to
Trust and Open Project 'pyrsia'?
selectTrust Project
. - From the project configuration combo box select
Edit Configuration
; then in the Configuration window, select+
orAdd New Run Configuration
. - Select
Cargo
from the list of supported configurations. - Rename the configuration to
Run Node
. - In the
Command
field past the following:
run --package pyrsia_node -- --pipeline-service-endpoint http://localhost:8080 --port 7888 --listen /ip4/0.0.0.0/tcp/44002
- Add the following vars to the
Environment Variables
:
DEV_MODE=on;
PYRSIA_ARTIFACT_PATH=/tmp/pyrsia/node;
RUST_LOG=pyrsia=debug,info;
- Point
Working Directory
to thePYRSIA_HOME
folder. - Confirm and save the configuration by pressing the
OK
button. In the event ofError: No Rust toolchain specified
go to theSettings/Preferences
, thenLanguages & Frameworks > Rust
, then selectDownloads via Rustup
. - Start the Pyrsia node by selecting
Run Node
from the configurations list and pressing theRun
button next to it. - IDEA Ultimate only. Start the debugging by selecting
Run Node
from the configurations list and pressingDebug
button. The debugging related features (e.g. breakpoints) are only available when Native Debugging Support plugin is installed.
Microsoft Visual Code Configuration
- Open the IDE and install rust-analyzer extension, CodeLLDB extension or C/C++ extension
- From the main menu select
File > Open Folder
. - When asked
Do you trust the authors of the files in this folder?
selectYes, I trust the authors...
. - From the main menu select
Run > Add Configuration..
, then from theSelect Debugger
combo box selectLLDB
. - When asked,
Cargo.toml was detected in this workspace...
, selectNo
. - In the newly created
launch.json
file, replace the generated configuration with the following:
{
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug executable 'pyrsia_node'",
"program": "${workspaceRoot}/target/debug/pyrsia_node",
"args": [
"-H", "0.0.0.0",
"-p", "7888",
"-L", "/ip4/0.0.0.0/tcp/44002"
],
"env": {
"DEV_MODE": "on",
"RUST_LOG": "pyrsia=debug,info"
},
"cwd": "${workspaceRoot}"
}
]
}
- Save the changes and start/debug the Pyrsia node by selecting
Run > Start Debugging
from the main menu.