craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.28k stars 635 forks source link

CraftCMS File/Folder Permissions Issues (WSL related?) #4436

Closed jlahijani closed 5 years ago

jlahijani commented 5 years ago

Hello,

I'm trying to get CraftCMS up and running in WSL. I ran the composer-based installer and I'm able to hit the welcome page just fine. However when going to /admin, I'm first presented with a bunch of permission errors, like this:

yii\base\ErrorException: chmod(): Operation not permitted in /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/yiisoft/yii2/helpers/BaseFileHelper.php:646
Stack trace:
#0 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/craftcms/cms/src/web/ErrorHandler.php(81): yii\base\ErrorHandler->handleError(2, 'chmod(): Operat...', '/mnt/c/Users/jl...', 646)
#1 [internal function]: craft\web\ErrorHandler->handleError(2, 'chmod(): Operat...', '/mnt/c/Users/jl...', 646, Array)
#2 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/yiisoft/yii2/helpers/BaseFileHelper.php(646): chmod('/mnt/c/Users/jl...', 509)
#3 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/yiisoft/yii2/helpers/BaseFileHelper.php(341): yii\helpers\BaseFileHelper::createDirectory('/mnt/c/Users/jl...', 509, true)
#4 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/yiisoft/yii2/web/AssetManager.php(566): yii\helpers\BaseFileHelper::copyDirectory('/mnt/c/Users/jl...', '/mnt/c/Users/jl...', Array)
#5 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/craftcms/cms/src/web/AssetManager.php(114): yii\web\AssetManager->publishDirectory('/mnt/c/Users/jl...', Array)
#6 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/yiisoft/yii2/web/AssetManager.php(466): craft\web\AssetManager->publishDirectory('/mnt/c/Users/jl...', Array)
#7 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/yiisoft/yii2/web/AssetBundle.php(185): yii\web\AssetManager->publish('/mnt/c/Users/jl...', Array)
#8 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/yiisoft/yii2/web/AssetManager.php(266): yii\web\AssetBundle->publish(Object(craft\web\AssetManager))
#9 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/yiisoft/yii2/web/AssetManager.php(237): yii\web\AssetManager->loadBundle('craft\\web\\asset...', Array, true)
#10 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/yiisoft/yii2/web/View.php(286): yii\web\AssetManager->getBundle('craft\\web\\asset...')
#11 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/twig/twig/src/Extension/CoreExtension.php(1485): yii\web\View->registerAssetBundle('craft\\web\\asset...')
#12 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/craftcms/cms/src/helpers/Template.php(79): twig_get_attribute(Object(craft\web\twig\Environment), Object(Twig\Source), Object(craft\web\View), 'registerAssetBu...', Array, 'method', false, false)
#13 /mnt/c/Users/jlahijani/Projects/mywebsite.com/storage/runtime/compiled_templates/0c/0c0724fcccf2d248e5298bceca7c4944e21894b14b533ecbc08d0bd1c330d963.php(48): craft\helpers\Template::attribute(Object(craft\web\twig\Environment), Object(Twig\Source), Object(craft\web\View), 'registerAssetBu...', Array, 'method')
#14 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/twig/twig/src/Template.php(407): __TwigTemplate_b996a6cdcc25ff78990800c334fbb9f450306e9aebcad2e29b622b7afc14dbd4->doDisplay(Array, Array)
#15 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/craftcms/cms/src/web/twig/Template.php(52): Twig\Template->displayWithErrorHandling(Array, Array)
#16 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/twig/twig/src/Template.php(380): craft\web\twig\Template->displayWithErrorHandling(Array, Array)
#17 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/craftcms/cms/src/web/twig/Template.php(34): Twig\Template->display(Array, Array)
#18 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/twig/twig/src/Template.php(392): craft\web\twig\Template->display(Array)
#19 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/twig/twig/src/TemplateWrapper.php(45): Twig\Template->render(Array, Array)
#20 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/twig/twig/src/Environment.php(318): Twig\TemplateWrapper->render(Array)
#21 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/craftcms/cms/src/web/View.php(343): Twig\Environment->render('login', Array)
#22 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/craftcms/cms/src/web/View.php(393): craft\web\View->renderTemplate('login', Array)
#23 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/craftcms/cms/src/web/Controller.php(161): craft\web\View->renderPageTemplate('login', Array)
#24 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/craftcms/cms/src/controllers/TemplatesController.php(78): craft\web\Controller->renderTemplate('login', Array)
#25 [internal function]: craft\controllers\TemplatesController->actionRender('login', Array)
#26 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#27 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#28 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/craftcms/cms/src/web/Controller.php(109): yii\base\Controller->runAction('render', Array)
#29 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('render', Array)
#30 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/craftcms/cms/src/web/Application.php(297): yii\base\Module->runAction('templates/rende...', Array)
#31 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction('templates/rende...', Array)
#32 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/craftcms/cms/src/web/Application.php(286): yii\web\Application->handleRequest(Object(craft\web\Request))
#33 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#34 /mnt/c/Users/jlahijani/Projects/mywebsite.com/web/index.php(21): yii\base\Application->run()
#35 {main}

