Skip to content

open_basedir restriction in effect #271

@srebb

Description

@srebb

Problem/Motivation

During a second composer install, I got this error:

is_dir(): open_basedir restriction in effect. 
File(../../doctrine/coding-standard/lib) is not within the allowed path(s): 
(/var/www/html:/var/www/.composer:/tmp:/dev/urandom:/proc/self/fd:/usr/local/bin)

This happens, cause during composer install the root directory is not the phpcs directory, therefore the ../../ points out of the projectDir. In my case, the code is limited via open_basedir to the projectDir.

Expected behaviour

No error

Actual behaviour

Code throws error during the second composer install.

Steps to reproduce

Create a project.

composer require --dev \
    dealerdirect/phpcodesniffer-composer-installer \
    doctrine/coding-standard \
    doctrine/doctrine-fixtures-bundle \
    squizlabs/php_codesniffer

add an open_basedir restriction in php to the root of the project (e.g. /var/www/html/projectName) where you installed the project.
Do another composer install.
Every composer install after the first one will get an error for open_basedir restriction.

Proposed changes

Change the order of is_readable checks in Plugin.php::cleanInstalledPaths()

See pull request #272

Environment

Question Answer
OS Linux)
PHP version 8.4.12
Composer version 2.8.3
PHP_CodeSniffer version 4.0.1
Install type Composer project local

Tested against main branch?

  • I have verified the issue still exists in the main branch.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions