My Cargo.toml contains this:
[package]
name = "p2pvpn"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rand = "0.8.5"
tuntap = "0.2.0"
When I run cargo check I've got this error:
Checking tokio-async-await v0.1.7
Checking tokio-threadpool v0.1.18
error[E0557]: feature has been removed
--> /home/tom/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-async-await-0.1.7/src/lib.rs:2:44
|
2 | #![feature(rust_2018_preview, async_await, await_macro, futures_api)]
| ^^^^^^^^^^^ feature has been removed
|
= note: subsumed by `.await` syntax
error[E0432]: unresolved import `std::await`
--> /home/tom/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-async-await-0.1.7/src/lib.rs:35:9
|
35 | pub use std::await as std_await;
| ^^^^^^^^^^^^^^^^^^^^^^^ no `await` in the root
Some errors have detailed explanations: E0432, E0557.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `tokio-async-await` due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
Should I rather select different version of tuntap crate or is there some different crate for managing tun/tap devices?
Related
I am trying to use GSL in Rust https://docs.rs/GSL/6.0.0/rgsl/ but am having trouble as I am very new to Rust. Every other crate I have tried to use just works by including the dependency in the Cargo.toml file. However, it doesn't seem to be this simple for this crate.
I have GSL installed and in Visual Studio 2022 I can successfully include it and I successfully built a program which uses functions from the library in C++.
#include <iostream>
#include <gsl/gsl_specfunc.h>
int main()
{
double k = 0.5;
double k_prime = sqrt(1 - k * k);
double K = gsl_sf_ellint_Kcomp(k, GSL_PREC_DOUBLE);
double K_prime = gsl_sf_ellint_Kcomp(k_prime, GSL_PREC_DOUBLE);
std::cout << K/K_prime << "\n";
}
I use IntelliJ as my Rust IDE, and I have a project with a Cargo.toml
[package]
name = "rust-gsl-test"
version = "0.1.0"
edition = "2021"
[dependencies]
GSL = "4.0"
In IntelliJ's terminal, when I type cargo build, I get
error: linking with `link.exe` failed: exit code: 1181
|
= note: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.33.31629\\bin\\HostX64\\x64\\link.exe" "/DEF:C:\\Users\\etcto\\AppData\\Local\\Temp\\rustckB
WI9y\\lib.def" "/NOLOGO" "C:\\Users\\etcto\\AppData\\Local\\Temp\\rustckBWI9y\\symbols.o" "D:\\GitHub\\rust-ellint\\target\\debug\\deps\\gsl_sys-0d1cd764caa3b2be.gsl_sys.59103b07-cgu.0
.rcgu.o" "D:\\GitHub\\rust-ellint\\target\\debug\\deps\\gsl_sys-0d1cd764caa3b2be.gsl_sys.59103b07-cgu.1.rcgu.o" "D:\\GitHub\\rust-ellint\\target\\debug\\deps\\gsl_sys-0d1cd764caa3b2be.
gsl_sys.59103b07-cgu.10.rcgu.o" "D:\\GitHub\\rust-ellint\\target\\debug\\deps\\gsl_sys-0d1cd764caa3b2be.gsl_sys.59103b07-cgu.11.rcgu.o" "D:\\GitHub\\rust-ellint\\target\\debug\\deps\\g
sl_sys-0d1cd764caa3b2be.gsl_sys.59103b07-cgu.12.rcgu.o" "D:\\GitHub\\rust-ellint\\target\\debug\\deps\\gsl_sys-0d1cd764caa3b2be.gsl_sys.59103b07-cgu.2.rcgu.o" "D:\\GitHub\\rust-ellint\
\target\\debug\\deps\\gsl_sys-0d1cd764caa3b2be.gsl_sys.59103b07-cgu.3.rcgu.o" "D:\\GitHub\\rust-ellint\\target\\debug\\deps\\gsl_sys-0d1cd764caa3b2be.gsl_sys.59103b07-cgu.4.rcgu.o" "D:
\\GitHub\\rust-ellint\\target\\debug\\deps\\gsl_sys-0d1cd764caa3b2be.gsl_sys.59103b07-cgu.5.rcgu.o" "D:\\GitHub\\rust-ellint\\target\\debug\\deps\\gsl_sys-0d1cd764caa3b2be.gsl_sys.5910
3b07-cgu.6.rcgu.o" "D:\\GitHub\\rust-ellint\\target\\debug\\deps\\gsl_sys-0d1cd764caa3b2be.gsl_sys.59103b07-cgu.7.rcgu.o" "D:\\GitHub\\rust-ellint\\target\\debug\\deps\\gsl_sys-0d1cd76
4caa3b2be.gsl_sys.59103b07-cgu.8.rcgu.o" "D:\\GitHub\\rust-ellint\\target\\debug\\deps\\gsl_sys-0d1cd764caa3b2be.gsl_sys.59103b07-cgu.9.rcgu.o" "D:\\GitHub\\rust-ellint\\target\\debug\
\deps\\gsl_sys-0d1cd764caa3b2be.3ehg95o16e12j0cb.rcgu.rmeta" "/LIBPATH:D:\\GitHub\\rust-ellint\\target\\debug\\deps" "/LIBPATH:C:\\Users\\etcto\\.rustup\\toolchains\\stable-x86_64-pc-w
indows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "gsl.lib" "gslcblas.lib" "D:\\GitHub\\rust-ellint\\target\\debug\\deps\\liblibc-33d50219ec2d56d1.rlib" "/LIBPATH:C:\\Users\\etct
o\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "std-fdaa63d6970be740.dll.lib" "C:\\Users\\etcto\\.rustup\\toolchains\\stable-x86_64-p
c-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-3f507ba7adac1c2a.rlib" "legacy_stdio_definitions.lib" "kernel32.lib" "advapi32.lib" "userenv.lib" "kerne
l32.lib" "ws2_32.lib" "bcrypt.lib" "msvcrt.lib" "legacy_stdio_definitions.lib" "/NXCOMPAT" "/LIBPATH:C:\\Users\\etcto\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\
\x86_64-pc-windows-msvc\\lib" "/OUT:D:\\GitHub\\rust-ellint\\target\\debug\\deps\\gsl_sys-0d1cd764caa3b2be.dll" "/OPT:REF,NOICF" "/DLL" "/IMPLIB:D:\\GitHub\\rust-ellint\\target\\debug\
\deps\\gsl_sys-0d1cd764caa3b2be.dll.lib" "/DEBUG" "/NATVIS:C:\\Users\\etcto\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:C:\\Users
\\etcto\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:C:\\Users\\etcto\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:C:\\Users\\etcto\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libstd.natvis"
= note: LINK : fatal error LNK1181: cannot open input file 'gsl.lib'
error: could not compile `GSL-sys` due to previous error
and when I try to run a very basic "main.rs", I get
Compiling GSL-sys v2.0.2
error: linking with `link.exe` failed: exit code: 1181
|
= note: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.33.31629\\bin\\HostX64\\x64\\link.exe" "/DEF:C:\\Users\\etcto\\AppData\\Local\\Temp\\rustcFvqjHf\\lib.def" "/NOLOGO" "C:\\Users\\etcto\\AppData\\Local\\Temp\\rustcFvqjHf\\symbols.o" "D:\\GitHub\\rust-ellint\\target\\debug\\deps\\gsl_sys-0d1cd764caa3b2be.gsl_sys.59103b07-cgu.0.rcgu.o" "D:\\GitHub\\rust-ellint\\target\\debug\\deps\\gsl_sys-0d1cd764caa3b2be.gsl_sys.59103b07-cgu.1.rcgu.o" "D:\\GitHub\\rust-ellint\\target\\debug\\deps\\gsl_sys-0d1cd764caa3b2be.gsl_sys.59103b07-cgu.10.rcgu.o" "D:\\GitHub\\rust-ellint\\target\\debug\\deps\\gsl_sys-0d1cd764caa3b2be.gsl_sys.59103b07-cgu.11.rcgu.o" "D:\\GitHub\\rust-ellint\\target\\debug\\deps\\gsl_sys-0d1cd764caa3b2be.gsl_sys.59103b07-cgu.12.rcgu.o" "D:\\GitHub\\rust-ellint\\target\\debug\\deps\\gsl_sys-0d1cd764caa3b2be.gsl_sys.59103b07-cgu.2.rcgu.o" "D:\\GitHub\\rust-ellint\\target\\debug\\deps\\gsl_sys-0d1cd764caa3b2be.gsl_sys.59103b07-cgu.3.rcgu.o" "D:\\GitHub\\rust-ellint\\target\\debug\\deps\\gsl_sys-0d1cd764caa3b2be.gsl_sys.59103b07-cgu.4.rcgu.o" "D:\\GitHub\\rust-ellint\\target\\debug\\deps\\gsl_sys-0d1cd764caa3b2be.gsl_sys.59103b07-cgu.5.rcgu.o" "D:\\GitHub\\rust-ellint\\target\\debug\\deps\\gsl_sys-0d1cd764caa3b2be.gsl_sys.59103b07-cgu.6.rcgu.o" "D:\\GitHub\\rust-ellint\\target\\debug\\deps\\gsl_sys-0d1cd764caa3b2be.gsl_sys.59103b07-cgu.7.rcgu.o" "D:\\GitHub\\rust-ellint\\target\\debug\\deps\\gsl_sys-0d1cd764caa3b2be.gsl_sys.59103b07-cgu.8.rcgu.o" "D:\\GitHub\\rust-ellint\\target\\debug\\deps\\gsl_sys-0d1cd764caa3b2be.gsl_sys.59103b07-cgu.9.rcgu.o" "D:\\GitHub\\rust-ellint\\target\\debug\\deps\\gsl_sys-0d1cd764caa3b2be.3ehg95o16e12j0cb.rcgu.rmeta" "/LIBPATH:D:\\GitHub\\rust-ellint\\target\\debug\\deps" "/LIBPATH:C:\\Users\\etcto\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "gsl.lib" "gslcblas.lib" "D:\\GitHub\\rust-ellint\\target\\debug\\deps\\liblibc-33d50219ec2d56d1.rlib" "/LIBPATH:C:\\Users\\etcto\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "std-fdaa63d6970be740.dll.lib" "C:\\Users\\etcto\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-3f507ba7adac1c2a.rlib" "legacy_stdio_definitions.lib" "kernel32.lib" "advapi32.lib" "userenv.lib" "kernel32.lib" "ws2_32.lib" "bcrypt.lib" "msvcrt.lib" "legacy_stdio_definitions.lib" "/NXCOMPAT" "/LIBPATH:C:\\Users\\etcto\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "/OUT:D:\\GitHub\\rust-ellint\\target\\debug\\deps\\gsl_sys-0d1cd764caa3b2be.dll" "/OPT:REF,NOICF" "/DLL" "/IMPLIB:D:\\GitHub\\rust-ellint\\target\\debug\\deps\\gsl_sys-0d1cd764caa3b2be.dll.lib" "/DEBUG" "/NATVIS:C:\\Users\\etcto\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:C:\\Users\\etcto\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:C:\\Users\\etcto\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:C:\\Users\\etcto\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libstd.natvis"
= note: LINK : fatal error LNK1181: cannot open input file 'gsl.lib'
error: aborting due to previous error
error: could not compile `GSL-sys` due to 2 previous errors
Process finished with exit code 101
where main.rs is
use rgsl;
fn main() {
k = 2;
K = rgsl::pow::Pow::pow_2(&k);
println!("{K}")
}
I have a clean project to which I include anyhow 1.0.66.
Installed the latest version of rust.
I'm getting an error saying that anyhow requires a nightly version. Perhaps this is due to the use of backtrace, but it is supported in rust version 1.65. I don't understand how to solve the problem.
Cargo.toml
[package]
name = "libfs"
version = "0.1.0"
edition = "2021"
[dependencies]
tokio = {version = "1.22", features = ["full"]}
anyhow = {version = "1.0.66", features = ["default"]}
src/lib.rs
#[tokio::test]
async fn run_test() {
println!("test");
}
output
$ cargo build
Compiling anyhow v1.0.66
error[E0554]: `#![feature]` may not be used on the stable release channel
--> /home/dima/.cargo/registry/src/github.com-1ecc6299db9ec823/anyhow-1.0.66/src/lib.rs:214:32
|
214 | #![cfg_attr(backtrace, feature(error_generic_member_access, provide_any))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0554]: `#![feature]` may not be used on the stable release channel
--> /home/dima/.cargo/registry/src/github.com-1ecc6299db9ec823/anyhow-1.0.66/src/lib.rs:214:61
|
214 | #![cfg_attr(backtrace, feature(error_generic_member_access, provide_any))]
| ^^^^^^^^^^^
For more information about this error, try `rustc --explain E0554`.
error: could not compile `anyhow` due to 2 previous errors
The problem was solved by:
rm -rf target
cargo check
This seems to be related to dtolnay/anyhow/issues/250 and rust-lang/rust-analyzer/issues/12973.
I have been used easylogging with OMP, but I found it should add ELPP_THREAD_SAFE to keep thread safe, it success in win but when failed in ubuntu20.04. When I tried to add definition ELPP_THREAD_SAFE in cmakelist, it complied failed.
PS:-lpthread was also added.
Fail info:
/usr/include/c++/9/mutex:541:5: error: variable or field ??lock?? declared void
541 | lock(_L1& __l1, _L2& __l2, _L3&... __l3)
| ^~~~
/usr/include/c++/9/mutex:543:7: error: expected primary-expression before ??while??
543 | while (true)
...
I am pretty new to Linux and I am having problems integrating an external software into my program. When I am following the instructions on integrating a couple of lines that includes Jansson (Add G4Sipm to your CMakeLists.txt in this document enter link description here) I get errors which I suspect is the problem of integration itself since it does separately build on its own. The errors I get are after command build -j2. Here is a part of the terminal output:
Scanning dependencies of target jansson
Scanning dependencies of target gtest
Scanning dependencies of target G4GeneralParticleSource
[ 1%] Building C object externals/g4sipm/externals/jansson/CMakeFiles/jansson.dir/src/dump.c.o
[ 2%] Building C object externals/g4sipm/externals/jansson/CMakeFiles/jansson.dir/src/error.c.o
[ 2%] Building C object externals/g4sipm/externals/jansson/CMakeFiles/jansson.dir/src/hashtable.c.o
[ 3%] Building CXX object G4BasicObjects/G4PropertyFileReadInTools/CMakeFiles/G4PropertyFileReadInTools.dir/src/PropertyToolsManager.cc.o
[ 4%] Building C object externals/g4sipm/externals/jansson/CMakeFiles/jansson.dir/src/hashtable_seed.c.o
[ 4%] Building CXX object G4BasicObjects/G4PropertyFileReadInTools/CMakeFiles/G4PropertyFileReadInTools.dir/src/GoddessProperties.cc.o
[ 4%] Building CXX object G4BasicObjects/G4PropertyFileReadInTools/CMakeFiles/G4PropertyFileReadInTools.dir/src/VectorUtil.cc.o
[ 5%] Building CXX object externals/g4sipm/externals/googletest/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o
[ 6%] Building C object externals/g4sipm/externals/jansson/CMakeFiles/jansson.dir/src/load.c.o
[ 6%] Building C object externals/g4sipm/externals/jansson/CMakeFiles/jansson.dir/src/memory.c.o
[ 7%] Building C object externals/g4sipm/externals/jansson/CMakeFiles/jansson.dir/src/pack_unpack.c.o
[ 7%] Building C object externals/g4sipm/externals/jansson/CMakeFiles/jansson.dir/src/strbuffer.c.o
In file included from /home/abhinab1/goddess/source/externals/g4sipm/externals/jansson/src/hashtable.h:11,
from /home/abhinab1/goddess/source/externals/g4sipm/externals/jansson/src/jansson_private.h:11,
from /home/abhinab1/goddess/source/externals/g4sipm/externals/jansson/src/dump.c:12:
/home/abhinab1/goddess/source/externals/g4sipm/externals/jansson/src/jansson.h:101:22: error: unknown type name ‘json_int_t’; did you mean ‘json_t’?
101 | json_t *json_integer(json_int_t value);
| ^~~~~~~~~~
| json_t
/home/abhinab1/goddess/source/externals/g4sipm/externals/jansson/src/jansson.h:280:1: error: unknown type name ‘json_int_t’; did you mean ‘json_auto_t’?
280 | json_int_t json_integer_value(const json_t *integer);
| ^~~~~~~~~~
| json_auto_t
In file included from /home/abhinab1/goddess/source/externals/g4sipm/externals/jansson/src/hashtable.h:11,
from /home/abhinab1/goddess/source/externals/g4sipm/externals/jansson/src/jansson_private.h:11,
from /home/abhinab1/goddess/source/externals/g4sipm/externals/jansson/src/error.c:1:
/home/abhinab1/goddess/source/externals/g4sipm/externals/jansson/src/jansson.h:101:22: error: unknown type name ‘json_int_t’; did you mean ‘json_t’?
101 | json_t *json_integer(json_int_t value);
| ^~~~~~~~~~
| json_t
/home/abhinab1/goddess/source/externals/g4sipm/externals/jansson/src/jansson.h:288:39: error: unknown type name ‘json_int_t’; did you mean ‘json_auto_t’?
288 | int json_integer_set(json_t *integer, json_int_t value);
| ^~~~~~~~~~
| json_auto_t
In file included from /home/abhinab1/goddess/source/externals/g4sipm/externals/jansson/src/dump.c:12:
/home/abhinab1/goddess/source/externals/g4sipm/externals/jansson/src/jansson_private.h:60:5: error: unknown type name ‘json_int_t’
60 | json_int_t value;
| ^~~~~~~~~~
/home/abhinab1/goddess/source/externals/g4sipm/externals/jansson/src/jansson.h:280:1: error: unknown type name ‘json_int_t’; did you mean ‘json_auto_t’?
280 | json_int_t json_integer_value(const json_t *integer);
| ^~~~~~~~~~
| json_auto_t
/home/abhinab1/goddess/source/externals/g4sipm/externals/jansson/src/jansson.h:288:39: error: unknown type name ‘json_int_t’; did you mean ‘json_auto_t’?
288 | int json_integer_set(json_t *integer, json_int_t value);
| ^~~~~~~~~~
| json_auto_t
In file included from /home/abhinab1/goddess/source/externals/g4sipm/externals/jansson/src/error.c:1:
/home/abhinab1/goddess/source/externals/g4sipm/externals/jansson/src/jansson_private.h:60:5: error: unknown type name ‘json_int_t’
60 | json_int_t value;
| ^~~~~~~~~~
In file included from /home/abhinab1/goddess/source/externals/g4sipm/externals/jansson/src/hashtable.h:11,
from /home/abhinab1/goddess/source/externals/g4sipm/externals/jansson/src/hashtable.c:19:
/home/abhinab1/goddess/source/externals/g4sipm/externals/jansson/src/jansson.h:101:22: error: unknown type name ‘json_int_t’; did you mean ‘json_t’?
101 | json_t *json_integer(json_int_t value);
| ^~~~~~~~~~
| json_t
I tried adding #include <jansson_config.h> instead of #include "jansson_config.h" however errors still persisted. I tried contacting the project lead however it seems they have all moved on from the project. Any help and suggestions would be greatly appreciated, thank you!
Edit 1: for clarification, I am using the latest version of Jansson
I'm attempting to get a working prototype of the following scenario:
Language: Rust (rustc 1.45.0-nightly (ad4bc3323 2020-06-01))
Framework: Rocket v0.4.4
Build Tool: Bazel
Platform: Mac OS X / Darwin x64
Running bazel build //web-api yields the below error. I believe, based on looking at the Cargo.lock file it is because Rocket's dependency on the hyper library specifies a dependency on the log 0.3.9 library. For whatever reason it is not using the more recent log=0.4.x. That said, I don't know why it's pulling this library since, if I build it manually, it works fine.
ERROR: /private/var/tmp/_bazel_nathanielford/2a39169ea9f6eb02fe788b12f9eae88f/external/raze__log__0_3_9/BUILD.bazel:27:1: error executing shell command: '/bin/bash -c CARGO_MANIFEST_DIR=$(pwd)/external/raze__log__0_3_9 external/rust_darwin_x86_64/bin/rustc "$#" --remap-path-prefix="$(pwd)"=__bazel_redacted_pwd external/raze__log__0_3_9/src/lib.rs -...' failed (Exit 1) bash failed: error executing command /bin/bash -c 'CARGO_MANIFEST_DIR=$(pwd)/external/raze__log__0_3_9 external/rust_darwin_x86_64/bin/rustc "$#" --remap-path-prefix="$(pwd)"=__bazel_redacted_pwd' '' external/raze__log__0_3_9/src/lib.rs ... (remaining 24 argument(s) skipped)
Use --sandbox_debug to see verbose messages from the sandbox
error[E0425]: cannot find function `set_logger` in crate `log`
--> external/raze__log__0_3_9/src/lib.rs:731:16
|
731 | match log::set_logger(&ADAPTOR) {
| ^^^^^^^^^^ not found in `log`
|
help: consider importing this function
|
204 | use set_logger;
|
The following is my directory structure:
/
|-WORKSPACE
|-BUILD # Empty
|-web-api/
| |-BUILD
| |-src/
| | |-main.rs
| |-cargo/
| |-Cargo.toml
| |-Cargo.lock
| |-BUILD.bazel
| |-remote/
| |-... (Cargo-raze files)
In order to set up the cargo-raze I did the following, following instructions from the github page.:
$ cd web-api/cargo
$ cargo generate-lockfile
$ cargo vendor --versioned-dirs --locked
$ cargo raze
(The generate-lockfile is what creates the Cargo.lock file, and the cargo raze is what creates the BUILD.bazel file and all the contents of the remote sub directory.)
And then to execute the bazel build I go back to the root and run bazel build //web-api, which produces the above error.
This is my WORKSPACE file:
workspace(name = "rocket-bazel")
load("#bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_rust",
sha256 = "f21c67fc2fef9d57fa3c81fde1defd9e57d451883388c0a469ec1c470fd30dcb",
strip_prefix = "rules_rust-master",
urls = [
"https://github.com/bazelbuild/rules_rust/archive/master.tar.gz"
],
)
http_archive(
name = "bazel_skylib",
sha256 = "9a737999532daca978a158f94e77e9af6a6a169709c0cee274f0a4c3359519bd",
strip_prefix = "bazel-skylib-1.0.0",
url = "https://github.com/bazelbuild/bazel-skylib/archive/1.0.0.tar.gz",
)
load("#io_bazel_rules_rust//rust:repositories.bzl", "rust_repositories")
rust_repositories(version="nightly", iso_date="2020-06-02")
load("#io_bazel_rules_rust//:workspace.bzl", "bazel_version")
bazel_version(name = "bazel_version")
load("//web-api/cargo:crates.bzl", "raze_fetch_remote_crates")
raze_fetch_remote_crates()
This is my web-api/BUILD file:
load("#io_bazel_rules_rust//rust:rust.bzl", "rust_binary")
rust_binary(
name = "web-api",
srcs = ["src/main.rs"],
deps = [
"//web-api/cargo:rocket",
],
)
And my web-api/cargo/Cargo.toml file:
load("#io_bazel_rules_rust//rust:rust.bzl", "rust_binary")
rust_binary(
name = "web-api",
srcs = ["src/main.rs"],
deps = [
"//web-api/cargo:rocket",
],
)
I've run out of ideas as to what to try. I can get this to compile without Bazel, just using rust (though obviously the files are in slightly different places). I can get it to compile inside a Docker container. I just can't get Bazel (necessarily with cargo raze, either in vendor or remote mode) to run successfully: I assume that there is some mismatch in compile target or the nightly build that is not being properly set - but I'm not sure how to diagnose or get past that.
Here is a link to a repository with the files/structure I tried.
I had a similar issue when I made a minimal Bazel workspace with rust and the log crate together with env_logger crate. I found a similar issue when you try to compile without features = ["std"]. I then tried to enable that in Cargo.toml on the log dependency without success.
My solution is that in Cargo.toml under [raze] I added:
default_gen_buildrs = true
I could trace it down to that when default_gen_buildrs flag is not set in the generated log crate the BUILD.bazel file did not have a cargo_build_script definition or this:
crate_features = [
"std",
],