Unexpected Laravel 5 errors using Vagrant

327 Views Asked by At

I'm usign a project structure using vagrant + puppet + capistrano + Laravel 5 for my API and I was working very well deploying from my local to the stage for 1 month but suddenly from yesterday I can't execute my local environment.

When I up my vagrant machine doesn't show any error and I already deleted the box, the instance, re-installed VirtualBox and Vagrant and still the same error and the weirdest thing is in other computer works fine with no issues.

The error always happens when I update/install with composer in "Generating autoload files"

    Generating autoload files
PHP Warning:  strpos(): Empty needle in /var/www/ubiq/src/vendor/vlucas/phpdotenv/src/Dotenv.php on line 51
PHP Stack trace:
PHP   1. {main}() /var/www/ubiq/src/artisan:0
PHP   2. Illuminate\Foundation\Console\Kernel->handle() /var/www/ubiq/src/artisan:36
PHP   3. Illuminate\Foundation\Console\Kernel->bootstrap() /var/www/ubiq/src/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:92
PHP   4. Illuminate\Foundation\Application->bootstrapWith() /var/www/ubiq/src/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:195
PHP   5. Illuminate\Foundation\Bootstrap\DetectEnvironment->bootstrap() /var/www/ubiq/src/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:183
PHP   6. Dotenv::load() /var/www/ubiq/src/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/DetectEnvironment.php:19
PHP   7. strpos() /var/www/ubiq/src/vendor/vlucas/phpdotenv/src/Dotenv.php:51

Warning: strpos(): Empty needle in /var/www/ubiq/src/vendor/vlucas/phpdotenv/src/Dotenv.php on line 51

Call Stack:
    0.0008     224352   1. {main}() /var/www/ubiq/src/artisan:0
    0.1363    1862536   2. Illuminate\Foundation\Console\Kernel->handle() /var/www/ubiq/src/artisan:36
    0.1363    1862664   3. Illuminate\Foundation\Console\Kernel->bootstrap() /var/www/ubiq/src/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:92
    0.1363    1862848   4. Illuminate\Foundation\Application->bootstrapWith() /var/www/ubiq/src/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:195
    0.1391    1869392   5. Illuminate\Foundation\Bootstrap\DetectEnvironment->bootstrap() /var/www/ubiq/src/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:183
    0.1425    1913168   6. Dotenv::load() /var/www/ubiq/src/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/DetectEnvironment.php:19
    0.1438    1916832   7. strpos() /var/www/ubiq/src/vendor/vlucas/phpdotenv/src/Dotenv.php:51

PHP Warning:  strpos(): Empty needle in /var/www/ubiq/src/vendor/vlucas/phpdotenv/src/Dotenv.php on line 51
PHP Stack trace:
PHP   1. {main}() /var/www/ubiq/src/artisan:0
PHP   2. Illuminate\Foundation\Console\Kernel->handle() /var/www/ubiq/src/artisan:36
PHP   3. Illuminate\Foundation\Console\Kernel->bootstrap() /var/www/ubiq/src/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:92
PHP   4. Illuminate\Foundation\Application->bootstrapWith() /var/www/ubiq/src/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:195
PHP   5. Illuminate\Foundation\Bootstrap\DetectEnvironment->bootstrap() /var/www/ubiq/src/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:183
PHP   6. Dotenv::load() /var/www/ubiq/src/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/DetectEnvironment.php:19
PHP   7. strpos() /var/www/ubiq/src/vendor/vlucas/phpdotenv/src/Dotenv.php:51

Warning: strpos(): Empty needle in /var/www/ubiq/src/vendor/vlucas/phpdotenv/src/Dotenv.php on line 51

Call Stack:
    0.0008     224352   1. {main}() /var/www/ubiq/src/artisan:0
    0.1363    1862536   2. Illuminate\Foundation\Console\Kernel->handle() /var/www/ubiq/src/artisan:36
    0.1363    1862664   3. Illuminate\Foundation\Console\Kernel->bootstrap() /var/www/ubiq/src/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:92
    0.1363    1862848   4. Illuminate\Foundation\Application->bootstrapWith() /var/www/ubiq/src/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:195
    0.1391    1869392   5. Illuminate\Foundation\Bootstrap\DetectEnvironment->bootstrap() /var/www/ubiq/src/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:183
    0.1425    1913168   6. Dotenv::load() /var/www/ubiq/src/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/DetectEnvironment.php:19
    0.1454    1916824   7. strpos() /var/www/ubiq/src/vendor/vlucas/phpdotenv/src/Dotenv.php:51

