Laravel-excel: [BUG] queueImport on production errors on the second chunk.

Created on 13 Nov 2019  路  3Comments  路  Source: Maatwebsite/Laravel-Excel

Prerequisites

  • [X] Checked if your Laravel Excel version is still supported: https://docs.laravel-excel.com/3.1/getting-started/support.html#supported-versions
  • [ ] Able to reproduce the behaviour outside of your code, the problem is isolated to Laravel Excel.
  • [X] Checked that your issue isn't already filed.
  • [X] Checked if no PR was submitted that fixes this problem.
  • [X] Filled in the entire issue template

Versions

  • PHP version: 7.1.12
  • Laravel version: 5.8.35
  • Package version: 3.1.17

Description

I'm using queueImport to import from csv to DB. The issue I'm facing is that when I import the csv and it will successfully imported the first batch of chunk but in the second chunk I get an error of unlink(/tmp/laravel-excel-ngc7Tv0LIfFIuRWZeaMNMgNzh6PEmUSw): Operation not permitted. I also tested and copied the commit of this issue #2434 to my project but the error still persist.
It only errors on production when the php artisan queue:work is called from the cronjob of www-data but when I call php artisan queue:work on the root folder there is no problem at all. Running in bitnami aws ubuntu, perfectly fine in development environment, windows;

This is my code in the Import

public function chunkSize(): int
{
    return 1000;
}

public function registerEvents(): array
{
    return [
        BeforeImport::class => function(BeforeImport $event) {
            Log::info('Importing inventory');
            Cache::set('importing-inventory-'.$this->store->id, true);
        },
    ];
}

Adding also the stacktrace

(/tmp/laravel-excel-ngc7Tv0LIfFIuRWZeaMNMgNzh6PEmUSw): Operation not permitted {"exception":"[object] (ErrorException(code: 0): unlink(/tmp/laravel-excel-ngc7Tv0LIfFIuRWZeaMNMgNzh6PEmUSw): Operation not permitted at /opt/bitnami/apache2/htdocs/inventory/app/vendor/maatwebsite/excel/src/Files/LocalTemporaryFile.php:46)
[stacktrace]
#0 [internal function]: Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(2, 'unlink(/tmp/lar...', '/opt/bitnami/ap...', 46, Array)
#1 /opt/bitnami/apache2/htdocs/amazon-inventory-management/restock-manager-app/vendor/maatwebsite/excel/src/Files/LocalTemporaryFile.php(46): unlink('/tmp/laravel-ex...')
#2 /opt/bitnami/apache2/htdocs/amazon-inventory-management/restock-manager-app/vendor/maatwebsite/excel/src/Reader.php(420): Maatwebsite\\Excel\\Files\\LocalTemporaryFile->delete()
#3 /opt/bitnami/apache2/htdocs/amazon-inventory-management/restock-manager-app/vendor/maatwebsite/excel/src/Reader.php(248): Maatwebsite\\Excel\\Reader->garbageCollect()

bug

Most helpful comment

This problem happened to me but on the localhost and I solved the problem by changing the permission of the "/tmp/" directory using the following command
sudo chmod -R 777 /tmp/

All 3 comments

This problem happened to me but on the localhost and I solved the problem by changing the permission of the "/tmp/" directory using the following command
sudo chmod -R 777 /tmp/

@OmarAbdelaziz646 thank you sir. That鈥檚 what I did.

This problem happened to me but on the localhost and I solved the problem by changing the permission of the "/tmp/" directory using the following command
sudo chmod -R 777 /tmp/

This worked for me. Thanks ! :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

matthewslouismarie picture matthewslouismarie  路  3Comments

dr3ads picture dr3ads  路  3Comments

octoxan picture octoxan  路  3Comments

lucatamtam picture lucatamtam  路  3Comments

amine8ghandi8amine picture amine8ghandi8amine  路  3Comments