Anki Forums

Cargo-raze warning message

I tried to add a rust dependency
backtrace = "0.3"

As indicated I tried to use update.py. I went to cargo and run python3 update.py

I get

python3 update.py
Updating crates.io index
Updating git repository https://github.com/ankitects/reqwest.git
Updating git repository https://github.com/ankitects/hyper-timeout.git
Updating git repository https://github.com/ankitects/tokio-io-timeout.git
Traceback (most recent call last):
File “update.py”, line 127, in
run_cargo_raze()
File “update.py”, line 41, in run_cargo_raze
subprocess.run([“cargo-raze”], cwd="…", check=True)
File “/usr/lib/python3.8/subprocess.py”, line 489, in run
with Popen(*popenargs, **kwargs) as process:
File “/usr/lib/python3.8/subprocess.py”, line 854, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File “/usr/lib/python3.8/subprocess.py”, line 1702, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: ‘cargo-raze’

What can I do to try to add dependencies?

If I just try to run test now, I get an error message because related to backtrace

The goal would be to get backtrace in error message. Becasue right now, it’s hard to understand error message since the backtrace only show the python part

Did you install cargo-raze as mentioned in the readme?

That said, I don’t really recommend this path. Backtraces are not available in release builds, and are expensive to generate on Macs. In many cases the code that returns an error should be fairly obvious when following the code flow, and when that’s not the case, we should update the code to return a more specific error, or attach some context.

I’ve not re read the readme recently no.

I do understand there is very good reason not to deploy this in every day anki. However, I do believe that keeping it as an extra branch to use when debugging could be really useful. At least for the rust PR I made a few days ago, and more generally when I update add-ons and try to figure out which rust hypothesis I did not respect.

I’ve not yet understood how to understand the code flow in rust honestly. Probably I should figure out how to use a proper IDE for rust and that may be a better solution. But I often loose time figuring out where a function called by python is defined (using grep usually), and, more complex, where the methods called in rust are defined. My current understanding is that sometime the method of a type T is not defined in the same file as T, which makes finding it slightly complex.
(To be clear, Anki was my only reason to look at rust, so I’m not at ease yet)

development.md briefly describes how to set up VS Code to work with Rust. I recommend you spend a bit of time doing that, as you can then use code navigation features like clicking on a function to jump to its definition.

If you just want to figure out the call tree of a particular inner function in development, throw a panic!() in it and run with RUST_BACKTRACE=1