Next yii\base\Exception: Failed to change permissions for directory "/mnt/c/Users/jlahijani/Projects/mywebsite.com/web/cpresources/de413280": chmod(): Operation not permitted in /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/yiisoft/yii2/helpers/BaseFileHelper.php:648
Stack trace:
#0 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/yiisoft/yii2/helpers/BaseFileHelper.php(341): yii\helpers\BaseFileHelper::createDirectory('/mnt/c/Users/jl...', 509, true)
#1 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/yiisoft/yii2/web/AssetManager.php(566): yii\helpers\BaseFileHelper::copyDirectory('/mnt/c/Users/jl...', '/mnt/c/Users/jl...', Array)
#2 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/craftcms/cms/src/web/AssetManager.php(114): yii\web\AssetManager->publishDirectory('/mnt/c/Users/jl...', Array)
#3 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/yiisoft/yii2/web/AssetManager.php(466): craft\web\AssetManager->publishDirectory('/mnt/c/Users/jl...', Array)
#4 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/yiisoft/yii2/web/AssetBundle.php(185): yii\web\AssetManager->publish('/mnt/c/Users/jl...', Array)
#5 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/yiisoft/yii2/web/AssetManager.php(266): yii\web\AssetBundle->publish(Object(craft\web\AssetManager))
#6 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/yiisoft/yii2/web/AssetManager.php(237): yii\web\AssetManager->loadBundle('craft\\web\\asset...', Array, true)
#7 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/yiisoft/yii2/web/View.php(286): yii\web\AssetManager->getBundle('craft\\web\\asset...')
#8 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/twig/twig/src/Extension/CoreExtension.php(1485): yii\web\View->registerAssetBundle('craft\\web\\asset...')
#9 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/craftcms/cms/src/helpers/Template.php(79): twig_get_attribute(Object(craft\web\twig\Environment), Object(Twig\Source), Object(craft\web\View), 'registerAssetBu...', Array, 'method', false, false)
#10 /mnt/c/Users/jlahijani/Projects/mywebsite.com/storage/runtime/compiled_templates/0c/0c0724fcccf2d248e5298bceca7c4944e21894b14b533ecbc08d0bd1c330d963.php(48): craft\helpers\Template::attribute(Object(craft\web\twig\Environment), Object(Twig\Source), Object(craft\web\View), 'registerAssetBu...', Array, 'method')
#11 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/twig/twig/src/Template.php(407): __TwigTemplate_b996a6cdcc25ff78990800c334fbb9f450306e9aebcad2e29b622b7afc14dbd4->doDisplay(Array, Array)
#12 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/craftcms/cms/src/web/twig/Template.php(52): Twig\Template->displayWithErrorHandling(Array, Array)
#13 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/twig/twig/src/Template.php(380): craft\web\twig\Template->displayWithErrorHandling(Array, Array)
#14 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/craftcms/cms/src/web/twig/Template.php(34): Twig\Template->display(Array, Array)
#15 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/twig/twig/src/Template.php(392): craft\web\twig\Template->display(Array)
#16 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/twig/twig/src/TemplateWrapper.php(45): Twig\Template->render(Array, Array)
#17 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/twig/twig/src/Environment.php(318): Twig\TemplateWrapper->render(Array)
#18 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/craftcms/cms/src/web/View.php(343): Twig\Environment->render('login', Array)
#19 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/craftcms/cms/src/web/View.php(393): craft\web\View->renderTemplate('login', Array)
#20 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/craftcms/cms/src/web/Controller.php(161): craft\web\View->renderPageTemplate('login', Array)
#21 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/craftcms/cms/src/controllers/TemplatesController.php(78): craft\web\Controller->renderTemplate('login', Array)
#22 [internal function]: craft\controllers\TemplatesController->actionRender('login', Array)
#23 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#24 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#25 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/craftcms/cms/src/web/Controller.php(109): yii\base\Controller->runAction('render', Array)
#26 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('render', Array)
#27 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/craftcms/cms/src/web/Application.php(297): yii\base\Module->runAction('templates/rende...', Array)
#28 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction('templates/rende...', Array)
#29 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/craftcms/cms/src/web/Application.php(286): yii\web\Application->handleRequest(Object(craft\web\Request))
#30 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#31 /mnt/c/Users/jlahijani/Projects/mywebsite.com/web/index.php(21): yii\base\Application->run()
#32 {main}

