cotech / website

The Cooperative Technologists WordPress website
https://www.coops.tech/
GNU General Public License v3.0
24 stars 5 forks source link

Error upgrading to WordPress 4.9.2 #86

Closed chriscroome closed 6 years ago

chriscroome commented 6 years ago

I have updated composer.json on the dev branch to change these lines:

    "johnpbloch/wordpress-core": "4.9.2",

    "wpackagist-plugin/contact-form-7": "4.9.2",

    "wpackagist-plugin/flamingo": "1.8",

When the update script it run it generates this error:

No local changes to save
Already up-to-date.
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
Nothing to install or update
Generating autoload files
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
up to date in 5.24s
/home/cotechdev/sites/web/app/themes/coop-tech-oowp-theme/node_modules/laravel-elixir/node_modules/require-dir/index.js:97
            if (!require.extensions.hasOwnProperty(ext)) {
                                    ^

TypeError: require.extensions.hasOwnProperty is not a function
    at requireDir (/home/cotechdev/sites/web/app/themes/coop-tech-oowp-theme/node_modules/laravel-elixir/node_modules/require-dir/index.js:97:37)
    at loadOfficialExtensions (/home/cotechdev/sites/web/app/themes/coop-tech-oowp-theme/node_modules/laravel-elixir/dist/bootstrap/LoadExtensions.js:15:27)
    at Object.<anonymous> (/home/cotechdev/sites/web/app/themes/coop-tech-oowp-theme/node_modules/laravel-elixir/dist/bootstrap/LoadExtensions.js:30:1)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
    at Module.require (module.js:587:17)
    at require (internal/module.js:11:18)
Success: WordPress database already at latest db version 38590.

Anyone know what the problem is and how to fix it?

nicksellen commented 6 years ago

This says that support for require.extensions was dropped in node >=8. And this says that the require-dir lib can be upgraded to 0.3.2 to fix (which is true). But thats a dependency of laravel-elixir which specifies version "^0.3.0".

The require-dir in the current yarn.lock though is already specified as 0.3.2.

I'm not sure what that script is doing (where can I see it again?), but it looks like the incorrect node libs are installed (which is resolved by running yarn in /home/cotechdev/sites/web/app/themes/coop-tech-oowp-theme).

Also, if you update composer.json, you must also run composer update to update composer.lock too, or you have an invalid combination of files (as the warning mentions).

Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.

chriscroome commented 6 years ago

Cheers @nicksellen, the update script is here, if it is any help the server is running:

node -v
v8.9.4

I'll install yarn tomorrow, don't have the time right now, thanks for looking at this :-)

nicksellen commented 6 years ago

Ok, I'd suggest switching the npm install step to yarn as the project comes with yarn.lock (and not package-lock.json - the npm equivalent).

chriscroome commented 6 years ago

So, yarn is now installed and it runs without an issue, however the dev.coops.tech hasn't updated and there is this warning when running the update script:

Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.

Something needs changing in the update script: I guess?

This is the full output:

bash ~/bin/update 
Saved working directory and index state On dev: Local changes stashed
HEAD is now at 743dd0f Contact Form 7 and Flamingo updated
Already up-to-date.
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
Nothing to install or update
Generating autoload files
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
yarn install v1.3.2
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
[1/2] ⠂ node-sass
[1/2] ⠄ node-sass
[1/2] ⠄ node-sass
[1/2] ⡀ node-sass
success Saved lockfile.
Done in 4.76s.
[10:05:38] Using gulpfile ~/sites/web/app/themes/coop-tech-oowp-theme/gulpfile.js
[10:05:38] Starting 'all'...
[10:05:38] Starting 'sass'...
[10:05:40] Finished 'sass' after 1.66 s
[10:05:40] Starting 'scripts'...
[10:05:40] Finished 'scripts' after 289 ms
[10:05:40] Starting 'scripts'...
[10:05:40] Finished 'scripts' after 8.4 ms
[10:05:40] Starting 'copy'...
[10:05:40] Finished 'copy' after 35 ms
[10:05:40] Starting 'copy'...
[10:05:40] Finished 'copy' after 5.92 ms
[10:05:40] Starting 'copy'...
[10:05:40] Finished 'copy' after 39 ms
[10:05:40] Starting 'copy'...
[10:05:40] Finished 'copy' after 257 ms
[10:05:40] Starting 'copy'...
[10:05:40] Finished 'copy' after 11 ms
[10:05:40] Finished 'all' after 2.31 s
[10:05:40] Starting 'default'...
┌───────────────┬──────────────────────────┬────────────────────────────────────────────────────────────┬───────────────────────────────┐
│ Task          │ Summary                  │ Source Files                                               │ Destination                   │
├───────────────┼──────────────────────────┼────────────────────────────────────────────────────────────┼───────────────────────────────┤
│ mix.sass()    │ 1. Compiling Sass        │ assets/scss/app.scss                                       │ public/css/app.css            │
│               │ 2. Autoprefixing CSS     │                                                            │                               │
│               │ 3. Concatenating Files   │                                                            │                               │
│               │ 4. Writing Source Maps   │                                                            │                               │
│               │ 5. Saving to Destination │                                                            │                               │
├───────────────┼──────────────────────────┼────────────────────────────────────────────────────────────┼───────────────────────────────┤
│ mix.scripts() │ 1. Concatenating Files   │ node_modules/jquery/dist/jquery.js                         │ public/js/vendor.js           │
│               │ 2. Writing Source Maps   │ node_modules/leaflet/dist/leaflet.js                       │                               │
│               │ 3. Saving to Destination │ node_modules/what-input/dist/what-input.js                 │                               │
│               │                          │ node_modules/foundation-sites/dist/foundation.js           │                               │
│               │                          │ node_modules/datatables.net/js/jquery.dataTables.js        │                               │
│               │                          │ node_modules/datatables.net-zf/js/dataTables.foundation.js │                               │
├───────────────┼──────────────────────────┼────────────────────────────────────────────────────────────┼───────────────────────────────┤
│ mix.scripts() │ 1. Concatenating Files   │ assets/js/app.js                                           │ public/js/app.js              │
│               │ 2. Writing Source Maps   │                                                            │                               │
│               │ 3. Saving to Destination │                                                            │                               │
├───────────────┼──────────────────────────┼────────────────────────────────────────────────────────────┼───────────────────────────────┤
│ mix.copy()    │ 1. Saving to Destination │ assets/img/**/*                                            │ public/img/                   │
├───────────────┼──────────────────────────┼────────────────────────────────────────────────────────────┼───────────────────────────────┤
│ mix.copy()    │ 1. Saving to Destination │ node_modules/leaflet/dist/images/**/*                      │ public/css/images/            │
├───────────────┼──────────────────────────┼────────────────────────────────────────────────────────────┼───────────────────────────────┤
│ mix.copy()    │ 1. Saving to Destination │ assets/fonts/**/*                                          │ public/fonts/                 │
│               │                          │ node_modules/font-awesome/fonts/**/*                       │                               │
├───────────────┼──────────────────────────┼────────────────────────────────────────────────────────────┼───────────────────────────────┤
│ mix.copy()    │ 1. Saving to Destination │ node_modules/foundation-icons/svgs/**/*                    │ public/foundation-icons/svgs/ │
├───────────────┼──────────────────────────┼────────────────────────────────────────────────────────────┼───────────────────────────────┤
│ mix.copy()    │ 1. Saving to Destination │ node_modules/foundation-icons/foundation-icons.css         │ public/foundation-icons/      │
│               │                          │ node_modules/foundation-icons/foundation-icons.eot         │                               │
│               │                          │ node_modules/foundation-icons/foundation-icons.scss        │                               │
│               │                          │ node_modules/foundation-icons/foundation-icons.svg         │                               │
│               │                          │ node_modules/foundation-icons/foundation-icons.ttf         │                               │
│               │                          │ node_modules/foundation-icons/foundation-icons.woff        │                               │
└───────────────┴──────────────────────────┴────────────────────────────────────────────────────────────┴───────────────────────────────┘
[10:05:40] Finished 'default' after 10 ms
Success: WordPress database already at latest db version 38590.

