Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel/Symfony: unable to load the "app" configuration file

After upgrading my Homestead and installing my packages I came across a strange bug. On calling php artisan the following was given as output:

In LoadConfiguration.php line 68:

Unable to load the "app" configuration file.

A few people suggest that this is the cause of Windows (10) capitalising the filenames. However this can't be seen in my folders and also does not apply in my Ubuntu (18.04) environment.

Looking in the source code of LoadConfiguration.php we can see that it is using the Finder class from the symfony/finder component.

foreach (Finder::create()->files()->name('*.php')->in($configPath) as $file) {
    $directory = $this->getNestedDirectory($file, $configPath);

    $files[$directory.basename($file->getRealPath(), '.php')] = $file->getRealPath();
}

The problem is that the finder does return an iterator that somehow cannot find my config files. A simple scandir($configPath) returns all files:

.
..
app.php
and all other files

Wrapping the call in iterator_to_array() returns an empty array [].

The following object is returned by adding ..->in($configPath)->getIterator():

Symfony\Component\Finder\Iterator\PathFilterIterator {#47
  #matchRegexps: []
  #noMatchRegexps: array:2 [
    0 => "#(^|/)\..+(/|$)#"
    1 => "#(^|/)\..+(/|$)#"
  ]
  innerIterator: Symfony\Component\Finder\Iterator\FilenameFilterIterator {#43
    #matchRegexps: array:1 [
      0 => "#^(?=[^\.])[^/]*\.php$#"
    ]
    #noMatchRegexps: []
    innerIterator: Symfony\Component\Finder\Iterator\FileTypeFilterIterator {#39
      -mode: 1
      innerIterator: RecursiveIteratorIterator {#42
        innerIterator: Symfony\Component\Finder\Iterator\ExcludeDirectoryFilterIterator {#46
          -iterator: Symfony\Component\Finder\Iterator\RecursiveDirectoryIterator {#48
            -ignoreUnreadableDirs: false
            -rewindable: null
            -rootPath: "/home/vagrant/somepath/api/config"
            -subPath: null
            -directorySeparator: "/"
            path: "/home/vagrant/somepath/api/config"
            filename: "app.php"
            basename: "app.php"
            pathname: "/home/vagrant/somepath/api/config/app.php"
            extension: "php"
            realPath: "./config/app.php"
            aTime: 2019-07-02 09:28:30
            mTime: 2019-01-31 17:43:49
            cTime: 2019-07-02 16:32:52
            inode: 429
            size: 9727
            perms: 0100777
            owner: 1000
            group: 1000
            type: "file"
            writable: true
            readable: true
            executable: true
            file: true
            dir: false
            link: false
          }
          -isRecursive: true
          -excludedDirs: array:9 [
            ".svn" => true
            "_svn" => true
            "CVS" => true
            "_darcs" => true
            ".arch-params" => true
            ".monotone" => true
            ".bzr" => true
            ".git" => true
            ".hg" => true
          ]
          -excludedPattern: null
          innerIterator: Symfony\Component\Finder\Iterator\RecursiveDirectoryIterator {#48}
        }
      }
    }
  }
}

Assume I do not know anything about these type of iterators. Two things stand out to me:

  • A lot of innerIterator's are present.
  • One iterator can find something #48, we can see our config/app.php, but is inside a ExcludeDirectoryFilterIterator.

Has anybody had this problem before or know how to lead me in the right direction?

The following versions were used:

OS: Windows 10/Ubuntu 18.04 LTS
Homestead: 9.0.1
laravel/framework: 5.8.*/5.7.*
 \ symfony/finder: ^4.2/^4.1,

EDIT

Downgraded my Homestead to v8.0.1 and everything works. However still no explanation about why this happened on v9.0.1.

like image 299
Thomas Van der Veen Avatar asked Jul 02 '19 17:07

Thomas Van der Veen


1 Answers

Try updating VirtualBox to v6. See this GitHub issue for more help.

like image 140
ncla Avatar answered Sep 19 '22 15:09

ncla