RedisJSON / RedisJSON2

Rust based RedisJSON implementation - Deprecated and moved to RedisJSON/RedisJSON
https://redisjson.io
Other
54 stars 4 forks source link

Build error[E0505]: cannot move out of `node` because it is borrowed #85

Closed fstarr closed 4 years ago

fstarr commented 4 years ago

Hi,

when trying to build libredisjson.so I get the following issue:

$ cargo build --release
    Updating crates.io index
    Updating git repository `https://github.com/gkorland/jsonpath.git`
 Downloading crates ...
  Downloaded libc v0.2.66
  Downloaded log v0.4.8
  Downloaded env_logger v0.7.1
  Downloaded serde v1.0.104
  Downloaded array_tool v1.0.3
  Downloaded bson v0.14.0
  Downloaded redis-module v0.7.0
  Downloaded cfg-if v0.1.10
  Downloaded termcolor v1.1.0
  Downloaded atty v0.2.14
  Downloaded humantime v1.3.0
  Downloaded serde_derive v1.0.104
  Downloaded regex v1.3.4
  Downloaded serde_json v1.0.47
  Downloaded rand v0.7.3
  Downloaded num-traits v0.2.11
  Downloaded linked-hash-map v0.5.2
  Downloaded chrono v0.4.10
  Downloaded cc v1.0.50
  Downloaded md5 v0.6.1
  Downloaded quick-error v1.2.3
  Downloaded enum-primitive-derive v0.1.2
  Downloaded byteorder v1.3.4
  Downloaded time v0.1.42
  Downloaded bitflags v1.2.1
  Downloaded hex v0.3.2
  Downloaded ryu v1.0.2
  Downloaded proc-macro2 v1.0.8
  Downloaded rand_core v0.5.1
  Downloaded getrandom v0.1.14
  Downloaded thread_local v1.0.1
  Downloaded num-traits v0.1.43
  Downloaded quote v0.3.15
  Downloaded aho-corasick v0.7.8
  Downloaded rand_chacha v0.2.1
  Downloaded quote v1.0.2
  Downloaded indexmap v1.3.2
  Downloaded autocfg v1.0.0
  Downloaded num-integer v0.1.42
  Downloaded itoa v0.4.5
  Downloaded syn v1.0.14
  Downloaded memchr v2.3.0
  Downloaded redisearch_api v0.3.0
  Downloaded unicode-xid v0.2.0
  Downloaded lazy_static v1.4.0
  Downloaded regex-syntax v0.6.14
  Downloaded bindgen v0.52.0
  Downloaded lazycell v1.2.1
  Downloaded rustc-hash v1.1.0
  Downloaded shlex v0.1.1
  Downloaded bindgen v0.51.1
  Downloaded cmake v0.1.42
  Downloaded c2-chacha v0.2.3
  Downloaded cexpr v0.3.6
  Downloaded which v3.1.0
  Downloaded clap v2.33.0
  Downloaded syn v0.11.11
  Downloaded peeking_take_while v0.1.2
  Downloaded ppv-lite86 v0.2.6
  Downloaded env_logger v0.6.2
  Downloaded nom v4.2.3
  Downloaded clang-sys v0.28.1
  Downloaded ansi_term v0.11.0
  Downloaded vec_map v0.8.1
  Downloaded textwrap v0.11.0
  Downloaded unicode-xid v0.0.4
  Downloaded synom v0.11.3
  Downloaded unicode-width v0.1.7
  Downloaded strsim v0.8.0
  Downloaded glob v0.3.0
  Downloaded libloading v0.5.2
  Downloaded version_check v0.1.5
   Compiling memchr v2.3.0
   Compiling version_check v0.1.5
   Compiling cc v1.0.50
   Compiling libc v0.2.66
   Compiling bitflags v1.2.1
   Compiling proc-macro2 v1.0.8
   Compiling log v0.4.8
   Compiling glob v0.3.0
   Compiling lazy_static v1.4.0
   Compiling cfg-if v0.1.10
   Compiling autocfg v1.0.0
   Compiling unicode-width v0.1.7
   Compiling quick-error v1.2.3
   Compiling unicode-xid v0.2.0
   Compiling regex-syntax v0.6.14
   Compiling vec_map v0.8.1
   Compiling bindgen v0.52.0
   Compiling strsim v0.8.0
   Compiling ansi_term v0.11.0
   Compiling getrandom v0.1.14
   Compiling termcolor v1.1.0
   Compiling syn v1.0.14
   Compiling bindgen v0.51.1
   Compiling unicode-xid v0.0.4
   Compiling rustc-hash v1.1.0
   Compiling shlex v0.1.1
   Compiling peeking_take_while v0.1.2
   Compiling lazycell v1.2.1
   Compiling ryu v1.0.2
   Compiling ppv-lite86 v0.2.6
   Compiling quote v0.3.15
   Compiling serde v1.0.104
   Compiling byteorder v1.3.4
   Compiling itoa v0.4.5
   Compiling md5 v0.6.1
   Compiling linked-hash-map v0.5.2
   Compiling hex v0.3.2
   Compiling array_tool v1.0.3
   Compiling nom v4.2.3
   Compiling libloading v0.5.2
   Compiling cmake v0.1.42
   Compiling clang-sys v0.28.1
   Compiling thread_local v1.0.1
   Compiling textwrap v0.11.0
   Compiling humantime v1.3.0
   Compiling num-traits v0.2.11
   Compiling indexmap v1.3.2
   Compiling num-integer v0.1.42
   Compiling synom v0.11.3
   Compiling c2-chacha v0.2.3
   Compiling syn v0.11.11
   Compiling aho-corasick v0.7.8
   Compiling atty v0.2.14
   Compiling which v3.1.0
   Compiling time v0.1.42
   Compiling quote v1.0.2
   Compiling regex v1.3.4
   Compiling clap v2.33.0
   Compiling rand_core v0.5.1
   Compiling cexpr v0.3.6
   Compiling num-traits v0.1.43
   Compiling env_logger v0.7.1
   Compiling env_logger v0.6.2
   Compiling rand_chacha v0.2.1
   Compiling enum-primitive-derive v0.1.2
   Compiling chrono v0.4.10
   Compiling serde_derive v1.0.104
   Compiling rand v0.7.3
   Compiling redisearch_api v0.3.0
   Compiling serde_json v1.0.47
   Compiling bson v0.14.0
   Compiling jsonpath_lib v0.2.3 (https://github.com/gkorland/jsonpath.git?branch=patch-1#bd1975d6)
error[E0505]: cannot move out of `node` because it is borrowed
  --> /root/.cargo/git/checkouts/jsonpath-dd869ee3d7fc4db5/bd1975d/src/ffi/mod.rs:54:22
   |
53 |     let found = selector.compiled_path(&node).value(&json).select().unwrap();
   |                                         ---- borrow of `node` occurs here
54 |     std::mem::forget(node);
   |                      ^^^^ move out of `node` occurs here
error: aborting due to previous error
For more information about this error, try `rustc --explain E0505`.
error: Could not compile `jsonpath_lib`.
warning: build failed, waiting for other jobs to finish...
error: build failed

Any ideas what to do about it? Am I missing some dependecies? Speaking of dependencies it would be nice to have a list of them somewhere. Maybe in README.md.

gkorland commented 4 years ago

Which rust version are you using? Regarding the dependencies https://github.com/RedisJSON/RedisJSON2/blob/master/Cargo.toml

gavrie commented 4 years ago

This indeed looks like an error from an old version of the Rust compiler (from before non-lexical lifetimes).

Please try building with the latest Rust version.

fstarr commented 4 years ago

I've been trying to build inside a Docker container based on the latest Python image which seems to be based on Debian 10 "Buster":

$ rustc --version
rustc 1.34.2
$ cargo --version
cargo 1.34.0
fstarr commented 4 years ago

Regarding the dependencies https://github.com/RedisJSON/RedisJSON2/blob/master/Cargo.toml

I was more thinking about the other system packages needed like e.g. cmake. Thankfully @willisga put quite some effort into documenting these in #60. Maybe it helps some others to put his findings in a more prominent place.

gavrie commented 4 years ago

@fstarr good point. We should add this to the README.md in the Build section.

fstarr commented 4 years ago

I just tried to build with rustc v1.42.0 which worked just fine!

Thanks for your support!