After refreshing about 10 or so times, it finally gets to the login screen but without any styles. I can see that it's trying to create files inside of the generated folders inside /web/cpresources/.

I tried chmoding the folders there with no luck either. I chmodded all the folders in CraftCMS to 777 but that didn't help either.

Attempting to login throws this error (perhaps related to the previous issue):

yii\web\BadRequestHttpException: Unable to verify your data submission. in /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/yiisoft/yii2/web/Controller.php:166
Stack trace:
#0 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/craftcms/cms/src/web/Controller.php(88): yii\web\Controller->beforeAction(Object(yii\base\InlineAction))
#1 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/craftcms/cms/src/controllers/TemplatesController.php(55): craft\web\Controller->beforeAction(Object(yii\base\InlineAction))
#2 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/yiisoft/yii2/base/Controller.php(155): craft\controllers\TemplatesController->beforeAction(Object(yii\base\InlineAction))
#3 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/craftcms/cms/src/web/Controller.php(109): yii\base\Controller->runAction('requirements-ch...', Array)
#4 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('requirements-ch...', Array)
#5 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/craftcms/cms/src/web/Application.php(297): yii\base\Module->runAction('templates/requi...', Array)
#6 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/craftcms/cms/src/web/Application.php(637): craft\web\Application->runAction('templates/requi...')
#7 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/craftcms/cms/src/web/Application.php(192): craft\web\Application->_processRequirementsCheck(Object(craft\web\Request))
#8 /mnt/c/Users/jlahijani/Projects/mywebsite.com/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#9 /mnt/c/Users/jlahijani/Projects/mywebsite.com/web/index.php(21): yii\base\Application->run()
#10 {main}

I know it's related to file/folder permissions, but giving everything 777 didn't help. I don't think this would be a WSL issue as I'm able to run ProcessWire and WordPress without issues.

I messed with ownership of files but no luck either. Usually I'm able to figure these kinds of issues out but I'm stumped on this one. I may just result to using a non-local server as WSL can be a little strange sometimes.

I tried also doing another installation but that didn't work either.

Any help would be appreciated.

Additional info

jlahijani commented 5 years ago

OK I figured out the issue. It's related to enabling this feature: https://blogs.msdn.microsoft.com/commandline/2018/01/12/chmod-chown-wsl-improvements/

I think I did that once before, but I re-installed WSL recently and didn't enable that.

Hope this helps someone.