PHP Warning:  strpos(): Empty needle in /var/www/ubiq/src/vendor/vlucas/phpdotenv/src/Dotenv.php on line 51
PHP Stack trace:
PHP   1. {main}() /var/www/ubiq/src/artisan:0
PHP   2. Illuminate\Foundation\Console\Kernel->handle() /var/www/ubiq/src/artisan:36
PHP   3. Illuminate\Foundation\Console\Kernel->bootstrap() /var/www/ubiq/src/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:92
PHP   4. Illuminate\Foundation\Application->bootstrapWith() /var/www/ubiq/src/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:195
PHP   5. Illuminate\Foundation\Bootstrap\DetectEnvironment->bootstrap() /var/www/ubiq/src/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:183
PHP   6. Dotenv::load() /var/www/ubiq/src/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/DetectEnvironment.php:19
PHP   7. strpos() /var/www/ubiq/src/vendor/vlucas/phpdotenv/src/Dotenv.php:51

Warning: strpos(): Empty needle in /var/www/ubiq/src/vendor/vlucas/phpdotenv/src/Dotenv.php on line 51

Call Stack:
    0.0008     224352   1. {main}() /var/www/ubiq/src/artisan:0
    0.1363    1862536   2. Illuminate\Foundation\Console\Kernel->handle() /var/www/ubiq/src/artisan:36
    0.1363    1862664   3. Illuminate\Foundation\Console\Kernel->bootstrap() /var/www/ubiq/src/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:92
    0.1363    1862848   4. Illuminate\Foundation\Application->bootstrapWith() /var/www/ubiq/src/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:195
    0.1391    1869392   5. Illuminate\Foundation\Bootstrap\DetectEnvironment->bootstrap() /var/www/ubiq/src/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:183
    0.1425    1913168   6. Dotenv::load() /var/www/ubiq/src/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/DetectEnvironment.php:19
    0.1461    1921888   7. strpos() /var/www/ubiq/src/vendor/vlucas/phpdotenv/src/Dotenv.php:51

PHP Warning:  strpos(): Empty needle in /var/www/ubiq/src/vendor/vlucas/phpdotenv/src/Dotenv.php on line 51
PHP Stack trace:
PHP   1. {main}() /var/www/ubiq/src/artisan:0
PHP   2. Illuminate\Foundation\Console\Kernel->handle() /var/www/ubiq/src/artisan:36
PHP   3. Illuminate\Foundation\Console\Kernel->bootstrap() /var/www/ubiq/src/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:92
PHP   4. Illuminate\Foundation\Application->bootstrapWith() /var/www/ubiq/src/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:195
PHP   5. Illuminate\Foundation\Bootstrap\DetectEnvironment->bootstrap() /var/www/ubiq/src/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:183
PHP   6. Dotenv::load() /var/www/ubiq/src/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/DetectEnvironment.php:19
PHP   7. strpos() /var/www/ubiq/src/vendor/vlucas/phpdotenv/src/Dotenv.php:51

Warning: strpos(): Empty needle in /var/www/ubiq/src/vendor/vlucas/phpdotenv/src/Dotenv.php on line 51

The error log is very big and you can check the full log here: https://jsfiddle.net/rng064wb/

Full error log: https://www.dropbox.com/s/v2lm8pdv95zgntx/error_log_laravel_5.log?dl=0

I've reinstalled many times and still the same error.

VirtualBox: 4.3.28
Laravel: 5.0.22
Vagrant: 1.7.2
Vagrant Box: http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-puppet.box
2

There are 2 best solutions below

3
On

Do you have .dotenv file in your project? If so please check whether you have consistent end of lines (unix/windows/mac).

2
On

You should check the .env file, or better remake it using your favourite IDE. DotEnv.php line 51 tries to strip the comments from the .env file and there's an encoding error in your file.