IAPark / tiktoken_ruby

Unofficial ruby binding for tiktoken by way of rust
MIT License
118 stars 26 forks source link

"Failed to build gem native extension" on Linux (Ubuntu) #7

Open bdegomme opened 1 year ago

bdegomme commented 1 year ago

Thanks for the great gem. Had the following error-trace when trying to install the gem

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
....
--- stderr
Using bindgen with clang args:
["-I/home/bdegomme/.rbenv/versions/3.1.3/include/ruby-3.1.0",
"-I/home/bdegomme/.rbenv/versions/3.1.3/include/ruby-3.1.0/x86_64-linux",
"-fms-extensions", "-O3", "-fno-fast-math", "-ggdb3", "-Wall", "-Wextra",
"-Wdeprecated-declarations", "-Wduplicated-cond", "-Wimplicit-function-declaration",
"-Wimplicit-int", "-Wmisleading-indentation", "-Wpointer-arith", "-Wwrite-strings",
"-Wold-style-definition", "-Wimplicit-fallthrough=0", "-Wmissing-noreturn",
"-Wno-cast-function-type", "-Wno-constant-logical-operand", "-Wno-long-long",
"-Wno-missing-field-initializers", "-Wno-overlength-strings",
"-Wno-packed-bitfield-compat", "-Wno-parentheses-equality", "-Wno-self-assign",
"-Wno-tautological-compare", "-Wno-unused-parameter", "-Wno-unused-value",
"-Wsuggest-attribute=format", "-Wsuggest-attribute=noreturn", "-Wunused-variable",
"-Wundef", "-I/home/bdegomme/.rbenv/versions/3.1.3/include"]
  warning: unknown warning option '-Wduplicated-cond' [-Wunknown-warning-option]
warning: unknown warning option '-Wimplicit-fallthrough=0'; did you mean
'-Wimplicit-fallthrough'? [-Wunknown-warning-option]
warning: unknown warning option '-Wno-packed-bitfield-compat'
[-Wunknown-warning-option]
warning: unknown warning option '-Wsuggest-attribute=format'; did you mean
'-Wproperty-attribute-mismatch'? [-Wunknown-warning-option]
warning: unknown warning option '-Wsuggest-attribute=noreturn'
[-Wunknown-warning-option]
/home/bdegomme/.rbenv/versions/3.1.3/include/ruby-3.1.0/ruby/ruby.h:23:10: fatal
error: 'stdarg.h' file not found
clang diag: warning: unknown warning option '-Wduplicated-cond'
[-Wunknown-warning-option]
clang diag: warning: unknown warning option '-Wimplicit-fallthrough=0'; did you
mean '-Wimplicit-fallthrough'? [-Wunknown-warning-option]
clang diag: warning: unknown warning option '-Wno-packed-bitfield-compat'
[-Wunknown-warning-option]
clang diag: warning: unknown warning option '-Wsuggest-attribute=format'; did you
mean '-Wproperty-attribute-mismatch'? [-Wunknown-warning-option]
clang diag: warning: unknown warning option '-Wsuggest-attribute=noreturn'
[-Wunknown-warning-option]
thread 'main' panicked at 'generate bindings:
ClangDiagnostic("/home/xxx/.rbenv/versions/3.1.3/include/ruby-3.1.0/ruby/ruby.h:23:10:
fatal error: 'stdarg.h' file not found\n")'

Resolved it by installing the latest version of clang sudo apt install clang

Putting this here for anyone who might have the same issue.