MB's avatar
Level 2

PHPUnit fail to install with composer, new NAS?

Hi,

I hope some of you can help me with an annoying problem. Have tried using chatgpt to fix this, but it just tells me to sell my NAS (UGREEN 2800) and buy another brand that support EXFAT... - not sure if that is correct... chatgpt think it's a file permission issue with the filesystem on the NAS (BTRFS + SMB). The UGREEN NAS only support BTRFS and EXT4.

So far I have been using dropbox for my code development, but I have reached the limit of the free plan. I want to use my NAS instead then. I do not use the NAS to run the site etc. Just as a storage device, thats it.

I can run "laravel new project-name" fine and without problems if I do it on C drive, but it fails when I do it on the NAS (network attached drive). This is the error I receive:

PS K:\code\Mfiles> composer install

Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Package operations: 1 install, 0 updates, 0 removals
INFO: Could not find files for the given pattern(s).
  - Installing phpunit/phpunit (11.5.7): Extracting archive
    Install of phpunit/phpunit failed

In Filesystem.php line 261:

  K:/code/Mfiles/vendor/phpunit/phpunit does not exist and could not be created:  

Also getting this error when running "php artisan serve":

hp artisan serve
PHP Warning:  require(K:\code\Mfiles/vendor/autoload.php): Failed to open stream: No such file or directory in K:\code\Mfiles\artisan on line 9

Warning: require(K:\code\Mfiles/vendor/autoload.php): Failed to open stream: No such file or directory in K:\code\Mfiles\artisan on line 9
PHP Fatal error:  Uncaught Error: Failed opening required 'K:\code\Mfiles/vendor/autoload.php' (include_path='C:\xampp\php\PEAR') in K:\code\Mfiles\artisan:9
Stack trace:
#0 {main}
  thrown in K:\code\Mfiles\artisan on line 9

Fatal error: Uncaught Error: Failed opening required 'K:\code\Mfiles/vendor/autoload.php' (include_path='C:\xampp\php\PEAR') in K:\code\Mfiles\artisan:9
Stack trace:
#0 {main}
  thrown in K:\code\Mfiles\artisan on line 9
PS K:\code\Mfiles>

Some of the things chatgpt asked me to check:

PS K:\code\Mfiles> Test-Path K:\code\Mfiles\vendor\autoload.php
False
PS K:\code\Mfiles> Test-Path K:\code\Mfiles\bootstrap\cache
True
PS K:\code\Mfiles> php artisan cache:clear

In PackageManifest.php line 179:

The K:\code\Mfiles\bootstrap\cache directory must be present and writable. 
New test in test.php file:

var_dump(is_writable(__DIR__)); // Check if the project root is writable
var_dump(is_writable(__DIR__ . "/bootstrap/cache")); // Check cache folder
var_dump(is_writable(__DIR__ . "/storage")); // Check storage folder
var_dump(file_put_contents(__DIR__ . "/bootstrap/cache/test2.txt", "hello")); // Try writing a file

Output:
PS K:\code\Mfiles> php test.php
bool(false)
bool(false)
bool(false)
int(5)
  • Only have one User account on the NAS and it have write/read permissions.
  • Can create and edit files (on the NAS) using PHP locally just fine.
  • I don't see any errors when running "composer install -vvv"

That was a lot - not sure if it helps.

I appreciate any help locating the problem :)

, Kenneth

0 likes
3 replies
LaryAI's avatar
Level 58

The issue you're experiencing seems to be related to file permissions on your NAS. Even though you mentioned that your user account has read/write permissions, the behavior you're seeing suggests that there might be a deeper issue with how the NAS handles file permissions, especially for operations initiated by PHP or Composer.

Here are some steps you can take to troubleshoot and potentially resolve the issue:

  1. Check NAS File System Compatibility: Ensure that the file system on your NAS is compatible with the operations you're trying to perform. Some NAS devices use file systems that have limitations with certain file operations, especially when accessed over a network.

  2. Verify Network Share Permissions: Double-check the permissions on the network share itself. Make sure that the share is configured to allow full read/write access for your user account.

  3. Check PHP and Composer Permissions: Ensure that the PHP process and Composer have the necessary permissions to write to the NAS. This might involve checking the user under which these processes are running and ensuring that this user has the correct permissions on the NAS.

  4. Test with a Simple PHP Script: Create a simple PHP script to test writing to the NAS. This can help isolate whether the issue is with PHP/Composer or with the NAS configuration.

    <?php
    $file = 'K:/code/Mfiles/test.txt';
    $content = 'Hello, World!';
    
    if (file_put_contents($file, $content) !== false) {
        echo "File created successfully.";
    } else {
        echo "Failed to create file.";
    }
    ?>
    
  5. Check for Hidden Errors: Run Composer with increased verbosity to see if there are any hidden errors:

    composer install -vvv
    
  6. Try a Different Network Protocol: If your NAS supports different network protocols (e.g., SMB, NFS), try using a different one to see if it resolves the issue.

  7. Local Development Environment: As a temporary workaround, consider using a local directory for development and then manually syncing to the NAS. This can help you continue working while you troubleshoot the issue.

  8. Consult NAS Documentation: Check the documentation for your NAS for any known issues or configuration settings related to file permissions and network shares.

If none of these steps resolve the issue, it might be worth reaching out to the support community for your specific NAS brand, as they might have more targeted advice for your setup.

Snapey's avatar

check that your php has the correct zip extension installed.

Also, when you run the test.php file, what folder did you run it from?

When you look in the file system, do you see the boostrap folder? Can you copy a file to it ?

What version of composer do you have.

Any tests with artisan would be meaningless unless composer runs without errors.

Please or to participate in this conversation.