Repository: phiresky/ripgrep-all (language: rust)

Issue:
build failed in ubuntu 18.04 docker
I want to build ripgrep-all from source and get errors.
I reproduce the same error on docker environment.

- docker original image: ubuntu/latest
~~~
docker run -it --rm ubuntu /bin/bash
~~~

- OS version
~~~
root@7927ed67baf9:/# lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.2 LTS
Release:	18.04
Codename:	bionic
~~~

- Installation code
~~~
apt update
apt upgrade

# install requirements
apt install build-essential pandoc poppler-utils ffmpeg cargo curl

# install rust
curl https://sh.rustup.rs -sSf | sh -s -- -y
export PATH="$HOME/.cargo/bin:$PATH"
~~~

- rust version check
~~~
root@7927ed67baf9:/# rustc --version
rustc 1.36.0 (a53f9df32 2019-07-03)
~~~

- Install ripgrep & ripgrep-all
~~~
# install ripgrep
cargo install ripgrep

# install repgrep_all
cargo install ripgrep_all
~~~

- Error messages
~~~
error[E0277]: `*const libsqlite3_sys::sqlite3_module` cannot be sent between threads safely
  --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/rusqlite-0.18.0/src/vtab/series.rs:21:1
   |
21 | / lazy_static! {
22 | |     static ref SERIES_MODULE: Module<SeriesTab> = eponymous_only_module::<SeriesTab>(1);
23 | | }
   | |_^ `*const libsqlite3_sys::sqlite3_module` cannot be sent between threads safely
   |
   = help: within `vtab::Module<vtab::series::SeriesTab>`, the trait `std::marker::Send` is not implemented for `*const libsqlite3_sys::sqlite3_module`
   = note: required because it appears within the type `libsqlite3_sys::sqlite3_vtab`
   = note: required because it appears within the type `vtab::series::SeriesTab`
   = note: required because it appears within the type `std::marker::PhantomData<vtab::series::SeriesTab>`
   = note: required because it appears within the type `vtab::Module<vtab::series::SeriesTab>`
   = note: required because of the requirements on the impl of `std::marker::Sync` for `spin::once::Once<vtab::Module<vtab::series::SeriesTab>>`
   = note: required because it appears within the type `lazy_static::lazy::Lazy<vtab::Module<vtab::series::SeriesTab>>`
   = note: shared static variables must have a type that implements `Sync`
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error[E0277]: `*mut i8` cannot be sent between threads safely
  --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/rusqlite-0.18.0/src/vtab/series.rs:21:1
   |