Incidently I could enable SSH access which would allow people with public keys on the server to do things like use WP-CLI and everything else…

decentral1se commented 6 years ago

there is this warning when running the update script:

Random internet trawling, but from https://github.com/composer/composer/issues/754#issuecomment-169682867, could you add --lock to the composer update command? Might be worth a shot, seems to be what we want here.

chriscroome commented 6 years ago

Thanks @lwm, but there is still this warning:

Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.

And also the updates still haven't been applied and there are now also three more outstanding:

chriscroome commented 6 years ago

Perhaps that is a clue — none of the latest three ACF plugins with updates apper to be listed in the composer.json file — could someone have installed plugins using the WordPress web interface and this has stopped updates via composer.json working? (this is just a guess…)

nicksellen commented 6 years ago

The repository should hold a valid combination of composer.json and composer.lock files, and the server scripts should just run composer install - otherwise it loses the benefit of detirministic dependencies.

The current state of json/lock files in the repo (dev branch) is invalid, as running composer install gives the Warning: The lock file is not up to date ... message.

Running composer update gave me:

Your requirements could not be resolved to an installable set of packages.

Problem 1

  • The requested package wpackagist-plugin/flamingo 1.8 exists as wpackagist-plugin/flamingo[1.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.0.5, 1.0.6, 1.1, 1.1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, dev-trunk] but these are rejected by your constraint.

It's specified as 1.8 which doesn't seem to exist, so I swapped it to 1.8 and ran composer update, and all went fine (I pushed those changes to https://github.com/cotech/website/tree/fixup-composer - all from dev branch, not sure which branch you are working on).

chriscroome commented 6 years ago

Cheers @nicksellen, I'm working on the dev branch.

chriscroome commented 6 years ago

I clicked the update link here and now there is a 1.8, sorry I didn't see that error before.

chriscroome commented 6 years ago

However I'm afraid there is still the core problem outstanding the updates haven't been applied and I still don't understand why.

chriscroome commented 6 years ago

Thanks for your help with this @nicksellen, I needed to RTFM 😊, however the site hasn't updated to WordPress 4.9.2 — is that because johnpbloch hasn't updated his WordPress repo for the latest point release?

chriscroome commented 6 years ago

Sorry there is a tag for 4.9.2.

chriscroome commented 6 years ago

So, I'm suck again I'm afraid, the dev site is promoting for an update, but the files are updated:

git branch
  WordPress_4.7.3
* dev
  disable-forms
  master
  outlandishideas/remove-composer-in-theme
  wp-4-7-4
  wp-4-7-5
  wp-4-8-0
  wp-4-8-1

git pull
Already up-to-date.

grep "4\.9\.2" composer.*
composer.json:    "johnpbloch/wordpress-core": "4.9.2",
composer.json:    "wpackagist-plugin/contact-form-7": "4.9.2",
composer.lock:            "version": "4.9.2",
composer.lock:                "wordpress/core-implementation": "4.9.2"
composer.lock:            "version": "4.9.2",
composer.lock:                "reference": "tags/4.9.2"
composer.lock:                "url": "https://downloads.wordpress.org/plugin/contact-form-7.4.9.2.zip",

What am I doing wrong now?

chriscroome commented 6 years ago

I have just tried updating to WordPress 4.9.4, see 78183af, but again this hasn't made a difference to the version the dev site is running — anyone have any idea what am I doing wrong?

nicksellen commented 6 years ago

Ah, sorry it's been so frustrating @chriscroome, especially when you are very happy doing these things using the normal way of using wordpress.

At the moment I am suspecting it's because in the setup script wordpess is installed if it's not already there. It might be that it only copies the wordpress files across at that point. I have not confirmed this theory though. I'll add it to my task list to investigate that :)

chriscroome commented 6 years ago

Thanks @nicksellen, the weird thing is that it used to work without a problem, for example I'm sure we didn't have this problem in November, also the servers hosting the dev and live sites are not running the site in Docker so I'm not sure how the setup-and-run.sh script plays a role there?

nicksellen commented 6 years ago

Aha! I've found the issue, it was the switch from wordpress to wordpress-core in https://github.com/cotech/website/commit/7b507726907c1b2bbb7514c1cc978626e3ac0ece

https://discourse.roots.io/t/johnpbloch-wordpress-moved-to-a-new-configuration-and-wp-goes-missing/9124/45 has a few details, might need a cache clear.

Locally now (using docker-compose setup), I can switch between the versions and it all works fine, the steps for changing the version are:

  1. update composer.json with desired version
  2. run docker-compose run wordpress composer update (will create an update composer.lock file)
  3. (assume db is up and running) run docker-compose run wordpress wp --allow-root core update-db to perform any db schema updates
  4. commit modified composer.json and composer.lock files

On server, it should just be:

  1. run composer install
  2. run wp core update-db (not sure if wp is configured/setup on server, might need to be installed and more options passed)
nicksellen commented 6 years ago

I pushed updates to dev branch (I actually meant to push to another branch but mangled my git commands :/ )

chriscroome commented 6 years ago

That does sound like the probably cause of this issue, the update script is run after changes in the repo, via a crontab and that contains:

WP=$(which wp)
composer install
${WP} core update-db

But the dev site still hasn't updated… so we arn't quite there yet…

chriscroome commented 6 years ago

I tried this suggestion on the dev server:

cd ~/sites
composer remove johnpbloch/wordpress
composer clear-cache
composer require johnpbloch/wordpress:4.9.4

And that seems to have done the trick :-)

