[GH-ISSUE #1298] [regression] Failed to init new instance #747

Closed
opened 2026-02-26 02:34:09 +03:00 by kerem · 5 comments
Owner

Originally created by @vitoyucepi on GitHub (Mar 30, 2021).
Original GitHub issue: https://github.com/koel/koel/issues/1298

Describe the bug
In version 5.1 I can't create new instance of koel because of error.

web_1      | Application key set successfully.
web_1      | Attempting to install or upgrade Koel.
web_1      | Remember, you can always install/upgrade manually following the guide here:
web_1      | 📙  https://docs.koel.dev
web_1      | 
web_1      | Running in no-interaction mode
web_1      | App key exists -- skipping
web_1      | Migrating database
web_1      | Oops! Koel installation or upgrade didn't finish successfully.
web_1      | Please try again, or visit https://docs.koel.dev for manual installation.
web_1      | 😥 Sorry for this. You deserve better.

To reproduce
Steps to reproduce the behavior:

  1. Install koel 5.1.0
  2. Check all variables are set
    DB_CONNECTION=mysql
    DB_HOST=db
    DB_DATABASE=koel
    DB_USERNAME=koel
    DB_PASSWORD=koel
    ADMIN_NAME=admin
    ADMIN_EMAIL=admin@localhost
    ADMIN_PASSWORD=admin
    CACHE_DRIVER=apc
    STREAMING_METHOD=x-sendfile
    MEDIA_PATH="/music"
    FFMPEG_PATH="/usr/bin/ffmpeg"    
    
  3. Init new instance with command su www-data -s /bin/sh 'php artisan koel:init --no-interaction --no-assets'
    The idea is to use www-data user.
  4. Get installation error

Expected behavior
No init errors.
If init script failed it should exit with non-zero return code.

Environment

  • Koel version: 5.1.0
  • OS: docker(php:7.4.16-apache) on archlinux
  • Browser: Chrome 89
  • PHP version: 7.4.16
  • Node version: N/A

Additional context
Upgrade from 5.0.2 to 5.1.0 is ok by the way.

In koel 5.0.2 koel/storage/search-indexes/ dir is present in tarball, but in 5.1.0 it's absent. This is the cause of error.
Why this happened

  1. I mount volume as storage/search-indexes.
  2. Mount point owner is root:root.
  3. www-data is not able to create directories.
Originally created by @vitoyucepi on GitHub (Mar 30, 2021). Original GitHub issue: https://github.com/koel/koel/issues/1298 **Describe the bug** In version 5.1 I can't create new instance of koel because of error. ``` web_1 | Application key set successfully. web_1 | Attempting to install or upgrade Koel. web_1 | Remember, you can always install/upgrade manually following the guide here: web_1 | 📙 https://docs.koel.dev web_1 | web_1 | Running in no-interaction mode web_1 | App key exists -- skipping web_1 | Migrating database web_1 | Oops! Koel installation or upgrade didn't finish successfully. web_1 | Please try again, or visit https://docs.koel.dev for manual installation. web_1 | 😥 Sorry for this. You deserve better. ``` **To reproduce** Steps to reproduce the behavior: 1. Install koel 5.1.0 1. Check all variables are set ``` DB_CONNECTION=mysql DB_HOST=db DB_DATABASE=koel DB_USERNAME=koel DB_PASSWORD=koel ADMIN_NAME=admin ADMIN_EMAIL=admin@localhost ADMIN_PASSWORD=admin CACHE_DRIVER=apc STREAMING_METHOD=x-sendfile MEDIA_PATH="/music" FFMPEG_PATH="/usr/bin/ffmpeg" ``` 1. Init new instance with command `su www-data -s /bin/sh 'php artisan koel:init --no-interaction --no-assets'` The idea is to use www-data user. 1. Get installation error **Expected behavior** No init errors. If init script failed it should exit with non-zero return code. **Environment** - Koel version: 5.1.0 - OS: docker(php:7.4.16-apache) on archlinux - Browser: Chrome 89 - PHP version: 7.4.16 - Node version: N/A **Additional context** Upgrade from 5.0.2 to 5.1.0 is ok by the way. In koel 5.0.2 `koel/storage/search-indexes/` dir is present in tarball, but in 5.1.0 it's absent. This is the cause of error. Why this happened 1. I mount volume as `storage/search-indexes`. 2. Mount point owner is `root:root`. 3. `www-data` is not able to create directories.
kerem closed this issue 2026-02-26 02:34:09 +03:00
Author
Owner

@vitoyucepi commented on GitHub (Mar 30, 2021):

It seems the problem is on my side.

But I think indexes shouldn't be stored in sqlite anyway.

Also init script should return non-zero if it fails.

<!-- gh-comment-id:810006770 --> @vitoyucepi commented on GitHub (Mar 30, 2021): It seems the problem is on my side. But I think indexes shouldn't be stored in sqlite anyway. Also `init` script should return non-zero if it fails.
Author
Owner

@MichaIng commented on GitHub (Apr 9, 2021):

Same here, on a fresh install. Strange is that when running koel:init more often, each time it gets one step further each time and finally has a functional instance:

sudo -u koel php7.3 artisan koel:init --no-assets
# sudo -u koel php7.3 artisan koel:init --no-assets
Attempting to install or upgrade Koel.
Remember, you can always install/upgrade manually following the guide here:
📙  https://docs.koel.dev

App key exists -- skipping
Migrating database
Oops! Koel installation or upgrade didn't finish successfully.
Please try again, or visit https://docs.koel.dev for manual installation.
😥 Sorry for this. You deserve better.
# sudo -u koel php7.3 artisan koel:init --no-assets
Attempting to install or upgrade Koel.
Remember, you can always install/upgrade manually following the guide here:
📙  https://docs.koel.dev

App key exists -- skipping
Migrating database
Creating default admin account
Seeding initial data
Oops! Koel installation or upgrade didn't finish successfully.
Please try again, or visit https://docs.koel.dev for manual installation.
😥 Sorry for this. You deserve better.
# sudo -u koel php7.3 artisan koel:init --no-assets
Attempting to install or upgrade Koel.
Remember, you can always install/upgrade manually following the guide here:
📙  https://docs.koel.dev

App key exists -- skipping
Migrating database
Data seeded -- skipping
The absolute path to your media directory. If this is skipped (left blank) now, you can set it later via the web interface.

 Media path []:
 > /path/to/media


🎆  Success! Koel can now be run from localhost with `php artisan serve`.
You can also scan for media with `php artisan koel:sync`.
Again, visit 📙 https://docs.koel.dev for the official documentation.
Feeling generous and want to support Koel's development? Check out https://github.com/users/phanan/sponsorship 🤗
Thanks for using Koel. You rock! 🤘
Another step when the key is missing 😉. It seems like while each init step actually succeeds, an exception is thrown, exiting the script.

Next is failing library since. Similarly it required some more attempts before it succeeds:

sudo -u koel php7.3 artisan koel:sync
# sudo -u koel php7.3 artisan koel:sync
Syncing media from /path/to/media


   PDOException

  SQLSTATE[HY000] [14] unable to open database file

  at vendor/teamtnt/tntsearch/src/Indexer/TNTIndexer.php:178
    174▕         if (file_exists($this->config['storage'].$indexName)) {
    175▕             unlink($this->config['storage'].$indexName);
    176▕         }
    177▕
  ➜ 178▕         $this->index = new PDO('sqlite:'.$this->config['storage'].$indexName);
    179▕         $this->index->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    180▕
    181▕         if($this->config['wal']) {
    182▕             $this->index->exec("PRAGMA journal_mode=wal;");

      +20 vendor frames
  21  app/Models/Album.php:79
      Illuminate\Database\Eloquent\Model::__callStatic("firstOrCreate")

  22  app/Services/FileSynchronizer.php:199
      App\Models\Album::getOrCreate(Object(App\Models\Artist), "")
# sudo -u koel php7.3 artisan koel:sync
Syncing media from /path/to/media


   PDOException

  SQLSTATE[HY000] [14] unable to open database file

  at vendor/teamtnt/tntsearch/src/Indexer/TNTIndexer.php:178
    174▕         if (file_exists($this->config['storage'].$indexName)) {
    175▕             unlink($this->config['storage'].$indexName);
    176▕         }
    177▕
  ➜ 178▕         $this->index = new PDO('sqlite:'.$this->config['storage'].$indexName);
    179▕         $this->index->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    180▕
    181▕         if($this->config['wal']) {
    182▕             $this->index->exec("PRAGMA journal_mode=wal;");

      +20 vendor frames
  21  app/Services/FileSynchronizer.php:209
      Illuminate\Database\Eloquent\Model::__callStatic("updateOrCreate")

  22  app/Services/MediaSyncService.php:112
      App\Services\FileSynchronizer::sync()
# sudo -u koel php7.3 artisan koel:sync
Syncing media from /path/to/media

 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

Completed! 0 new or updated song(s), 1 unchanged song(s), and 0 invalid file(s).

Interesting here that sqlite: storage driver seems to be hardcoded, while MariaDB is configured and used. I already recognised that composer install fails when no SQLite PHP modules are enabled (both: sqlite3 and pdo_sqlite). From then on, I have a functional server, even after disabling and removing all SQLite PHP modules.

<!-- gh-comment-id:816872063 --> @MichaIng commented on GitHub (Apr 9, 2021): Same here, on a fresh install. Strange is that when running `koel:init` more often, each time it gets one step further each time and finally has a functional instance: <details> <summary>sudo -u koel php7.3 artisan koel:init --no-assets</summary> ``` # sudo -u koel php7.3 artisan koel:init --no-assets Attempting to install or upgrade Koel. Remember, you can always install/upgrade manually following the guide here: 📙 https://docs.koel.dev App key exists -- skipping Migrating database Oops! Koel installation or upgrade didn't finish successfully. Please try again, or visit https://docs.koel.dev for manual installation. 😥 Sorry for this. You deserve better. # sudo -u koel php7.3 artisan koel:init --no-assets Attempting to install or upgrade Koel. Remember, you can always install/upgrade manually following the guide here: 📙 https://docs.koel.dev App key exists -- skipping Migrating database Creating default admin account Seeding initial data Oops! Koel installation or upgrade didn't finish successfully. Please try again, or visit https://docs.koel.dev for manual installation. 😥 Sorry for this. You deserve better. # sudo -u koel php7.3 artisan koel:init --no-assets Attempting to install or upgrade Koel. Remember, you can always install/upgrade manually following the guide here: 📙 https://docs.koel.dev App key exists -- skipping Migrating database Data seeded -- skipping The absolute path to your media directory. If this is skipped (left blank) now, you can set it later via the web interface. Media path []: > /path/to/media 🎆 Success! Koel can now be run from localhost with `php artisan serve`. You can also scan for media with `php artisan koel:sync`. Again, visit 📙 https://docs.koel.dev for the official documentation. Feeling generous and want to support Koel's development? Check out https://github.com/users/phanan/sponsorship 🤗 Thanks for using Koel. You rock! 🤘 ``` </details> Another step when the key is missing 😉. It seems like while each init step actually succeeds, an exception is thrown, exiting the script. Next is failing library since. Similarly it required some more attempts before it succeeds: <details> <summary>sudo -u koel php7.3 artisan koel:sync</summary> ``` # sudo -u koel php7.3 artisan koel:sync Syncing media from /path/to/media PDOException SQLSTATE[HY000] [14] unable to open database file at vendor/teamtnt/tntsearch/src/Indexer/TNTIndexer.php:178 174▕ if (file_exists($this->config['storage'].$indexName)) { 175▕ unlink($this->config['storage'].$indexName); 176▕ } 177▕ ➜ 178▕ $this->index = new PDO('sqlite:'.$this->config['storage'].$indexName); 179▕ $this->index->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 180▕ 181▕ if($this->config['wal']) { 182▕ $this->index->exec("PRAGMA journal_mode=wal;"); +20 vendor frames 21 app/Models/Album.php:79 Illuminate\Database\Eloquent\Model::__callStatic("firstOrCreate") 22 app/Services/FileSynchronizer.php:199 App\Models\Album::getOrCreate(Object(App\Models\Artist), "") # sudo -u koel php7.3 artisan koel:sync Syncing media from /path/to/media PDOException SQLSTATE[HY000] [14] unable to open database file at vendor/teamtnt/tntsearch/src/Indexer/TNTIndexer.php:178 174▕ if (file_exists($this->config['storage'].$indexName)) { 175▕ unlink($this->config['storage'].$indexName); 176▕ } 177▕ ➜ 178▕ $this->index = new PDO('sqlite:'.$this->config['storage'].$indexName); 179▕ $this->index->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 180▕ 181▕ if($this->config['wal']) { 182▕ $this->index->exec("PRAGMA journal_mode=wal;"); +20 vendor frames 21 app/Services/FileSynchronizer.php:209 Illuminate\Database\Eloquent\Model::__callStatic("updateOrCreate") 22 app/Services/MediaSyncService.php:112 App\Services\FileSynchronizer::sync() # sudo -u koel php7.3 artisan koel:sync Syncing media from /path/to/media 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100% Completed! 0 new or updated song(s), 1 unchanged song(s), and 0 invalid file(s). ``` </details> Interesting here that `sqlite:` storage driver seems to be hardcoded, while MariaDB is configured and used. I already recognised that composer install fails when no SQLite PHP modules are enabled (both: `sqlite3` and `pdo_sqlite`). From then on, I have a functional server, even after disabling and removing all SQLite PHP modules.
Author
Owner

@phanan commented on GitHub (Apr 11, 2021):

The index is by TNTSearch, which uses an SQLite database. Koel has no part in this regard.
@MichaIng Please open another ticket if you believe the details are bugs.

<!-- gh-comment-id:817347084 --> @phanan commented on GitHub (Apr 11, 2021): The index is by TNTSearch, which uses an SQLite database. Koel has no part in this regard. @MichaIng Please open another ticket if you believe the details are bugs.
Author
Owner

@MichaIng commented on GitHub (Apr 11, 2021):

The index uses TNTSearch, which uses an SQLite database.

Does it mean that SQLite + the PHP SQLite module both need to be installed on the system for koel:init to succeed? I thought I tried that already but will assure and retry in case, before opening a dedicated issue.

<!-- gh-comment-id:817349624 --> @MichaIng commented on GitHub (Apr 11, 2021): > The index uses TNTSearch, which uses an SQLite database. Does it mean that SQLite + the PHP SQLite module both need to be installed on the system for `koel:init` to succeed? I thought I tried that already but will assure and retry in case, before opening a dedicated issue.
Author
Owner

@phanan commented on GitHub (Apr 11, 2021):

I don't think you need it for koel:init, but you'll need it if you use TNTSearch (instead of e.g., Algolia) and scan for music.

<!-- gh-comment-id:817351095 --> @phanan commented on GitHub (Apr 11, 2021): I don't think you need it for `koel:init`, but you'll need it if you use TNTSearch (instead of e.g., Algolia) and scan for music.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/koel-koel#747
No description provided.