thoughtbot / factory_bot

A library for setting up Ruby objects as test data.
https://thoughtbot.com
MIT License
7.91k stars 2.6k forks source link

Update the minimum version of sqlite3 #1667

Closed smaboshe closed 1 month ago

smaboshe commented 3 months ago

When running bundle install, are having an issue with sqlite3 version 1.4.2. It is not building on CI, M1 or Intel chips:

Building native extensions. This could take a while...
ERROR:  Error installing sqlite3:
        ERROR: Failed to build gem native extension.

    current directory: ~/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/sqlite3-1.4.2/ext/sqlite3
~/.asdf/installs/ruby/3.3.4/bin/ruby extconf.rb
checking for pkg-config for sqlite3... ["-I/opt/homebrew/opt/sqlite/include ", "-L/opt/homebrew/opt/sqlite/lib", "-lsqlite3"]
checking for sqlite3.h... yes
checking for pthread_create() in -lpthread... yes
checking for -ldl... yes
checking for sqlite3_libversion_number() in -lsqlite3... yes
checking for rb_proc_arity()... yes
checking for rb_integer_pack()... yes
checking for sqlite3_initialize()... yes
checking for sqlite3_backup_init()... yes
checking for sqlite3_column_database_name()... yes
checking for sqlite3_enable_load_extension()... yes
checking for sqlite3_load_extension()... yes
checking for sqlite3_open_v2()... yes
checking for sqlite3_prepare_v2()... yes
checking for sqlite3_int64 in sqlite3.h... yes
checking for sqlite3_uint64 in sqlite3.h... yes
creating Makefile

current directory: ~/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/sqlite3-1.4.2/ext/sqlite3
make DESTDIR\= sitearchdir\=./.gem.20240719-68199-43z80t sitelibdir\=./.gem.20240719-68199-43z80t clean

current directory: ~/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/sqlite3-1.4.2/ext/sqlite3
make DESTDIR\= sitearchdir\=./.gem.20240719-68199-43z80t sitelibdir\=./.gem.20240719-68199-43z80t
compiling aggregator.c
compiling backup.c
compiling database.c
database.c:38:9: warning: unused variable 'flags' [-Wunused-variable]
  VALUE flags;
        ^
database.c:109:18: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  return INT2NUM((long)sqlite3_total_changes(ctx->db));
         ~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
database.c:150:67: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  VALUE result = rb_funcall(handle, rb_intern("call"), 1, INT2NUM((long)count));
                                                          ~~~~~~~ ^~~~~~~~~~~
database.c:395:18: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  return INT2NUM((long)sqlite3_errcode(ctx->db));
         ~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
database.c:726:57: error: incompatible function pointer types passing 'int (VALUE, int, char **, char **)' (aka 'int (unsigned long, int, char **, char **)') to parameter of type 'int (*)(void *, int, char **, char **)' [-Wincompatible-function-pointer-types]
    status = sqlite3_exec(ctx->db, StringValuePtr(sql), hash_callback_function, callback_ary, &errMsg);
                                                        ^~~~~~~~~~~~~~~~~~~~~~
/opt/homebrew/opt/sqlite/include/sqlite3.h:430:9: note: passing argument to parameter 'callback' here
  int (*callback)(void*,int,char**,char**),  /* Callback function */
        ^
database.c:726:81: error: incompatible integer to pointer conversion passing 'VALUE' (aka 'unsigned long') to parameter of type 'void *' [-Wint-conversion]
    status = sqlite3_exec(ctx->db, StringValuePtr(sql), hash_callback_function, callback_ary, &errMsg);
                                                                                ^~~~~~~~~~~~
/opt/homebrew/opt/sqlite/include/sqlite3.h:431:9: note: passing argument to parameter here
  void *,                                    /* 1st argument to callback */
        ^
database.c:728:57: error: incompatible function pointer types passing 'int (VALUE, int, char **, char **)' (aka 'int (unsigned long, int, char **, char **)') to parameter of type 'int (*)(void *, int, char **, char **)' [-Wincompatible-function-pointer-types]
    status = sqlite3_exec(ctx->db, StringValuePtr(sql), regular_callback_function, callback_ary, &errMsg);
                                                        ^~~~~~~~~~~~~~~~~~~~~~~~~
/opt/homebrew/opt/sqlite/include/sqlite3.h:430:9: note: passing argument to parameter 'callback' here
  int (*callback)(void*,int,char**,char**),  /* Callback function */
        ^
database.c:728:84: error: incompatible integer to pointer conversion passing 'VALUE' (aka 'unsigned long') to parameter of type 'void *' [-Wint-conversion]
    status = sqlite3_exec(ctx->db, StringValuePtr(sql), regular_callback_function, callback_ary, &errMsg);
                                                                                   ^~~~~~~~~~~~
/opt/homebrew/opt/sqlite/include/sqlite3.h:431:9: note: passing argument to parameter here
  void *,                                    /* 1st argument to callback */
        ^
4 warnings and 4 errors generated.
make: *** [database.o] Error 1

make failed, exit code 2

Gem files will remain installed in ~/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/sqlite3-1.4.2 for inspection.
Results logged to ~/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/extensions/arm64-darwin-23/3.3.0/sqlite3-1.4.2/gem_make.out

sqlite3 version 1.4.2 was released on 18 December 2019.

In this commit, we are bumping the Appraisal versions of sqlite3 to resolve this issue as it is currently blocking CI

Ref:

sarahraqueld commented 1 month ago

Closing as this is not needed anymore after https://github.com/thoughtbot/factory_bot/pull/1686