Skip to content

Magento2 cannot resolve path to pub/static JS files #7869

@zucler

Description

@zucler

Preconditions

  1. Magento ver. 2.1.3
  2. PHP 7.0
  3. MySQL 5.6

All of the above running in docker containers. Files are sync'ed using docker-sync utility, but I've also tried mounting volumes directly from my local host drive and it did not help.

I've confirmed that PHP is running as www-data user and that all project files have read & write permissions on every file and directory within the project.

I have previously tried deleting all manual content and running setup:static-content:deploy. Static files were re-created, but it didn't help me to solve my problem.

Lastly, I've troubleshooted the code as far as I could and got to the point where in

vendor/magento/framework/View/Design/FileResolution/Fallback/Resolver/Simple.php file

protected function resolveFile(RuleInterface $fallbackRule, $file, array $params = [])
    {
        //->getPatternDirs return Array ( [0] => /var/www/html/lib/web )
        // given that nginx doc root path is /var/www/html
        foreach ($fallbackRule->getPatternDirs($params) as $dir) {
            $path = "{$dir}/{$file}";
            $dirRead = $this->readFactory->create($dir);
            if ($dirRead->isExist($file) && $this->checkFilePathAccess($file, $path)) {
                return $path;
            }
        }
        return false;
    }

Error details:

Unable to resolve the source file for '_requirejs/adminhtml/Magento/backend/en_US/requirejs-config.js'
#0 /var/www/html/vendor/magento/framework/App/StaticResource.php(97): Magento\Framework\View\Asset\File->getSourceFile()
#1 /var/www/html/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\StaticResource->launch()
#2 /var/www/html/pub/static.php(13): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\StaticResource))
#3 {main}

Also, I have confirmed that these files actually exist, but Magento is unable to work out their paths correctly.

Steps to reproduce

  1. Open management page or default Luma page

Expected result

  1. All files are loaded and all Javascript on the page is working

Actual result

  1. The files below can not be loaded, thus no JS is working on the page

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions