3

Hi all, i am facing this error while setup:upgrade command in RecurringData.php file magento 2.

I tried all code mentioned in below link

Git hub link

Please guide me,if you have any idea related this topic

Please check below bin\magento file

#!/usr/bin/env php
<?php

echo "\n";
if (PHP_SAPI !== 'cli') {
    echo 'bin/magento must be run as a CLI application';
    exit(1);
}

try {
    require __DIR__ . '/../app/bootstrap.php';
} catch (\Exception $e) {
    echo 'Autoload error: ' . $e->getMessage();
    exit(1);
}
try {
    $handler = new \Magento\Framework\App\ErrorHandler();
    set_error_handler([$handler, 'handler']);
    $application = new Magento\Framework\Console\Cli('Magento CLI');
    $application->run();
} catch (\Exception $e) {
    while ($e) {
        echo $e->getMessage();
        echo $e->getTraceAsString();
        echo "\n\n";
        $e = $e->getPrevious();
    }
    exit(Magento\Framework\Console\Cli::RETURN_FAILURE);
}
5
  • please attach screen shot of error May 27, 2019 at 15:54
  • @Rk, sorry i am not able to share the screenshots due to some company policies At the last line: Running data recurring...Area code is already set May 27, 2019 at 15:58
  • i think this error for custom module May 27, 2019 at 16:01
  • when you setup upgrade check which module is not update means which module throw this error May 27, 2019 at 16:03
  • @RkRathod this error not coming due to any custom module because i am using 3 RecurringData.php in 3 custom module and after debugging i found this error executing randomly in these 3 modules one by one or sometimes in 2 modules also May 28, 2019 at 14:43

3 Answers 3

4

I don't know this is the rightway or not but it's solution is in

/var/www/html/magento231(your magento root directory)/bin/magento

open this file

add after

 <?php

below line

echo "\n";

and your error will go away

3
  • @Rutvi, even still error is exists May 28, 2019 at 13:47
  • 1
    @HiteshBalpande add your bin/magento file code in question May 29, 2019 at 4:59
  • please check my updated question, thanks for reply. May 29, 2019 at 6:29
2

I've seen this happen if extension console scripts are written in a certain way that was fine under previous versions. But that means that you've got to disable and reenable console scripts from third party modules one by one removing entry from di.xml and compiling until you find the culprit. It's likely there is one which is setting area code in the constructor instead of part of the execution method. Last time this happened to me it took a while to find the culprit. But also removing from constructor means something in the script itself will break and potentially it's a bit of a rewrite.

2

File: vendor/magento/framework/App/State.php

in this function public function setAreaCode($code)

try {
        $appState->setAreaCode('frontend');
    } catch (MagentoFrameworkExceptionLocalizedException $e) {
        // intentionally left empty
    }
    parent::__construct($name);

you can follow this link, you will get solution : click here

2
  • 1
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
    – Jarnail S
    Oct 17, 2019 at 8:12
  • okay thanks will take care Oct 17, 2019 at 8:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.