Roots Discourse

Composer could not find a composer.json file

#1

I’m setting up a fresh instance of Trellis and Bedrock according to the instructions on Trellis website. However during vagrant up I get the following error:

System info:
  Ansible 2.1.1.0; Vagrant 1.8.5; Darwin
  Trellis at "WP 4.6 Compat: set WP_HOME/SITEURL directly"
---------------------------------------------------
You are running composer with xdebug enabled. This has a major impact on
runtime performance. See https://getcomposer.org/xdebug
Do not run Composer as root/super user! See https://getcomposer.org/root for
details
Composer could not find a composer.json file in
/srv/www/mydomain.pl/current
To initialize a project, please create a composer.json file as described in
the https://getcomposer.org/ "Getting Started" section
failed: [default] (item=mydomain.pl) => {"changed": true, "cmd": ["composer", "install"], "delta": "0:00:00.240805", "end": "2016-09-02 17:21:13.208273", "failed": true, "item": "mydomain.pl", "rc": 1, "start": "2016-09-02 17:21:12.967468", "stderr": "You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug\nDo not run Composer as root/super user! See https://getcomposer.org/root for details\nComposer could not find a composer.json file in /srv/www/mydomain.pl/current\nTo initialize a project, please create a composer.json file as described in the https://getcomposer.org/ \"Getting Started\" section", "stdout": "", "stdout_lines": [], "warnings": []}

I found information about a potential bug in Vagrant 1.8.4, and a recommendation to downgrade to 1.8.1. I did that but the error is exactly the same. It’s not the first time I’m using Trellis (I used it for two commercial projects a few months ago), but it’s the first time I get this kind of error.

When I vagrant ssh and cd /srv/www/mydomain.pl/current/ it’s not linked to my site directory like it should be – instead I only see one empty directory web inside.

Is there anything I can do to fix the problem?

1 Like

#2

Hi there,

Watching this, as I’ve had similar issue.

What happens when you run “composer install” in that directory?

0 Likes

#3

There’s no composer.json in that directory because it’s not linked to my ../site folder. That’s the main issue.

0 Likes

#4

Did you run – in this order…

./trellis

ansible-galaxy install -r requirements.yml

./sagetheme

npm install && npm run build:production

./trellis

vagrant up

If I’m not very explicit with the steps I take I run into all sorts of weird issues.

0 Likes

#5

I don’t use Sage and it has nothing to do with the issue. I did run ansible-galaxy install -r requirements.yml before running vagrant up.

0 Likes

#6

try reinstalling the host manager / bindfs on the vagrant?

sorry, I’m just giving you exactly what I do to get it to work :confused:

5 Likes

#7

Indeed! I run vagrant plugin update and it fixed the problem. Thank you!

6 Likes

#8

Awesome glad to hear!

0 Likes

#9

Yup that worked for me

0 Likes

#10

FWIW I was having same issue, adding new sites to Trellis. I ran $ vagrant halt and then $ vagrant up, noted the following output:

==> default: Creating bind mounts for selected devices
==> default: Creating bind mount from /vagrant-nfs-growdigital to /srv/www/growdigital/current

so I’m guessing this is when the link to /current/ is made.

0 Likes

#11

I was having a similar issue and ran vagrant plugin update and tried running a vagrant provision to pull in the changes, but it actually didn’t work for me without doing a vagrant destroy and vagrant up.

1 Like

#12

For what it is worth, I was banging my head against this/a similar issue. When I SSH’d into the box, the /srv/www/whatever.com/current folder was empty. I am using Ubuntu 16 and it turns out that I was unable to mount to anything within the /home/{user}/ directory – had to move to a non-linked folder and everything worked out fine. If you are in a folder like ~/Development or something like I was, try to move into a non-home folder, and be sure to make your user the owner of the new file before trying to run vagrant up.

2 Likes

#13

For me, this was my own fault. I ran vagrant up --provision from a non-admin windows powershell. Tried again from an admin powershell, worked fine. Just adding my experience since no one seemed to identify this as a potential cause in the prior comments.

0 Likes