unresolved import `crate::sys` on rust project building - rust

I am working on the Solana contract with rust language.
When I execute cargo build, it returns ok result.
But when I execute cargo +bpf build --target bpfel-unknown-unknown --release, it returns below the error console.
error[E0432]: unresolved import `crate::sys`
--> /home/ubuntu/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.2/src/sockaddr.rs:5:12
|
5 | use crate::sys::{
| ^^^
| |
| unresolved import
| help: a similar path exists: `crate::socket::io::sys`
error[E0432]: unresolved imports `crate::sys`, `crate::sys`
--> /home/ubuntu/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.2/src/socket.rs:21:12
|
21 | use crate::sys::{self, c_int, getsockopt, setsockopt, Bool};
| ^^^ ^^^^ no `sys` in the root
| |
| unresolved import
| help: a similar path exists: `crate::socket::io::sys`
...
Please let me know if you faced this kinda issue before.

On-chain programs are limited in what resources they can access. For example, you can't access the internet or filesystem. Your program seems to be relying on some of these forbidden packages.
Here's more info from the documentation about using rand, which is also not allowed: https://docs.solana.com/developing/on-chain-programs/developing-rust#depending-on-rand

Related

Kitties tutorial part 1 build is failing with unresolved import for sc_client_api RemoteBackend, anyone faced this issue?

I just followed the tutorial, I am at the first
cargo build --release
This is the error I am getting, any idea why this would happen?
error[E0432]: unresolved import `sc_client_api::RemoteBackend`
--> node/src/service.rs:4:39
|
4 | use sc_client_api::{ExecutorProvider, RemoteBackend};
| ^^^^^^^^^^^^^
| |
| no `RemoteBackend` in the root
| help: a similar name exists in the module: `StateBackend`
I solved this by removing RemoteBackend from the import at node/src/service.rs.
Just change the line (for me it was Line 4) at node/src/service.rs from
use sc_client_api::{ExecutorProvider, RemoteBackend};
to
use sc_client_api::ExecutorProvider;
While working with the tutorial cargo build --release resulted in the following error message:
error[E0432]: unresolved import `sc_client_api::RemoteBackend`
--> node/src/service.rs:4:39
|
4 | use sc_client_api::{ExecutorProvider, RemoteBackend};
| ^^^^^^^^^^^^^
| |
| no `RemoteBackend` in the root
| help: a similar name exists in the module: `StateBackend`
The help message provided some clue as to what was happening. Checking the node/src/service.rs file, I found that RemoteBackend was never referenced anywhere else in the file. So I simply removed it from the imports, and the build process was completed successfully.

nginx audio track for hls module installation

I started to configure a setup with nginx audio track module and I encountered a few problems.
First of all, I started from the official documentation.
I followed the requirements and installed ffmpeg.
As far as I can see, the available libs are:
/usr/lib/x86_64-linux-gnu/libavformat.so.58
/usr/lib/x86_64-linux-gnu/libavutil.so.56
/usr/lib/x86_64-linux-gnu/libavcodec.so.58
When I run make install the following output is generated:
/root/dev/nginx-audio-track-for-hls-module/ngx_http_aac_module.c: In function ‘ngx_http_aac_extract_audio’:
/root/dev/nginx-audio-track-for-hls-module/ngx_http_aac_module.c:156:5: error: ‘av_register_all’ is deprecated [-Werror=deprecated-declarations]
156 | av_register_all();
| ^~~~~~~~~~~~~~~
In file included from /root/dev/nginx-audio-track-for-hls-module/ngx_http_aac_module.h:6,
from /root/dev/nginx-audio-track-for-hls-module/ngx_http_aac_module.c:1:
/usr/include/x86_64-linux-gnu/libavformat/avformat.h:2050:6: note: declared here
2050 | void av_register_all(void);
| ^~~~~~~~~~~~~~~
/root/dev/nginx-audio-track-for-hls-module/ngx_http_aac_module.c:210:5: error: ‘avcodec_copy_context’ is deprecated [-Werror=deprecated-declarations]
210 | avcodec_copy_context(output_audio_stream->codec, input_audio_stream->codec);
| ^~~~~~~~~~~~~~~~~~~~
In file included from /root/dev/nginx-audio-track-for-hls-module/ngx_http_aac_module.h:5,
from /root/dev/nginx-audio-track-for-hls-module/ngx_http_aac_module.c:1:
/usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:4235:5: note: declared here
4235 | int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src);
This is only a short sample, there are many with the same error message.

Error on installing RISCV toolchain on Ubuntu 20.10

I am trying to install riscv-toolchain on ubuntu 20.10. I got the error while .buidl.sh executes
Configuring project riscv-isa-sim
Building project riscv-isa-sim
./fesvr/dtm.cc: In member function ‘uint32_t dtm_t::get_xlen()’:
../fesvr/dtm.cc:488:16: error: ‘runtime_error’ is not a member of ‘std’
488 | throw std::runtime_error("FESVR DTM Does not support 128-bit");
| ^~~~~~~~~~~~~
../fesvr/dtm.cc:505:14: error: ‘runtime_error’ is not a member of ‘std’
505 | throw std::runtime_error("FESVR DTM can't determine XLEN. Aborting");
| ^~~~~~~~~~~~~
../fesvr/dtm.cc:506:1: warning: control reaches end of non-void function [-Wreturn-type]
506 | }
| ^
std::runtime_error is defined in stdexcept. normally you are missing #include <stdexcept>. However normally, this modification was done in the riscv-isa-sim 7 months ago. you are probably not using the last version.

