I'm running craft inside the homestead box. The box will up correctly with everything installed, and when I navigate to http://localhost:8000/admin the setup wizard screen displays correctly and works fine, but every time I click through the final screen I get "Install Failed". phperrors.log says:
[03-Jun-2019 19:56:07 UTC] PHP Fatal error: Uncaught yii\base\ErrorException: unlink(/home/vagrant/code/storage/runtime/mutex/a78d6a4ecc5877cd5617ca990a2be38b.lock): Text file busy in /home/vagrant/code/vendor/yiisoft/yii2/mutex/FileMutex.php:161
Stack trace:
#0 /home/vagrant/code/vendor/yiisoft/yii2/mutex/FileMutex.php(161): ::unlink()
#1 /home/vagrant/code/vendor/yiisoft/yii2/mutex/Mutex.php(88): yii\mutex\FileMutex->releaseLock()
#2 /home/vagrant/code/vendor/yiisoft/yii2/mutex/Mutex.php(57): yii\mutex\FileMutex->release()
#3 {main}
thrown in /home/vagrant/code/vendor/yiisoft/yii2/mutex/FileMutex.php on line 161
which I believe is the same as #3879 and #3881. However, the fix for those issues (a custom FileMutex) has been deprecated in #3884. A yii variable 'isWindows' is apparently the way to correct this issue, but I haven't been able to find any documentation describing where/how to set this. I was following the up and running with Craft 3 tutorial as recommended in Developers New to Craft, but I have also googled it to no avail. Additionally, I couldn't find any mention of it anywhere in the documentation. I am new to craft and php, so perhaps I am missing something obvious.
The best solution would be for craft/yii to autodetect when it is running inside a VM, and use the host OS for this setting. I'm not sure this is possible, so the second-best solution is being able to override/force this setting.
composer create-project craftcms/craft .composer require laravel/homestead --dev and .\vendor\bin\homestead makevagrant up to boot the boxhttp://localhost:8000/admin and complete the craft install stepsExpected: craft installs correctly and redirects to the admin console.
Actual: an error message is displayed.
The install is completed successfully if vagrant uses SMB for the file sharing instead of the default (virtualbox). However, this is unsatisfactory because it requires admin privileges.
A yii variable 'isWindows' is apparently the way to correct this issue, but I haven't been able to find any documentation describing where/how to set this.
From your Craft config/app.php file, you can use this to set the isWindows property of the FileMutex class to true.
return [
'components' => [
'mutex' => function() {
$config = craft\helpers\App::mutexConfig();
$config['isWindows'] = true;
return Craft::createObject($config);
},
],
];
Thank you, I can confirm that works!
Craft 3.4.5
I've just run into this when I switched my localhosting over to DDev.
After getting the site setup with DDev everything worked except for saving entries until I added the above.
Is this something that I will need to add to all sites going forward or will there be a an update that will address it in the future?
@CreateSean you'll have to add it as there's no reliable way for 1) Craft to detect that it's running in a VM/container and 2) that the host OS is Windows.
Okay, that's kind of what I was expecting. Thank you.
Most helpful comment
Thank you, I can confirm that works!