Problems with permissions when i activete debug mode on and cant upload images

Keywords: PrestaShop - AWS - Technical issue - Permissions
Description:
when i activate my denug mode on i getr this:
(1/1) ContextErrorException
Warning: file_put_contents(/opt/bitnami/apps/prestashop/htdocs/var/cache/dev/cacert.pem): failed to open stream: Permission denied

in Tools.php line 2118
at ToolsCore::refreshCACertFile()
in Tools.php line 107
at Tools->refreshCaCertFile()
in ApiClient.php line 66
at ApiClient->setSslVerification(’/opt/bitnami/apps/prestashop/htdocs/var/cache/dev/cacert.pem’)
in ModuleManagerBuilder.php line 178
at ModuleManagerBuilder->__construct()
in ModuleManagerBuilder.php line 87
at ModuleManagerBuilder::getInstance()
in Link.php line 944
at LinkCore->getImageLink(’’, ‘mx-default’, ‘thickbox_default’)
in ImageRetriever.php line 255
at ImageRetriever->getNoPictureImage(object(Language))
in FrontController.php line 1518
at FrontControllerCore->getTemplateVarUrls()
in FrontController.php line 496
at FrontControllerCore->assignGeneralPurposeVariables()
in FrontController.php line 548
at FrontControllerCore->initContent()
in IndexController.php line 37
at IndexControllerCore->initContent()
in Controller.php line 292
at ControllerCore->run()
in Dispatcher.php line 515
at DispatcherCore->dispatch()
in index.php line 28

ALSO i can upload images to my products i get this error:

I get this when i try tu upload an image for my products

THanks

Hi, @oscar.garcia.alarcon.

We have a Support Tool that will gather relevant information for us to analyze your configuration and logs. Could you please execute it on the machine where the stack is running by following the steps described in the guide below?

Please note that you need to paste the code ID that is shown at the end.

thanks for the response here is my ID

cb880a01-7397-44bb-2373-070147420de6

Can you try giving Apache permissions to write this file?

sudo chmod 664 /opt/bitnami/apps/prestashop/htdocs/var/cache/dev/cacert.pem

Regards,
Alejandro

thabk you for your response now i get this

 (1/1) ContextErrorException

Warning: touch(): Utime failed: Permission denied
in smarty_template_compiled.php line 178
at Smarty_Template_Compiled->compileTemplateSource(object(SmartyDevTemplate))in smarty_template_compiled.php line 141
at Smarty_Template_Compiled->process(object(SmartyDevTemplate))in smarty_template_compiled.php line 105
at Smarty_Template_Compiled->render(object(SmartyDevTemplate))in smarty_internal_template.php line 216
at Smarty_Internal_Template->render()in smarty_internal_template.php line 385
at Smarty_Internal_Template->_subTemplateRender('file:_partials/head.tpl', null, 'layouts/layout-full-width.tpl', 0, 31536000, array(), 0, false)in 998beaf786f19146424319dd85c44b811c113d08_2.file.layout-both-columns.tpl.php line 134
at Block_9817180375e160367f36e54_08658943->callBlock(object(SmartyDevTemplate))in smarty_internal_runtime_inheritance.php line 248
at Smarty_Internal_Runtime_Inheritance->callBlock(object(Block_9817180375e160367f36e54_08658943), object(SmartyDevTemplate))in smarty_internal_runtime_inheritance.php line 184
at Smarty_Internal_Runtime_Inheritance->process(object(SmartyDevTemplate), object(Block_9817180375e160367f36e54_08658943))in smarty_internal_runtime_inheritance.php line 156
at Smarty_Internal_Runtime_Inheritance->instanceBlock(object(SmartyDevTemplate), 'Block_9817180375e160367f36e54_08658943', 'head')in 998beaf786f19146424319dd85c44b811c113d08_2.file.layout-both-columns.tpl.php line 40
at content_5e160368003c83_06105089(object(SmartyDevTemplate))in smarty_template_resource_base.php line 123
at Smarty_Template_Resource_Base->getRenderedTemplateCode(object(SmartyDevTemplate))in smarty_template_compiled.php line 114
at Smarty_Template_Compiled->render(object(SmartyDevTemplate))in smarty_internal_template.php line 216
at Smarty_Internal_Template->render()in smarty_internal_template.php line 385
at Smarty_Internal_Template->_subTemplateRender('layouts/layout-both-columns.tpl', null, 'layouts/layout-full-width.tpl', 0, 31536000, array(), 2, false, null, null)in smarty_internal_runtime_inheritance.php line 125
at Smarty_Internal_Runtime_Inheritance->endChild(object(SmartyDevTemplate), 'layouts/layout-both-columns.tpl')in 9773058e89fb62c3abac6c16c615c877a4835bd0_2.file.layout-full-width.tpl.php line 42
at content_5e160367f33136_92350406(object(SmartyDevTemplate))in smarty_template_resource_base.php line 123
at Smarty_Template_Resource_Base->getRenderedTemplateCode(object(SmartyDevTemplate))in smarty_template_compiled.php line 114
at Smarty_Template_Compiled->render(object(SmartyDevTemplate))in smarty_internal_template.php line 216
at Smarty_Internal_Template->render()in smarty_internal_template.php line 385
at Smarty_Internal_Template->_subTemplateRender('layouts/layout-full-width.tpl', null, 'layouts/layout-full-width.tpl', 0, 31536000, array(), 2, false, null, null)in smarty_internal_runtime_inheritance.php line 125
at Smarty_Internal_Runtime_Inheritance->endChild(object(SmartyDevTemplate), 'layouts/layout-full-width.tpl')in afdd2992c38cdbb00f107d85af917a3f0482a323_2.file.page.tpl.php line 33
at content_5e160367f2ab92_03377369(object(SmartyDevTemplate))in smarty_template_resource_base.php line 123
at Smarty_Template_Resource_Base->getRenderedTemplateCode(object(SmartyDevTemplate))in smarty_template_compiled.php line 114
at Smarty_Template_Compiled->render(object(SmartyDevTemplate))in smarty_internal_template.php line 216
at Smarty_Internal_Template->render()in smarty_internal_template.php line 385
at Smarty_Internal_Template->_subTemplateRender('page.tpl', null, 'layouts/layout-full-width.tpl', 0, 31536000, array(), 2, false, null, null)in smarty_internal_runtime_inheritance.php line 125
at Smarty_Internal_Runtime_Inheritance->endChild(object(SmartyDevTemplate), 'page.tpl')in 2a60ce271a3a1b22fafd3514536bec69122ab1ed_2.file.index.tpl.php line 33
at content_5e16057a00e0d0_52244748(object(SmartyDevTemplate))in smarty_template_resource_base.php line 123
at Smarty_Template_Resource_Base->getRenderedTemplateCode(object(SmartyDevTemplate))in smarty_template_compiled.php line 114
at Smarty_Template_Compiled->render(object(SmartyDevTemplate))in smarty_internal_template.php line 216
at Smarty_Internal_Template->render(false, 0)in smarty_internal_templatebase.php line 232
at Smarty_Internal_TemplateBase->_execute(object(SmartyDevTemplate), null, 'layouts/layout-full-width.tpl', null, 0)in smarty_internal_templatebase.php line 116
at Smarty_Internal_TemplateBase->fetch('index.tpl', null, 'layouts/layout-full-width.tpl', null, false, true, false)in SmartyDev.php line 40
at SmartyDev->fetch('index.tpl', null, 'layouts/layout-full-width.tpl')in FrontController.php line 683
at FrontControllerCore->smartyOutputContent('index.tpl')in FrontController.php line 667
at FrontControllerCore->display()in Controller.php line 312
at ControllerCore->run()in Dispatcher.php line 515
at DispatcherCore->dispatch()in index.php line 28

Looks like it’s missing permissions to touch a file. Can you check line 178 in the smarty_template_compiled.php file? What is it trying to touch?

Regards.
Alejandro

Thank you for your response: here it is:

/**

  • compile template from source
    *
    • @param Smarty_Internal_Template $_template
    • @throws Exception
      */
      public function compileTemplateSource(Smarty_Internal_Template $_template)
      {
      $this->file_dependency = array();
      $this->includes = array();
      $this->nocache_hash = null;
      $this->unifunc = null;
      // compile locking
      if ($saved_timestamp = (!$_template->source->handler->recompiled && is_file($this->filepath))) {
      $saved_timestamp = $this->getTimeStamp();
      touch($this->filepath);
      }
      // compile locking
      try {
      // call compiler
      $_template->loadCompiler();
      $this->write($_template, $_template->compiler->compileTemplate($_template));
      } catch (Exception $e) {
      // restore old timestamp in case of error
      if ($saved_timestamp && is_file($this->filepath)) {
      touch($this->filepath, $saved_timestamp);
      }
      unset($_template->compiler);
      throw $e;
      }
      // release compiler object to free memory
      unset($_template->compiler);
      }

I’ll try to reproduce this on my side.

Thank you for your help !:grinning:

Hi, @oscar.garcia.alarcon.

I’ve enabled debug mode on a new instance and I’m not able to reproduce your issue: everything seems to work and I don’t see any errors anywhere. Where are you getting that error? It clearly looks like there’s a permission missing on some folder, but I don’t know what folder is it talking about.

The only thing it asked me was for some permissions on a cache folder for Smarty. Can you try running these commands?

sudo mkdir -p /opt/bitnami/apps/prestashop/htdocs/themes/classic/cache
sudo chown bitnami:daemon /opt/bitnami/apps/prestashop/htdocs/themes/classic/cache
sudo chmod 775 /opt/bitnami/apps/prestashop/htdocs/themes/classic/cache

Regards,
Alejandro

i get errors when i try to upload an image of a product and when i activate debug mode on the site crashes i type the commands that are you suggesting, but not working

What errors do you get when trying to upload an image of a product?

this ones Problems with permissions when i activete debug mode on and cant upload images

Hi, @oscar.garcia.alarcon.

I’ve tried again and I’m able to upload images for the products and enable debug mode without having issues. The error you are getting seems to be because PrestaShop isn’t able to to touch a file, apparently due to permissions issues.

To try to debug this, I would investigate what is this path that is trying to touch (the $this->filepath variable on line 178 of the smarty_template_compiled.php file).

I recommend you to post this question on the PrestaShop forums (https://www.prestashop.com/forums/) since they will be able to help you there. Note that as we only package already existing software we are not experts on each application, and as such we can only answer questions related to our configuration or to very basic things.

Regards,
Alejandro

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.