Why are multiple imports from the Hyper crate failing?

I'm working on a very simple HTTP client in Rust, built on top of the hyper (GitHub, crates.io) crate.
When I try to replicate the examples/client.rs file in a new Cargo project using cargo build (as well as using rustc src/main.rs), I get multiple errors caused by failed imports from hyper.
Here's the top of my main.rs:
extern crate hyper;
use hyper::client::{Client, Request, Response, DefaultTransport as HttpStream};
use hyper::header::Connection;
use hyper::{Decoder, Encoder, Next};
The rest of the file is, except for some comments, identical to the examples/client.rs file from the hyper repository.
At compile time, I get the following errors:
src/main.rs:10:48: 10:78 error: unresolved import `hyper::client::DefaultTransport`. There is no `DefaultTransport` in `hyper::client` [E0432]
src/main.rs:10 use hyper::client::{Client, Request, Response, DefaultTransport as HttpStream};
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/main.rs:10:48: 10:78 help: run `rustc --explain E0432` to see a detailed explanation
src/main.rs:12:13: 12:20 error: unresolved import `hyper::Decoder`. There is no `Decoder` in `hyper` [E0432]
src/main.rs:12 use hyper::{Decoder, Encoder, Next};
^~~~~~~
src/main.rs:12:13: 12:20 help: run `rustc --explain E0432` to see a detailed explanation
src/main.rs:12:22: 12:29 error: unresolved import `hyper::Encoder`. There is no `Encoder` in `hyper` [E0432]
src/main.rs:12 use hyper::{Decoder, Encoder, Next};
^~~~~~~
src/main.rs:12:22: 12:29 help: run `rustc --explain E0432` to see a detailed explanation
src/main.rs:12:31: 12:35 error: unresolved import `hyper::Next`. There is no `Next` in `hyper` [E0432]
src/main.rs:12 use hyper::{Decoder, Encoder, Next};
^~~~
src/main.rs:12:31: 12:35 help: run `rustc --explain E0432` to see a detailed explanation
src/main.rs:53:6: 53:40 error: trait `hyper::client::Handler` is not in scope [E0405]
src/main.rs:53 impl hyper::client::Handler<HttpStream> for Dump {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/main.rs:53:6: 53:40 help: run `rustc --explain E0405` to see a detailed explanation
src/main.rs:53:6: 53:40 help: you can to import it into scope: `use hyper::server::Handler;`.
In case it may contribute to this issue, here are the contents of my Cargo.toml:
name = "my_project"
version = "0.0.1"
authors = ["email#example.com"]
[dependencies]
getopts = "0.2"
hyper = "0.9.6"
[[bin]]
name = "my_project"
Some of the imports are actually working, so assuming the example in the repository is up to date, I really can't tell what's wrong. The source files of the crate look like they expose the involved types, but I'm very new to Rust so I may be misreading the files.
You are using examples from the master branch that do not work with 0.9.6 version. You can take a look at examples on the branch 0.9.6 or make cargo use hyper direct from github, writing on Cargo.toml:
[dependencies]
hyper = {git = "https://github.com/hyperium/hyper"}

Tanuki upgrade: JVM configuration version

I am currently using the old tanuki version 3.2.3, and moving to the newest one 3.5.25.
I followed the upgrading documentation: modify my script, change the jar and binary wrapper… etc.
Debugging during the JVM launch, I could see that every additional param defined in my wrapper.conf appears as follows:
DEBUG | wrapper | 2014/07/03 13:41:08 | Command[0] : java
DEBUG | wrapper | 2014/07/03 13:41:08 | Command[1] : -Djava.system.class.loader=myClass
DEBUG | wrapper | 2014/07/03 13:41:08 | Command[2] : -Dcom.sun.management.jmxremote=true
But there are some extra params, and I don´t know where they are set up:
DEBUG | wrapper | 2014/07/03 13:41:08 | Command[30] : -Dwrapper.version=3.2.3
DEBUG | wrapper | 2014/07/03 13:41:08 | Command[31] : -Dwrapper.native_library=wrapper
DEBUG | wrapper | 2014/07/03 13:41:08 | Command[32] : -Dwrapper.service=TRUE
DEBUG | wrapper | 2014/07/03 13:41:08 | Command[33] : -Dwrapper.cpu.timeout=10
Specially annoying is the version one. It is still the old one. Does anybody know where I could change this configuration params?
Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
Thanks!
Best
Tanuki library was imported by a dependency. Doesn´t matter the properties in my project, they will be overwritten.
The solution: using maven discard these dependencies or overwrite them.

Resources