# Can't upgrade to mautic 3.02 =\> 4.2 from command line

**URL:** <https://forum.mautic.org/t/cant-upgrade-to-mautic-3-02-4-2-from-command-line/23209>\
**Category:** Product Support\
**Tags:** mautic-3\
**Created:** [March 22, 2022, 11:38pm UTC](https://forum.mautic.org/t/cant-upgrade-to-mautic-3-02-4-2-from-command-line/23209 "2022-03-22T23:38:05Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![vanguy765](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/vanguy765/32/6750_2.png) [@vanguy765](https://forum.mautic.org/u/vanguy765)\
**Post date:** [March 22, 2022, 11:38pm UTC](https://forum.mautic.org/t/cant-upgrade-to-mautic-3-02-4-2-from-command-line/23209/1 "2022-03-22T23:38:05Z")

</div>

**Your software**  
My Mautic version is: 3.02  
My PHP version as given by Mautic is: 7.3.33  
DB Server type: MariaDB  
DB Server version: 10.2.32

Webserver: nginx/1.20.2  
PHP version as given by phpMyAdmin: 7.4.28

I’m on Amazon Lightsail/Ubuntu/Plesk

**Your problem**  
My problem is:  
I can’t upgrade to mautic 4.2, even from the command line. The update:find command says that I have the latest version installed.

Steps I have tried to fix the problem:  
I’ve tried updating to PHP 7.4.28, but update:find still says I have the latest version.

What is the work around for this?

---

<div class="post-metadata">

**Author:** ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)\
**Post date:** [March 22, 2022, 11:44pm UTC](https://forum.mautic.org/t/cant-upgrade-to-mautic-3-02-4-2-from-command-line/23209/2 "2022-03-22T23:44:01Z")

</div>

Hi,

this is probably because of previous unsuccessful / partial updates. Try the following:

- Backup source and database
- Reinstall current version of mautic 3.0.2 (clone / copy core files from Mautic release) and then copy instance specific folders and files to this fresh clone

It is possible that you will have to revert app/config/local.php which is trickier since this is specific to your instance - but first try the above and lets see what issues you face then.

---

<div class="post-metadata">

**Author:** ![vanguy765](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/vanguy765/32/6750_2.png) [@vanguy765](https://forum.mautic.org/u/vanguy765)\
**Post date:** [March 22, 2022, 11:53pm UTC](https://forum.mautic.org/t/cant-upgrade-to-mautic-3-02-4-2-from-command-line/23209/4 "2022-03-22T23:53:27Z")

</div>

Thanks, I will give that a go. Could you clarify what are “instance specific folders”, please? Is that like a file I’ve written to handle a webhook?

---

<div class="post-metadata">

**Author:** ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)\
**Post date:** [March 23, 2022, 11:33am UTC](https://forum.mautic.org/t/cant-upgrade-to-mautic-3-02-4-2-from-command-line/23209/5 "2022-03-23T11:33:06Z")

</div>

These are folders in which mautic places uploads of any kind or some other files that are created on the fly and are of relevance to the user, those folders are:

- media
- themes
- local\*.php files in app/config

Hope it helps.

Mautic has

---

<div class="post-metadata">

**Author:** ![vanguy765](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/vanguy765/32/6750_2.png) [@vanguy765](https://forum.mautic.org/u/vanguy765)\
**Post date:** [March 23, 2022, 5:17pm UTC](https://forum.mautic.org/t/cant-upgrade-to-mautic-3-02-4-2-from-command-line/23209/6 "2022-03-23T17:17:10Z")

</div>

That was helpful, thanks [mzagmajster](https://forum.mautic.org/u/mzagmajster).

So I did a new install of Mautic Ver 3.02, copied over my old local.php to the new install (nothing else), and updated all obvious references in local.php to point to the new install. I checked the new Mautic and all of the data appeared to display fine. Then I updated to php 7.4.28.

Finally, I did mautic:update:find (making sure to give the path to the new instance). But the results were the same, “Great! You are running the current version of Mautic.”

Did I miss something?

---

<div class="post-metadata">

**Author:** ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)\
**Post date:** [March 23, 2022, 6:11pm UTC](https://forum.mautic.org/t/cant-upgrade-to-mautic-3-02-4-2-from-command-line/23209/7 "2022-03-23T18:11:46Z")

</div>

> [@vanguy765](#):
>
> Finally, I did mautic:update:find (making sure to give the path to the new instance).

1. Where did you download files for Mautic 3.0.2?
2. What path did you give to update command, you should run this command inside mautic root directory.
3. When you run php bin/console --version what does it say in the terminal?
4. What does it say at the bottom of the page in the right corner? What version is shown there?

---

<div class="post-metadata">

**Author:** ![vanguy765](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/vanguy765/32/6750_2.png) [@vanguy765](https://forum.mautic.org/u/vanguy765)\
**Post date:** [March 23, 2022, 6:30pm UTC](https://forum.mautic.org/t/cant-upgrade-to-mautic-3-02-4-2-from-command-line/23209/8 "2022-03-23T18:30:20Z")

</div>

Thanks for your help, [mzagmajster](https://forum.mautic.org/t/cant-upgrade-to-mautic-3-02-4-2-from-command-line/23209/7).  
0. I downloaded the files from github: [Release 3.0.2 · mautic/mautic · GitHub](https://github.com/mautic/mautic/releases/tag/3.0.2)

1. /var/www/vhosts/domain/originalmautic/clonemauticfiles/bin/console mautic:update:find
2. Mautic 3.0.2 - app/prod (kernel: app, env: prod, debug: false)
3. v3.0.2

---

<div class="post-metadata">

**Author:** ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)\
**Post date:** [March 23, 2022, 6:43pm UTC](https://forum.mautic.org/t/cant-upgrade-to-mautic-3-02-4-2-from-command-line/23209/9 "2022-03-23T18:43:00Z")

</div>

Can you try to run find command like this:

```auto
cd /var/www/vhosts/domain/originalmautic/clonemauticfiles
php bin/console mautic:update:find

```

There are couple of possibilities:

- find command pre-checks some values in config file, maybe thats why it out
- ‘system\_update\_url’ =\> ‘[https://api.github.com/repos/mautic/mautic/releases](https://api.github.com/repos/mautic/mautic/releases)’, - can you check that your url s set to this in your app/config/local.php

---

<div class="post-metadata">

**Author:** ![vanguy765](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/vanguy765/32/6750_2.png) [@vanguy765](https://forum.mautic.org/u/vanguy765)\
**Post date:** [March 23, 2022, 6:52pm UTC](https://forum.mautic.org/t/cant-upgrade-to-mautic-3-02-4-2-from-command-line/23209/10 "2022-03-23T18:52:06Z")

</div>

Running update from the root directory gives the same result.

I confirm (with cut and paste) ‘system\_update\_url’ =\> ‘[https://api.github.com/repos/mautic/mautic/releases](https://api.github.com/repos/mautic/mautic/releases)’,

---

<div class="post-metadata">

**Author:** ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)\
**Post date:** [March 23, 2022, 7:35pm UTC](https://forum.mautic.org/t/cant-upgrade-to-mautic-3-02-4-2-from-command-line/23209/11 "2022-03-23T19:35:37Z")

</div>

I mean there is always an option of updating manually:

- download latest 3.x files
- replace the files in current instance
- run php bin/console mautic:update:apply
- run php bin/console mautic:update:apply --finish

At this point you can try to use find & update command again to update to the latest 4.x version, if it still does not work you can repeat procedure with 4.x files

---

<div class="post-metadata">

**Author:** ![vanguy765](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/vanguy765/32/6750_2.png) [@vanguy765](https://forum.mautic.org/u/vanguy765)\
**Post date:** [March 23, 2022, 8:55pm UTC](https://forum.mautic.org/t/cant-upgrade-to-mautic-3-02-4-2-from-command-line/23209/12 "2022-03-23T20:55:20Z")

</div>

Thanks for your help so far…

I installed Mautic 3.3.4, replaced the files in the current directory and from its root directory executed update:apply. I get this error:

In ListModel.php line 78:  
Type error: Argument 1 passed to Mautic\LeadBundle\Model\ListModel::\_\_construct() mus  
t be an instance of Mautic\CategoryBundle\Model\CategoryModel, instance of Mautic\Cor  
eBundle\Helper\CoreParametersHelper given, called in /var/www/vhosts/domain/originalmautic/clonedmautic/var/cache/prod/Containe  
r5xuxk9r/appProdProjectContainer.php on line 9240

I don’t think things look good at this point. Luckily, I can input the essential data I need with just a couple of hours work.

---

<div class="post-metadata">

**Author:** ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)\
**Post date:** [March 23, 2022, 10:10pm UTC](https://forum.mautic.org/t/cant-upgrade-to-mautic-3-02-4-2-from-command-line/23209/13 "2022-03-23T22:10:29Z")

</div>

- make sure you run the supported php version
- rm -rf var/cache/dev/\* var/cache/prod/\*
- php bin/console mautic:plugins:reload --env=prod

---

<div class="post-metadata">

**Author:** ![raramuridesign](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/raramuridesign/32/13226_2.png) [@raramuridesign](https://forum.mautic.org/u/raramuridesign)\
**Post date:** [March 24, 2022, 4:47pm UTC](https://forum.mautic.org/t/cant-upgrade-to-mautic-3-02-4-2-from-command-line/23209/14 "2022-03-24T16:47:23Z")

</div>

@vanguy765 Try do an incremental update using the command line where you install mautic from a zip file. Then run database migrations after each step. This will be tedious but it should get you to the latest version. Try not do a big jump in versions, as a lot changes and some file locations and or commands may not work.

remember to do each upgrade…incremental  
Then database migrate  
clear cache  
next upgrade  
etc

Hope this helps  
M.

---

<div class="post-metadata">

**Author:** ![vanguy765](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/vanguy765/32/6750_2.png) [@vanguy765](https://forum.mautic.org/u/vanguy765)\
**Post date:** [March 24, 2022, 5:16pm UTC](https://forum.mautic.org/t/cant-upgrade-to-mautic-3-02-4-2-from-command-line/23209/15 "2022-03-24T17:16:15Z")

</div>

[raramuridesign](https://forum.mautic.org/t/cant-upgrade-to-mautic-3-02-4-2-from-command-line/23209/14), I’m inputting the data by hand. But for the next person your suggestion for incremental upgrades is good as I did use the zip files. (My problem was the db was no longer “whole”.)

For the sake of completion, how do I do a database migration?

---

<div class="post-metadata">

**Author:** ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)\
**Post date:** [March 24, 2022, 5:22pm UTC](https://forum.mautic.org/t/cant-upgrade-to-mautic-3-02-4-2-from-command-line/23209/16 "2022-03-24T17:22:02Z")

</div>

- backup database
- run php bin/console doctrine:migrations:status
- run php bin/console doctrine:migrations:migrate

---

<div class="post-metadata">

**Author:** ![raramuridesign](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/raramuridesign/32/13226_2.png) [@raramuridesign](https://forum.mautic.org/u/raramuridesign)\
**Post date:** [March 25, 2022, 7:33am UTC](https://forum.mautic.org/t/cant-upgrade-to-mautic-3-02-4-2-from-command-line/23209/17 "2022-03-25T07:33:12Z")

</div>

@vanguy765 glad it worked  
You can see from @mzagmajster the suggestion to run the command line migrations of the database.  
Was the upgrade now successful?

---

<div class="post-metadata">

**Author:** ![vanguy765](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/vanguy765/32/6750_2.png) [@vanguy765](https://forum.mautic.org/u/vanguy765)\
**Post date:** [March 29, 2022, 3:50pm UTC](https://forum.mautic.org/t/cant-upgrade-to-mautic-3-02-4-2-from-command-line/23209/18 "2022-03-29T15:50:04Z")

</div>

[raramuridesign](https://forum.mautic.org/u/raramuridesign), [mzagmajster](https://forum.mautic.org/u/mzagmajster) No, the upgrade was not successful. I downloaded 3.1 from Github and copied the unzipped files into my current directory. When I tried to migrate the database I got the following error:

In AmazonTransport.php line 35:

Type error: Argument 4 passed to Mautic\EmailBundle\Swiftmailer\Transport\AmazonTransport::\_\_construct() must be an instance of Mautic\EmailBundle\Swiftmailer\Amazon\AmazonCallback, instance of Mautic\CoreBundle\Translation\Translator given, called in /var/www/vhosts/domain/subdomain/clonemauticfiles/var/cache/prod/Container5xuxk9r/getMautic\_Transport\_AmazonService.php on line 8

I have ported the essential parts of my data. But, what did I miss to get that error?

(It was not that I did not clear my cache, was it?)

---

<div class="post-metadata">

**Author:** ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)\
**Post date:** [March 29, 2022, 3:51pm UTC](https://forum.mautic.org/t/cant-upgrade-to-mautic-3-02-4-2-from-command-line/23209/19 "2022-03-29T15:51:39Z")

</div>

Run:

- rm -rf /var/cache/prod/\* var/cache/dev/\*
- php bin/console mautic:plugins:reload --env=prod

Also you cant just copy files to an existing mautic dir.

Create new mauitc dir and copy local.php & ,media files to the new dir

---

<div class="post-metadata">

**Author:** ![vanguy765](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/vanguy765/32/6750_2.png) [@vanguy765](https://forum.mautic.org/u/vanguy765)\
**Post date:** [March 29, 2022, 4:08pm UTC](https://forum.mautic.org/t/cant-upgrade-to-mautic-3-02-4-2-from-command-line/23209/20 "2022-03-29T16:08:17Z")

</div>

OK. I will have to try this later, just to check this works for a time when things go south on me. Thanks for your help.

(I feel like an idiot… The instructions to clear the cache and reload plugins is right there in your earlier post.

So, for the next guy, can you confirm the following as a general guide? If you have trouble upgrading your Mautic installation, do it manually one incremental update at a time using the following steps:

- backup your database
- Create new mauitc dir with incremental update files
  - find the files here [Releases · mautic/mautic · GitHub](https://github.com/mautic/mautic/releases) (remember to scroll to the bottom)

- copy local.php & ,media files to the new dir
- rm -rf /var/cache/prod/\* var/cache/dev/\*
- php bin/console mautic:plugins:reload --env=prod
- try to upgrade through the command line
  - run php bin/console mautic:update:apply
  - run php bin/console mautic:update:apply --finish

- OR (if that fails) migrate the DB
  - run php bin/console doctrine:migrations:status
  - run php bin/console doctrine:migrations:migrate

Remember, copying the new files to the old directory will not work, make a new directory and copy your local.php & media files to it.

A good reference for what happens during a regular upgrade is here (but dated) [Upgrade steps | Mautic](https://docs.mautic.org/en/mautic-3-upgrade/upgrade-steps)

Also, be aware that you may need to upgrade your PHP instance along the way to upgrading your Mautic. The php requirements for Mautic are here, [Requirements](https://www.mautic.org/download/requirements)
