Roots Discourse

Trying to run composer but "command not found"


I’m following my Trellis/bedrock/Sage discovery: after my first problem, i managed to install everything and i have now my VM working thanks to Trellis with Bedrock and Sage installed. But in the meantime, Wordpress has been updated from 4.5.1 to 4.5.2 so i wanted to update the Wordpress used in my project and the VM.

To do it i tried that:

  • update the Wordpress version in the “composer.json” file
  • run “composer update”.
    In response to that command, i unfortunately got a “composer: command not found” error.

I thought that Composer was installed via the “composer” ansible role during Trellis installation.

I guess that there is something obvious here that i miss, so any help is welcome :confused:

Are you running that command locally on your host OS (OSX?) or on the VM?

Trellis installs everything on the VM.

I did it on the host OS (OSX indeed), thinking that it would by carried to the VM through the sync mecanism.

So what i need is get in the VM (vagrant ssh), and run “composer update” (assuming the “composer.json” file has already been synched to the VM)?

That’s correct. Vagrant only syncs files.

edit: it only syncs files for the WP site path, not your whole system.

OK, so it means that Composer is installed by Vagrant in the VM system and then not synk back to my OS as it’s not installed in the WP site path.

In the VM, i found the updated “composer.json” file in the “” folder at the root of the VM so i ran composer update in that folder and guess what… it’s working :astonished:

Thanks for the help: it worked and i learned a valuable lesson!

1 Like

If you forget to run ansible-galaxy install -r requirements.yml before you run vagrant up on the first time you set up Trellis you will run into this issue:
ERROR! the role 'composer' was not found in /Users/../trellis/roles:/Users/..
The error appears to have been in ../trellis/dev.yml'...

Destroy your box, install the requirements, and try again.

1 Like