nicksellen commented 6 years ago

Great :)

I think/hope that's just a one-off thing to run, seems like johnpbloch totally changed what is in the package but gave it the same name and versions (as they match the wordpress ones), which would understandably confuse composer.

chriscroome commented 6 years ago

For some reason this doesn't appear to work on the live server, I'm not sure why, it was fine on the dev server:

composer remove johnpbloch/wordpress
  johnpbloch/wordpress is not required in your composer.json and has not been removed
  Package "johnpbloch/wordpress" listed for update is not installed. Ignoring.
  Loading composer repositories with package information
  Updating dependencies (including require-dev)                        
  Nothing to install or update
  Writing lock file
  Generating autoload files
composer clear-cache
  Clearing cache (cache-dir): /home/cotech/.composer/cache
  Clearing cache (cache-files-dir): /home/cotech/.composer/cache/files
  Clearing cache (cache-repo-dir): /home/cotech/.composer/cache/repo
  Cache directory does not exist (cache-vcs-dir): 
  All caches cleared.
composer require johnpbloch/wordpress:4.9.4
  ./composer.json has been updated
  Loading composer repositories with package information
  Updating dependencies (including require-dev)                        
  Your requirements could not be resolved to an installable set of packages.

    Problem 1
      - Installation request for johnpbloch/wordpress 4.9.4 -> satisfiable by johnpbloch/wordpress[4.9.4].
      - johnpbloch/wordpress 4.9.4 requires johnpbloch/wordpress-core 4.9.4 -> satisfiable by johnpbloch/wordpress-core[4.9.4] but these conflict with your requirements or minimum-stability.

  Installation failed, reverting ./composer.json to its original content.

The odd thing is that the composer.json hasn't updated:

git branch
  * master
git pull
  Already up-to-date.
grep johnpbloch composer.json 
    "johnpbloch/wordpress-core": "4.9.1",

Are this is what we have in the repo. so did I mess the merge request up? I wanted to merge dev into master...

chriscroome commented 6 years ago

Do'h, the merge hasn't been completed!