Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building error #737

Closed
chenyukang opened this issue Dec 11, 2022 · 2 comments
Closed

Building error #737

chenyukang opened this issue Dec 11, 2022 · 2 comments
Labels
C-bug Category Bugs

Comments

@chenyukang
Copy link

chenyukang commented Dec 11, 2022

What type of bug is this?

Configuration, Unexpected error

What subsystems are affected?

Standalone mode, Other

What happened?

I'm completed newcomer for this project, so I follow the document try to build it locally, I work in WSL:

Linux LAPTOP-V6U0QKD4 5.15.79.1-microsoft-standard-WSL2 #1 SMP Wed Nov 23 01:01:46 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

There are two errors I met, the first one is:

cat@LAPTOP-V6U0QKD4:~/code/greptimedb$ cargo build
   Compiling nalgebra v0.27.1
   Compiling arrow v10.0.0
   Compiling arrow2 v0.10.1
   Compiling lalrpop v0.19.8
   Compiling h2 v0.3.14
   Compiling opentelemetry v0.17.0
   Compiling tower v0.4.13
   Compiling api v0.1.0 (/home/cat/code/greptimedb/src/api)
   Compiling reqsign v0.6.9
   Compiling etcd-client v0.10.2
   Compiling storage v0.1.0 (/home/cat/code/greptimedb/src/storage)
   Compiling tonic-reflection v0.5.0
   Compiling pgwire v0.6.1
   Compiling opensrv-mysql v0.3.0
   Compiling arrow v26.0.0
error: failed to run custom build command for `api v0.1.0 (/home/cat/code/greptimedb/src/api)`

Caused by:
  process didn't exit successfully: `/home/cat/code/greptimedb/target/debug/build/api-95d88fb37e7dc334/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-changed=greptime/v1/select.proto
  cargo:rerun-if-changed=greptime/v1/greptime.proto
  cargo:rerun-if-changed=greptime/v1/meta/common.proto
  cargo:rerun-if-changed=greptime/v1/meta/heartbeat.proto
  cargo:rerun-if-changed=greptime/v1/meta/route.proto
  cargo:rerun-if-changed=greptime/v1/meta/store.proto
  cargo:rerun-if-changed=prometheus/remote/remote.proto
  cargo:rerun-if-changed=.
  Running: "/usr/bin/protoc" "--include_imports" "--include_source_info" "-o" "/home/cat/code/greptimedb/target/debug/build/api-3dd1a27ebc3ab7c2/out/greptime_fd.bin" "-I" "." "greptime/v1/select.proto" "greptime/v1/greptime.proto" "greptime/v1/meta/common.proto" "greptime/v1/meta/heartbeat.proto" "greptime/v1/meta/route.proto" "greptime/v1/meta/store.proto" "prometheus/remote/remote.proto"

  --- stderr
  thread 'main' panicked at 'compile proto: Custom { kind: Other, error: "protoc failed: greptime/v1/column.proto:59:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default.\ngreptime/v1/select.proto: Import \"greptime/v1/column.proto\" was not found or had errors.\ngreptime/v1/select.proto:8:12: \"Column\" is not defined.\n" }', src/api/build.rs:33:10
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
^C  Building [=====================>   ] 711/782: nalgebra, arrow, h2, arrow, arrow2, lalrpop

This is caused by version of protoc is not right, I install protoc with command:

sudo  apt install -y protobuf-compiler

my local version is:

cat@LAPTOP-V6U0QKD4:~/code/greptimedb$ protoc --version
libprotoc 3.6.1

I give a quick fix for it:

