tursodatabase / turso-driver-laravel

Turso Driver for Laravel with Native libSQL
https://turso.tech/sdk/php/guides/laravel
MIT License
59 stars 6 forks source link

[Bug]: Order of Package Installation Error #16

Closed nickwild-999 closed 1 month ago

nickwild-999 commented 1 month ago

What happened?

When I run composer require tursodatabase/turso-driver-laravel I get this error

...
@php artisan package:discover --ansi

   ErrorException 

  Undefined array key "syncUrl"

  at vendor/tursodatabase/turso-driver-laravel/src/Database/LibSQLDatabase.php:30
     26▕                 default => $config['url'],
     27▕             };
     28▕         }
     29▕ 
  ➜  30▕         $this->setConnectionMode($config['url'], $config['syncUrl'], $config['authToken'], $config['remoteOnly']);
     31▕ 
     32▕         $this->db = match ($this->connection_mode) {
     33▕             'local' => $this->createLibSQL(
     34▕                 $config['url'],

How to reproduce the bug

If you follow the order in the docs (i.e. composer require the library before setting the .env values) it fails on install. I have now entered values in .env and database.php and now no longer get this error. However I now get another error

thread '<unnamed>' panicked at src/providers/remote_replica.rs:66:14:
called `Result::unwrap()` on an `Err` value: ConnectionFailed("Can not sync a database without a wal_index, please delete the database and attempt again")
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread '<unnamed>' panicked at library/core/src/panicking.rs:221:5:
panic in a function that cannot unwind
stack backtrace:
   0:        0x10ae41f4c - <std::sys::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::he9a0910abc20c72b
   1:        0x10ae5d8b4 - core::fmt::write::h7a8b1161b2729ae2
   2:        0x10ae3f5c0 - std::io::Write::write_fmt::h307f2c9094c7b973
   3:        0x10ae41da4 - std::sys::backtrace::print::h6a6c7ad415701e23
   4:        0x10ae42f78 - std::panicking::default_hook::{{closure}}::h1c715af0db849489
   5:        0x10ae42c44 - std::panicking::default_hook::h26b69a1a9d040be0
   6:        0x10ae43960 - std::panicking::rust_panic_with_hook::hd487552b1d265f7a
   7:        0x10ae432d8 - std::panicking::begin_panic_handler::{{closure}}::he77a128a49e03af5
   8:        0x10ae423d0 - std::sys::backtrace::__rust_end_short_backtrace::h0c25066a690f7f8f
   9:        0x10ae42fc8 - _rust_begin_unwind
  10:        0x10ae77b9c - core::panicking::panic_nounwind_fmt::h7e50102aa14c89e2
  11:        0x10ae77c14 - core::panicking::panic_nounwind::h86f3739e17fb099a
  12:        0x10ae77d00 - core::panicking::panic_cannot_unwind::hb1f3942d03f6df6a
  13:        0x10a974d60 - ext_php_rs::builders::class::ClassBuilder::object_override::constructor::h93aa7bad26bf8103
  14:        0x10462b038 - _ZEND_DO_FCALL_SPEC_RETVAL_UNUSED_HANDLER
  15:        0x104608ebc - _execute_ex
  16:        0x1045d8374 - _zend_call_function
  17:        0x1044f43a4 - _zif_call_user_func
  18:        0x1046473f4 - _ZEND_DO_FCALL_BY_NAME_SPEC_RETVAL_USED_HANDLER
  19:        0x104608ebc - _execute_ex
  20:        0x1045d8374 - _zend_call_function
  21:        0x1045d884c - _zend_call_known_function
  22:        0x104687ea8 - _zend_std_read_dimension
  23:        0x104661228 - _zend_fetch_dimension_address_read_R_slow
  24:        0x104633b98 - _ZEND_FETCH_DIM_R_SPEC_TMPVAR_CV_HANDLER
  25:        0x104608ebc - _execute_ex
  26:        0x1045d8374 - _zend_call_function
  27:        0x1044e0850 - _php_array_walk
  28:        0x1044e04c8 - _zif_array_walk
  29:        0x104647188 - _ZEND_DO_FCALL_BY_NAME_SPEC_RETVAL_UNUSED_HANDLER
  30:        0x104608ebc - _execute_ex
  31:        0x1046090e8 - _zend_execute
  32:        0x1045d8f90 - _zend_eval_stringl
  33:        0x1045d90d4 - _zend_eval_stringl_ex
  34:        0x1046d14c0 - _do_cli
  35:        0x1046d00c0 - _main
thread caused non-unwinding panic. aborting.

Run the above code

Package Version

latest

PHP Version

8.3

Laravel Version

11.0.0

Which operating systems does with happen with?

macOS

Notes

No response

darkterminal commented 1 month ago

Can not sync a database without a wal_index, please delete the database and attempt again

Have you tried deleting the database?

This error shows that you want to use a remote replica/embedded replica connection. is that really what you want to do?

darkterminal commented 1 month ago

This issues is fix in latest version, please update the dependency for changes. Thank you, feel free to report if you've any trouble related to this driver.