Magento 2 error after upgrade and deploy - magento2

For a template in magento 2 we had to do following in SSH
Run command line: php bin/magento module:enable MGS_Mpanel
Run command line: php bin/magento module:enable MGS_Mmegamenu
Run command line: php bin/magento module:enable MGS_Portfolio
Run command line: php bin/magento module:enable MGS_Testimonial
Run command line: php bin/magento module:enable MGS_Brand
Run command line: php bin/magento module:enable MGS_Core
Run command line: php bin/magento module:enable MGS_Promobanners
Run command line: php bin/magento module:enable MGS_StoreLocator
Run command line: php bin/magento module:enable MGS_Blog
Run command line: php bin/magento module:enable MGS_QuickView
Run command line: php bin/magento module:enable MGS_AdvancedReports
Run command line: php bin/magento setup:upgrade
Run command line: php bin/magento setup:static-content:deploy
Magento was installed correctly, but after deploy we get following error:
a:4:{i:0;s:294:"Warning: include(/home/[myusername]/domains/[mydomain]/public_html/var/generation/Magento/Framework/App/FrontController/Interceptor.php): failed to open stream: No such file or directory in /home/[myusername]/domains/[mydomain]/public_html/vendor/magento/framework/Code/Generator/Io.php on line 158";i:1;s:2288:"#0 /home/[myusername]/domains/[mydomain]/public_html/vendor/magento/framework/Code/Generator/Io.php(158): Magento\Framework\App\ErrorHandler->handler(2, 'include(/home/d...', '/home/[myusername]/...', 158, Array)
1 /home/[myusername]/domains/[mydomain]/public_html/vendor/magento/framework/Code/Generator/Io.php(158): include()
2 /home/[myusername]/domains/[mydomain]/public_html/vendor/magento/framework/Code/Generator.php(202): Magento\Framework\Code\Generator\Io->includeFile('/home/[myusername]/...')
3 /home/[myusername]/domains/[mydomain]/public_html/vendor/magento/framework/Code/Generator.php(92): Magento\Framework\Code\Generator->shouldSkipGeneration('interceptor', 'Magento\Framewo...', 'Magento\Framewo...')
4 /home/[myusername]/domains/[mydomain]/public_html/vendor/magento/framework/Code/Generator/Autoloader.php(35): Magento\Framework\Code\Generator->generateClass('Magento\Framewo...')
5 [internal function]: Magento\Framework\Code\Generator\Autoloader->load('Magento\Framewo...')
6 [internal function]: spl_autoload_call('Magento\Framewo...')
7 /home/[myusername]/domains/[mydomain]/public_html/vendor/magento/framework/Code/Reader/ClassReader.php(19): ReflectionClass->__construct('Magento\Framewo...')
8 /home/[myusername]/domains/[mydomain]/public_html/vendor/magento/framework/ObjectManager/Definition/Runtime.php(44): Magento\Framework\Code\Reader\ClassReader->getConstructor('Magento\Framewo...')
9 /home/[myusername]/domains/[mydomain]/public_html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(71): Magento\Framework\ObjectManager\Definition\Runtime->getParameters('Magento\Framewo...')
10 /home/[myusername]/domains/[mydomain]/public_html/vendor/magento/framework/ObjectManager/ObjectManager.php(71): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\Framewo...')
11 /home/[myusername]/domains/[mydomain]/public_html/vendor/magento/framework/App/Http.php(114): Magento\Framework\ObjectManager\ObjectManager->get('Magento\Framewo...')
12 /home/[myusername]/domains/[mydomain]/public_html/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()
13 /home/[myusername]/domains/[mydomain]/public_html/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
14 {main}";s:3:"url";s:1:"/";s:11:"script_name";s:10:"/index.php";}
Any ideas on how to solve this have no clue and tried re-installing this for a few times now.

Hope this will help you.
Please remove var/di/* and var/generation/* using following command from your Magento project's root directory
rm -Rf var/di/* var/generation/*

Related

Magento2 Fatal error: Uncaught TypeError: Argument 2 passed to Gogoesho

My code display this error , anyone can help me , many thanks
Fatal error: Uncaught TypeError: Argument 2 passed to
Gogoeshop\ProductWarranty\Controller\Index\Index::__construct() must
be an instance of Magento\Customer\Model\Session, instance of
Magento\Framework\View\Result\PageFactory given, called in
C:\Apache-2.4.7-win64-VC11\htdocs\magentopos2\generated\code\Gogoeshop\ProductWarranty\Controller\Index\Index\Interceptor.php
on line 14 and defined in
C:\Apache-2.4.7-win64-VC11\htdocs\magentopos2\app\code\Gogoeshop\ProductWarranty\Controller\Index\Index.php:9
Stack trace: #0
C:\Apache-2.4.7-win64-VC11\htdocs\magentopos2\generated\code\Gogoeshop\ProductWarranty\Controller\Index\Index\Interceptor.php(14):
Gogoeshop\ProductWarranty\Controller\Index\Index->__construct(Object(Magento\Framework\App\Action\Context),
Object(Magento\Framework\View\Result\PageFactory)) #1
C:\Apache-2.4.7-win64-VC11\htdocs\magentopos2\vendor\magento\framework\ObjectManager\Factory\AbstractFactory.php(111):
Gogoeshop\ProductWarranty\Controller\Index\Index\Interceptor->__construct(Object(Magento\Framework\App\
in
C:\Apache-2.4.7-win64-VC11\htdocs\magentopos2\app\code\Gogoeshop\ProductWarranty\Controller\Index\Index.php
on line 9
Try Compiling the code with this command: php bin/magento setup:di:compile. I hope it helps.
Just run following command using Command Line Mode
rm -rf var/generation/*
Generally, Magento caches the constructors in var/generation folder, so if you clear the var/generation content then Magento will regenerate the interceptor.
rm -rf var/generation
I had the same issue and resolving it by following steps
First, you need to remove generated/code/* and var/cache/*
rm -rf generated/code/* var/cache/*
Second, Clean the cache
php bin/magento cache:clean
Third, Change the file permission
sudo chmod 777 -R generated/ var/ pub/
Fourth, run Generated Compile the code
php bin/magento setup:di:compile
Run the following commands one by one:-
rm -rf var/*
rm -rf generated
php bin/magento setup:di:compile

Magento 2 errors on cache:flush cache:clean | Need to set permission to 777 afterwards

Everytime I run:
php bin/magento cache:flush
php bin/magento cache:clean
I get the following message when reloading the page:
An error has happened during application run. See exception log for
details.
exception.log:
ain.CRITICAL: Exception: Warning: file_put_contents(/var/www/magento2/var/cache//mage-tags/mage---914_CONFIG_SCOPES): failed to open stream: Permission denied in /var/www/magento2/vendor/colinmollenhour/cache-backend-file/File.php on line 663 in /var/www/magento2/vendor/magento/framework/App/ErrorHandler.php:61
When I then run:
sudo chmod -R 777 var/ pub/
The error is gone.
How could this happen everytime I clean cache and what should be done to back trace/solve this issue?
The root of such type of issues is same: the user that run web-server differs from the user which runs console command.
Preconditions
You should define what user run your web-server.
$ ls -la
This command could who creates var/cache and so on.
Let's decide that web-server run under www-data user.
Solution 1
$ sudo -H -u www-data __some_command_here_
This format allows you to run the command under web-server user. So application will have same rights as a server (user www-data).
So you command php bin/magento cache:flush transforms to
$ sudo -H -u www-data php bin/magento cache:flush
Solution 2
Add web-server's user to your user to the same group.
$ id
uid=1001(ygl) gid=1002(ygl) groups=1002(ygl),112(nopasswdlogin)
this one will show information about the current user.
$ sudo usermod -a -G www-data
this command will add www-data to yourGroupName.

php command not found while installing composer

I am using ubuntu OS. I am trying to install composer.
my $PATH is
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin:/opt/lampp/bin/php
while entering following command it shows error php is not command
curl -sS https://getcomposer.org/installer | sudo php --
--install-dir=/usr/local/bin --filename=composer
error sudo:
php: command not found
curl: (23) Failed writing body (0 != 16133)
Do you use PHP7? Then the command should be this.
curl -sS https://getcomposer.org/installer | php70

Build of docker image with centos:6.6 fails when trying to update repo

I have the following simple Dockerfile:
FROM centos:6.6
USER root
RUN yum clean all
RUN yum update
And I am trying to build it as usual:
docker build -t myimage/hadoop .
But I have the following error and I can't find the solution:
Error: Cannot find a valid baseurl for repo: base Could not retrieve
mirrorlist
http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os&infra=stock
error was 14: PYCURL ERROR 6 - "Couldn't resolve host
'mirrorlist.centos.org'" INFO[0005] The command "/bin/sh -c yum
update" returned a non-zero code: 1
Any help or reference to solve the problem would be very helpful.
EDIT: I tried the solution given in this post but with no results.
Could you try add "-y" to the ""yum update"?
RUN yum update -y

installing mongodb with pecl

this is what i get:
bitnami#ip-10-117-57-211:/bin$ sudo pecl install mongo
downloading mongo-1.4.0.tgz ...
Starting to download mongo-1.4.0.tgz (138,495 bytes)
..............................done: 138,495 bytes
84 source files, building
WARNING: php_bin /opt/bitnami/php/bin/php appears to have a suffix /bin/php, but config variable php_suffix does not match
running: phpize
Configuring for:
PHP Api Version: 20100412
Zend Module Api No: 20100525
Zend Extension Api No: 220100525
Can't load '/opt/bitnami/perl/lib/5.8.8/i686-linux/auto/Data/Dumper/Dumper.so' for module Data::Dumper: /opt/bitnami/perl/lib/5.8.8/i686-linux/auto/Data/Dumper/Dumper.so: undefined symbol: PL_sv_undef at /opt/bitnami/perl/lib/5.8.8/i686-linux/XSLoader.pm line 70.
at /opt/bitnami/perl/lib/5.8.8/i686-linux/Data/Dumper.pm line 36
Compilation failed in require at /usr/share/autoconf/Autom4te/C4che.pm line 33.
BEGIN failed--compilation aborted at /usr/share/autoconf/Autom4te/C4che.pm line 33.
Compilation failed in require at /usr/bin/autom4te line 38.
BEGIN failed--compilation aborted at /usr/bin/autom4te line 38.
ERROR: `phpize' failed
Any ideas how to fix?
Try configuring manually as it seems bitnami is a bit funky:
$ sudo apt-get update
$ sudo apt-get install build-essential libtool autoconf unzip wget
Download the latest source code from the web page, uncompress it and compile the module.
$ wget http://pecl.php.net/get/mongo-1.4.3.tgz
$ tar -zxf mongo*
$ export PHP_AUTOCONF=/usr/bin/autoconf
$ export PHP_PREFIX=/opt/bitnami/php
$ cd mongo-*
$ /opt/bitnami/php/bin/phpize
$ ./configure
$ make
$ sudo make install
Adapted from: http://wiki.bitnami.com/Components/PHP#How_to_install_OAuth_module.3f
well i finally got it working. I ran through the steps to install mongo extension on mac server and it worked for my bitnami lamp stack.
The instructions were on this blog:
http://andres.jaimes.net/857/setup-php-mongo-on-mac/