cat@LAPTOP-V6U0QKD4:~/code/greptimedb$ git diff
diff --git a/src/api/greptime/v1/admin.proto b/src/api/greptime/v1/admin.proto
index 3f253cd..75e438b 100644
--- a/src/api/greptime/v1/admin.proto
+++ b/src/api/greptime/v1/admin.proto
@@ -33,22 +33,22 @@ message AdminResult {

 // TODO(hl): rename to CreateTableExpr
 message CreateExpr {
-  optional string catalog_name = 1;
-  optional string schema_name = 2;
+  string catalog_name = 1;
+  string schema_name = 2;
   string table_name = 3;
-  optional string desc = 4;
+  string desc = 4;
   repeated ColumnDef column_defs = 5;
   string time_index = 6;
   repeated string primary_keys = 7;
   bool create_if_not_exists = 8;
   map<string, string> table_options = 9;
-  optional uint32 table_id = 10;
+  uint32 table_id = 10;
   repeated uint32 region_ids = 11;
 }

 message AlterExpr {
-  optional string catalog_name = 1;
-  optional string schema_name = 2;
+  string catalog_name = 1;
+  string schema_name = 2;
   string table_name = 3;
   oneof kind {
     AddColumns add_columns = 4;
diff --git a/src/api/greptime/v1/column.proto b/src/api/greptime/v1/column.proto
index ec6993a..a693a9d 100644
--- a/src/api/greptime/v1/column.proto
+++ b/src/api/greptime/v1/column.proto
@@ -56,7 +56,7 @@ message ColumnDef {
   string name = 1;
   ColumnDataType datatype = 2;
   bool is_nullable = 3;
-  optional bytes default_constraint = 4;
+  bytes default_constraint = 4;
 }

Recommend add instructions on how to install the right version of deps(a prepare shell script will be good), so devlopers don't need to install it manually.

The second compiling error

cat@LAPTOP-V6U0QKD4:~/code/greptimedb$ cargo build
   Compiling rustpython-parser v0.1.2 (https://github.com/discord9/RustPython?rev=183e8dab#183e8dab)
   Compiling common-recordbatch v0.1.0 (/home/cat/code/greptimedb/src/common/recordbatch)
   Compiling api v0.1.0 (/home/cat/code/greptimedb/src/api)
   Compiling common-query v0.1.0 (/home/cat/code/greptimedb/src/common/query)
error[E0308]: mismatched types
  --> src/api/src/v1/column_def.rs:27:13
   |
26 |         let constraint = match &self.default_constraint {
   |                                ------------------------ this expression has type `&Vec<u8>`
27 |             None => None,
   |             ^^^^ expected struct `Vec`, found enum `Option`
   |
   = note: expected struct `Vec<u8>`
                found enum `Option<_>`

error[E0308]: mismatched types
  --> src/api/src/v1/column_def.rs:28:13
   |
26 |         let constraint = match &self.default_constraint {
   |                                ------------------------ this expression has type `&Vec<u8>`
27 |             None => None,
28 |             Some(v) => Some(
   |             ^^^^^^^ expected struct `Vec`, found enum `Option`
   |
   = note: expected struct `Vec<u8>`
                found enum `Option<_>`

For more information about this error, try `rustc --explain E0308`.
error: could not compile `api` due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
    Building [=======================> ] 751/782: rustpython-parser(build)

My rustc -vV is:

cat@LAPTOP-V6U0QKD4:~/code/greptimedb$ rustc -vV
rustc 1.64.0-nightly (87588a2af 2022-07-13)
binary: rustc
commit-hash: 87588a2afd9ca903366f0deaf84d805f34469384
commit-date: 2022-07-13
host: x86_64-unknown-linux-gnu
release: 1.64.0-nightly
LLVM version: 14.0.6

But it's too late now, may need more dig later.

What operating system did you use?

Linux LAPTOP-V6U0QKD4 5.15.79.1-microsoft-standard-WSL2 #1 SMP Wed Nov 23 01:01:46 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Relevant log output and stack trace

No response

How can we reproduce the bug?

Build in a refresh WSL?


Linux LAPTOP-V6U0QKD4 5.15.79.1-microsoft-standard-WSL2 #1 SMP Wed Nov 23 01:01:46 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
@chenyukang chenyukang added the C-bug Category Bugs label Dec 11, 2022
@waynexia
Copy link
Member

Hi @chenyukang, sorry for the convenient. This error is caused by the incorrect version of protoc, that's right. I'm afraid the newly updated version 3.6.1 is not enough. I've searched the ubuntu package list, and it looks like you need a newer ubuntu to reach the requirement (through #616 3.12 may work). If your system is not ready for update maybe through docker to achieve this is a better choice. Or another workaround is install the pre-build binary from protobuf's github release, protoc-*-linux-x86_64.zip is what suit your system.

And the second compile error is caused by those optional keywords in .proto files you removed. It changes the types in the generated code. Revert those changes should fix this (after a correct version of protoc is installed). Thanks for your patient, please let us know if it works for you ❤️

@chenyukang
Copy link
Author

Yes,it works, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category Bugs
Projects
None yet
Development

No branches or pull requests

2 participants