21 | / lazy_static! {
22 | |     static ref SERIES_MODULE: Module<SeriesTab> = eponymous_only_module::<SeriesTab>(1);
23 | | }
   | |_^ `*mut i8` cannot be sent between threads safely
   |
   = help: within `vtab::Module<vtab::series::SeriesTab>`, the trait `std::marker::Send` is not implemented for `*mut i8`
   = note: required because it appears within the type `libsqlite3_sys::sqlite3_vtab`
   = note: required because it appears within the type `vtab::series::SeriesTab`
   = note: required because it appears within the type `std::marker::PhantomData<vtab::series::SeriesTab>`
   = note: required because it appears within the type `vtab::Module<vtab::series::SeriesTab>`
   = note: required because of the requirements on the impl of `std::marker::Sync` for `spin::once::Once<vtab::Module<vtab::series::SeriesTab>>`
   = note: required because it appears within the type `lazy_static::lazy::Lazy<vtab::Module<vtab::series::SeriesTab>>`
   = note: shared static variables must have a type that implements `Sync`
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0277`.
error: failed to compile `ripgrep_all v0.9.2`, intermediate artifacts can be found at `/tmp/cargo-installOqSn2W`

Caused by:
  Could not compile `rusqlite`.

To learn more, run the command again with --verbose.
~~~

- With --verbose option
~~~
cargo install ripgrep_all --verbose
~~~

- Error messages
~~~
   Compiling rusqlite v0.18.0
     Running `rustc --edition=2018 --crate-name rusqlite /root/.cargo/registry/src/github.com-1ecc6299db9ec823/rusqlite-0.18.0/src/lib.rs --color always --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 --cfg 'feature="bundled"' --cfg 'feature="lazy_static"' --cfg 'feature="libsqlite3-sys"' --cfg 'feature="vtab"' -C metadata=b5985805439e28e0 -C extra-filename=-b5985805439e28e0 --out-dir /tmp/cargo-installa2jlTk/release/deps -L dependency=/tmp/cargo-installa2jlTk/release/deps --extern bitflags=/tmp/cargo-installa2jlTk/release/deps/libbitflags-e53b4b50e5713d69.rlib --extern fallible_iterator=/tmp/cargo-installa2jlTk/release/deps/libfallible_iterator-229d1b548363649b.rlib --extern fallible_streaming_iterator=/tmp/cargo-installa2jlTk/release/deps/libfallible_streaming_iterator-3dc8799337b38106.rlib --extern lazy_static=/tmp/cargo-installa2jlTk/release/deps/liblazy_static-b92b4a1bf6babc8c.rlib --extern libsqlite3_sys=/tmp/cargo-installa2jlTk/release/deps/liblibsqlite3_sys-fec7266de6e25bdf.rlib --extern lru_cache=/tmp/cargo-installa2jlTk/release/deps/liblru_cache-b6c9918432310b68.rlib --extern memchr=/tmp/cargo-installa2jlTk/release/deps/libmemchr-292d84c02d2d5263.rlib --extern time=/tmp/cargo-installa2jlTk/release/deps/libtime-d82d709fd943c2c8.rlib --cap-lints allow -L native=/tmp/cargo-installa2jlTk/release/build/libsqlite3-sys-0f04e3e46e346ca2/out`
error[E0277]: `*const libsqlite3_sys::sqlite3_module` cannot be sent between threads safely
  --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/rusqlite-0.18.0/src/vtab/series.rs:21:1
   |
21 | / lazy_static! {
22 | |     static ref SERIES_MODULE: Module<SeriesTab> = eponymous_only_module::<SeriesTab>(1);
23 | | }
   | |_^ `*const libsqlite3_sys::sqlite3_module` cannot be sent between threads safely
   |
   = help: within `vtab::Module<vtab::series::SeriesTab>`, the trait `std::marker::Send` is not implemented for `*const libsqlite3_sys::sqlite3_module`
   = note: required because it appears within the type `libsqlite3_sys::sqlite3_vtab`
   = note: required because it appears within the type `vtab::series::SeriesTab`
   = note: required because it appears within the type `std::marker::PhantomData<vtab::series::SeriesTab>`
   = note: required because it appears within the type `vtab::Module<vtab::series::SeriesTab>`
   = note: required because of the requirements on the impl of `std::marker::Sync` for `spin::once::Once<vtab::Module<vtab::series::SeriesTab>>`
   = note: required because it appears within the type `lazy_static::lazy::Lazy<vtab::Module<vtab::series::SeriesTab>>`
   = note: shared static variables must have a type that implements `Sync`
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error[E0277]: `*mut i8` cannot be sent between threads safely
  --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/rusqlite-0.18.0/src/vtab/series.rs:21:1
   |
21 | / lazy_static! {
22 | |     static ref SERIES_MODULE: Module<SeriesTab> = eponymous_only_module::<SeriesTab>(1);
23 | | }
   | |_^ `*mut i8` cannot be sent between threads safely
   |
   = help: within `vtab::Module<vtab::series::SeriesTab>`, the trait `std::marker::Send` is not implemented for `*mut i8`
   = note: required because it appears within the type `libsqlite3_sys::sqlite3_vtab`
   = note: required because it appears within the type `vtab::series::SeriesTab`
   = note: required because it appears within the type `std::marker::PhantomData<vtab::series::SeriesTab>`
   = note: required because it appears within the type `vtab::Module<vtab::series::SeriesTab>`
   = note: required because of the requirements on the impl of `std::marker::Sync` for `spin::once::Once<vtab::Module<vtab::series::SeriesTab>>`
   = note: required because it appears within the type `lazy_static::lazy::Lazy<vtab::Module<vtab::series::SeriesTab>>`
   = note: shared static variables must have a type that implements `Sync`
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0277`.
error: failed to compile `ripgrep_all v0.9.2`, intermediate artifacts can be found at `/tmp/cargo-installa2jlTk`

Caused by:
  Could not compile `rusqlite`.

Caused by:
  process didn't exit successfully: `rustc --edition=2018 --crate-name rusqlite /root/.cargo/registry/src/github.com-1ecc6299db9ec823/rusqlite-0.18.0/src/lib.rs --color always --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 --cfg 'feature="bundled"' --cfg 'feature="lazy_static"' --cfg 'feature="libsqlite3-sys"' --cfg 'feature="vtab"' -C metadata=b5985805439e28e0 -C extra-filename=-b5985805439e28e0 --out-dir /tmp/cargo-installa2jlTk/release/deps -L dependency=/tmp/cargo-installa2jlTk/release/deps --extern bitflags=/tmp/cargo-installa2jlTk/release/deps/libbitflags-e53b4b50e5713d69.rlib --extern fallible_iterator=/tmp/cargo-installa2jlTk/release/deps/libfallible_iterator-229d1b548363649b.rlib --extern fallible_streaming_iterator=/tmp/cargo-installa2jlTk/release/deps/libfallible_streaming_iterator-3dc8799337b38106.rlib --extern lazy_static=/tmp/cargo-installa2jlTk/release/deps/liblazy_static-b92b4a1bf6babc8c.rlib --extern libsqlite3_sys=/tmp/cargo-installa2jlTk/release/deps/liblibsqlite3_sys-fec7266de6e25bdf.rlib --extern lru_cache=/tmp/cargo-installa2jlTk/release/deps/liblru_cache-b6c9918432310b68.rlib --extern memchr=/tmp/cargo-installa2jlTk/release/deps/libmemchr-292d84c02d2d5263.rlib --extern time=/tmp/cargo-installa2jlTk/release/deps/libtime-d82d709fd943c2c8.rlib --cap-lints allow -L native=/tmp/cargo-installa2jlTk/release/build/libsqlite3-sys-0f04e3e46e346ca2/out` (exit code: 1)
