error: could not compile `casbin`; the name `...` is defined multiple times
arnaudpoullet opened this issue · comments
Hello,
I'm having trouble simply adding this crate to my project. The cfg conditional featured-based use statements
do not seem to be taken into account. Here are the errors:
error[E0252]: the name `IoError` is defined multiple times
--> /home/arnaud/.cargo/registry/src/github.com-1ecc6299db9ec823/casbin-2.0.5/src/adapter/file_adapter.rs:20:10
|
13 | io::{BufReader, Error as IoError, ErrorKind},
| ---------------- previous import of the type `IoError` here
...
20 | io::{Error as IoError, ErrorKind},
| ^^^^^^^^^^^^^^^^--
| |
| `IoError` reimported here
| help: remove unnecessary import
|
= note: `IoError` must be defined only once in the type namespace of this module
error[E0252]: the name `ErrorKind` is defined multiple times
--> /home/arnaud/.cargo/registry/src/github.com-1ecc6299db9ec823/casbin-2.0.5/src/adapter/file_adapter.rs:20:28
|
13 | io::{BufReader, Error as IoError, ErrorKind},
| --------- previous import of the type `ErrorKind` here
...
20 | io::{Error as IoError, ErrorKind},
| ^^^^^^^^^ `ErrorKind` reimported here
|
= note: `ErrorKind` must be defined only once in the type namespace of this module
error[E0252]: the name `Path` is defined multiple times
--> /home/arnaud/.cargo/registry/src/github.com-1ecc6299db9ec823/casbin-2.0.5/src/adapter/file_adapter.rs:21:5
|
14 | path::Path,
| ---------- previous import of the type `Path` here
...
21 | path::Path,
| ^^^^^^^^^^ `Path` reimported here
|
= note: `Path` must be defined only once in the type namespace of this module
help: you can use `as` to change the binding name of the import
|
21 | path::Path as OtherPath,
| ^^^^^^^^^^^^^^^^^^^^^^^
error[E0252]: the name `File` is defined multiple times
--> /home/arnaud/.cargo/registry/src/github.com-1ecc6299db9ec823/casbin-2.0.5/src/adapter/file_adapter.rs:25:5
|
11 | fs::File,
| -------- previous import of the type `File` here
...
25 | fs::File,
| ^^^^^^^^ `File` reimported here
|
= note: `File` must be defined only once in the type namespace of this module
help: you can use `as` to change the binding name of the import
|
25 | fs::File as OtherFile,
| ^^^^^^^^^^^^^^^^^^^^^
error[E0252]: the name `BufReader` is defined multiple times
--> /home/arnaud/.cargo/registry/src/github.com-1ecc6299db9ec823/casbin-2.0.5/src/adapter/file_adapter.rs:26:42
|
13 | io::{BufReader, Error as IoError, ErrorKind},
| --------- previous import of the type `BufReader` here
...
26 | io::{AsyncBufReadExt, AsyncWriteExt, BufReader},
| ^^^^^^^^^ `BufReader` reimported here
|
= note: `BufReader` must be defined only once in the type namespace of this module
help: you can use `as` to change the binding name of the import
|
26 | io::{AsyncBufReadExt, AsyncWriteExt, BufReader as OtherBufReader},
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0252]: the name `Cursor` is defined multiple times
--> /home/arnaud/.cargo/registry/src/github.com-1ecc6299db9ec823/casbin-2.0.5/src/config.rs:13:11
|
6 | io::{BufReader, Cursor, Error as IoError, ErrorKind},
| ------ previous import of the type `Cursor` here
...
13 | use std::{io::Cursor, path::Path};
| ^^^^^^^^^^ `Cursor` reimported here
|
= note: `Cursor` must be defined only once in the type namespace of this module
help: you can use `as` to change the binding name of the import
|
13 | use std::{io::Cursor as OtherCursor, path::Path};
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0252]: the name `Path` is defined multiple times
--> /home/arnaud/.cargo/registry/src/github.com-1ecc6299db9ec823/casbin-2.0.5/src/config.rs:13:23
|
10 | use async_std::{fs::File, path::Path};
| ---------- previous import of the type `Path` here
...
13 | use std::{io::Cursor, path::Path};
| ^^^^^^^^^^ `Path` reimported here
|
= note: `Path` must be defined only once in the type namespace of this module
help: you can use `as` to change the binding name of the import
|
13 | use std::{io::Cursor, path::Path as OtherPath};
| ^^^^^^^^^^^^^^^^^^^^^^^
error[E0252]: the name `BufReader` is defined multiple times
--> /home/arnaud/.cargo/registry/src/github.com-1ecc6299db9ec823/casbin-2.0.5/src/config.rs:16:36
|
6 | io::{BufReader, Cursor, Error as IoError, ErrorKind},
| --------- previous import of the type `BufReader` here
...
16 | AsyncBufReadExt, AsyncReadExt, BufReader, Error as IoError, ErrorKind,
| ^^^^^^^^^ `BufReader` reimported here
|
= note: `BufReader` must be defined only once in the type namespace of this module
help: you can use `as` to change the binding name of the import
|
16 | AsyncBufReadExt, AsyncReadExt, BufReader as OtherBufReader, Error as IoError, ErrorKind,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0252]: the name `IoError` is defined multiple times
--> /home/arnaud/.cargo/registry/src/github.com-1ecc6299db9ec823/casbin-2.0.5/src/config.rs:16:47
|
6 | io::{BufReader, Cursor, Error as IoError, ErrorKind},
| ---------------- previous import of the type `IoError` here
...
16 | AsyncBufReadExt, AsyncReadExt, BufReader, Error as IoError, ErrorKind,
| ^^^^^^^^^^^^^^^^--
| |
| `IoError` reimported here
| help: remove unnecessary import
|
= note: `IoError` must be defined only once in the type namespace of this module
error[E0252]: the name `ErrorKind` is defined multiple times
--> /home/arnaud/.cargo/registry/src/github.com-1ecc6299db9ec823/casbin-2.0.5/src/config.rs:16:65
|
6 | io::{BufReader, Cursor, Error as IoError, ErrorKind},
| --------- previous import of the type `ErrorKind` here
...
16 | AsyncBufReadExt, AsyncReadExt, BufReader, Error as IoError, ErrorKind,
| ^^^^^^^^^-
| |
| `ErrorKind` reimported here
| help: remove unnecessary import
|
= note: `ErrorKind` must be defined only once in the type namespace of this module
error[E0252]: the name `File` is defined multiple times
--> /home/arnaud/.cargo/registry/src/github.com-1ecc6299db9ec823/casbin-2.0.5/src/config.rs:20:5
|
10 | use async_std::{fs::File, path::Path};
| -------- previous import of the type `File` here
...
20 | use tokio::fs::File;
| ^^^^^^^^^^^^^^^ `File` reimported here
|
= note: `File` must be defined only once in the type namespace of this module
help: you can use `as` to change the binding name of the import
|
20 | use tokio::fs::File as OtherFile;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0252]: the name `Path` is defined multiple times
--> /home/arnaud/.cargo/registry/src/github.com-1ecc6299db9ec823/casbin-2.0.5/src/model/default_model.rs:19:5
|
16 | use async_std::path::Path;
| --------------------- previous import of the type `Path` here
...
19 | use std::path::Path;
| ^^^^^^^^^^^^^^^ `Path` reimported here
|
= note: `Path` must be defined only once in the type namespace of this module
help: you can use `as` to change the binding name of the import
|
19 | use std::path::Path as OtherPath;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 12 previous errors
These errors appear whether or not I add the features = ["runtime-tokio"]
to my Cargo.toml. I'm working with rustc 1.49.0 (e1884a8e3 2020-12-29)
and here is the list of dependencies from my Cargo.toml
:
[dependencies]
actix-casbin-auth = { version = "0.4.4", features = ["runtime-tokio"] }
actix-files = "0.5.0"
actix-redis = "0.9.1"
actix-session = "0.4.0"
actix-web = { version = "3", default-features = false }
chrono = { version = "0.4.19", features = ["serde"]}
diesel = { version = "^1.4.4", features = ["postgres","r2d2","chrono"] }
diesel-adapter = { version = "0.8.3", features = ["postgres"] }
diesel-derive-enum = { version = "1.1.0", features = ["postgres"] }
dotenv = "0.15"
env_logger = "0.7"
failure = "0.1.8"
futures = "0.3.8"
lazy_static = "1.4.0"
lettre = "0.10.0-alpha.4"
log = "0.4.13"
regex = "1.4.3"
sailfish = "0.3.0"
sailfish-macros = "0.3.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
sodiumoxide = "0.2.6"
strum_macros = "0.20.1"
uuid = { version = "0.8", features = ["serde", "v4"] }
walkdir = "2.3.1"
Any help would be appreciated.
@hackerchai @PsiACE plz take a look
/cc @GopherJ
@arnaudpoullet Try to write cargo.toml
like this:
actix-casbin= {version = "0.4.2", default-features = false, features = [ "runtime-async-std" ]}
actix-casbin-auth = {version = "0.4.4", default-features = false, features = [ "runtime-async-std" ]}
diesel-adapter = { version = "0.8.1", default-features = false, features = ["postgres","runtime-async-std"] }
This should avoid async runtime multipile importing issue.
Thank you8 This works indeed. I think this should be added to the Install
section of the README.
As well, I don't want to make a new issue for this, but I had to do an extra import to get the example code working in my main. I think it should be added too, because it doesn't seem to work without.
use actix_casbin_auth::casbin::function_map::key_match2;
@arnaudpoullet can you make a PR to fix the README?