~~~


Discussion / hints:
Thanks for the detailed report. I can reproduce this on 1.36.0 stable. I guess it's caused by the unsoundness fixes Rust added in 1.36. It probably needs to be fixed in rusqlite. I'll open an issue there, see what they think.

Fix patch:
diff --git a/.travis.yml b/.travis.yml
index 470503f6..15eff2d1 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -36,13 +36,11 @@ matrix:
           rust: nightly
           # XML_CATALOG_FILES is apparently necessary for asciidoc on macOS.
           env: TARGET=x86_64-apple-darwin XML_CATALOG_FILES=/usr/local/etc/xml/catalog
-        # Minimum Rust supported channel. We enable these to make sure ripgrep
-        # continues to work on the advertised minimum Rust version.
         - os: linux
-          rust: 1.35.0
+          rust: stable
           env: TARGET=x86_64-unknown-linux-gnu
         - os: linux
-          rust: 1.35.0
+          rust: stable
           env: TARGET=x86_64-unknown-linux-musl
         #- os: linux
         # rust: 1.35.0
diff --git a/Cargo.lock b/Cargo.lock
index 611d9b1c..b2f6b5ba 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -460,7 +460,7 @@ dependencies = [
 
 [[package]]
 name = "libsqlite3-sys"
-version = "0.15.0"
+version = "0.16.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -957,7 +957,7 @@ dependencies = [
  "path-clean 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "rkv 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "rusqlite 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rusqlite 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)",
  "size_format 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -991,14 +991,14 @@ dependencies = [
 
 [[package]]
 name = "rusqlite"
-version = "0.19.0"
+version = "0.20.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "fallible-streaming-iterator 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
  "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "libsqlite3-sys 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libsqlite3-sys 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1455,7 +1455,7 @@ dependencies = [
 "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14"
 "checksum libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)" = "6281b86796ba5e4366000be6e9e18bf35580adf9e63fbe2294aadb587613a319"
 "checksum libflate 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)" = "76912aa0196b6f0e06d9c43ee877be45369157c06172ade12fe20ac3ee5ffa15"
-"checksum libsqlite3-sys 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "72b1e07fcc60484f42e246f0cf1f133940c98117c81b2cefcdf71be288069680"
+"checksum libsqlite3-sys 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5e5b95e89c330291768dc840238db7f9e204fd208511ab6319b56193a7f2ae25"
 "checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83"
 "checksum lmdb-rkv 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e25b4069789bf7ac069d6fd58229f18aec20c6f7cc9173cb731d11c10dbb6b6e"
 "checksum lmdb-rkv-sys 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1470e0168f1832e35afd6d0931ae60db625685332837b97aa156773ec9c5e393"
@@ -1513,7 +1513,7 @@ dependencies = [
 "checksum regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "dcfd8681eebe297b81d98498869d4aae052137651ad7b96822f09ceb690d0a96"
 "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5"
 "checksum rkv 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9ebeb7e046283b72b4bcd3b8ee4720cf69cd09f5b140b5ab46495df4af0e5113"
-"checksum rusqlite 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6ebca2e7e3deb7241b7fa5929c088548c590728b1b740c479594c23f813eb8a7"
+"checksum rusqlite 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2a194373ef527035645a1bc21b10dc2125f73497e6e155771233eb187aedd051"
 "checksum rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f4dccf6f4891ebcc0c39f9b6eb1a83b9bf5d747cb439ec6fba4f3b977038af"
 "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
 "checksum ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "b96a9549dc8d48f2c283938303c4b5a77aa29bfbc5b54b084fb1630408899a8f"
diff --git a/rust-toolchain b/rust-toolchain
new file mode 100644
index 00000000..2bf5ad04
--- /dev/null
+++ b/rust-toolchain
@@ -0,0 +1,1 @@
+stable
diff --git a/src/adapters/sqlite.rs b/src/adapters/sqlite.rs
index 09a3af3f..7a59f33e 100644
--- a/src/adapters/sqlite.rs
+++ b/src/adapters/sqlite.rs
@@ -46,7 +46,7 @@ fn format_blob(b: ValueRef) -> String {
         Null => "NULL".to_owned(),
         Integer(i) => format!("{}", i),
         Real(i) => format!("{}", i),
-        Text(i) => format!("'{}'", i.replace("'", "''")),
+        Text(i) => format!("'{}'", String::from_utf8_lossy(i).replace("'", "''")),
         Blob(b) => format!(
             "[blob {}B]",
             size_format::SizeFormatterSI::new(


Test patch: