# RuntimeException no composer.json present in current directory

**URL:** https://discourse.roots.io/t/runtimeexception-no-composer-json-present-in-current-directory/19374
**Category:** trellis
**Created:** 2020-10-25T11:14:58Z
**Posts:** 16

## Post 1 by @TJ_Khara — 2020-10-25T11:14:58Z

Hello,

I am trying to create a local setup with trellis and bedrock on my linux mint machine with vagrant.

```
I have run into this error:

non-zero return code
Changed current directory to /root/.composer
Do not run Composer as root/super user! See https://getcomposer.org/root for
details

  [RuntimeException]
  No composer.json present in the current directory, this may be the cause of
the following exception.
```

My setup is as follows:

- site (directory with bedrock files created by composer)
- trellis (clones from git repo)

The only thing i changed in the vagrant.default.yml file was the syncing protocol to rsync as nfs was giving me issues.

vagrant\_mount\_type: ‘rsync’

Any guidance on this would be appreciated.

Thanks.

---

## Post 2 by @silumesii — 2020-10-25T12:31:06Z

Hello @TJ_Khara! Welcome to the community :slight_smile:

I am experiencing the same issue when deploying staging and production servers today. This seems to be related to Prestissimo and the release of Composer 2:

> <https://github.com/roots/trellis/issues/1088#issuecomment-716048254>
>
> we're currently using https://github.com/hirak/prestissimo to make composer packages download faster and it works great
> it looks like it's been added upstream to...

---

## Post 3 by @silumesii — 2020-10-25T12:51:25Z

A temporary fix is to comment out the requirement for Prestissimo in `group_vars/all/main.yml`:

```
#composer_global_packages:
# - { name: hirak/prestissimo }
```

… and then re-provision.

---

## Post 4 by @psymeon — 2020-10-27T11:58:37Z

I run across a similar issue as well. In my case the resent release of version 2 of Composer (2 days ago) was causing the issue. We are using an older version of Trellis (1.0.0-rc2), so I’m not sure if the following will apply to everyone.

The way we solved this was by setting `composer_keep_updated: false` and adding `composer_version: '1.10.6'` (or probably whatever \<2 version works best for you) to the `group_vars/all/main.yml` file.

So basically the first two lines of the file now look like this:

```
composer_keep_updated: false
composer_version: '1.10.6'
```

I hope this helps!

---

## Post 5 by @joshb — 2020-10-30T00:00:01Z

This is so much fun!

I had to provision a server today, which was fine but now I can’t deploy anything. I’ve tried everything possible to get past this but no cigar.

```
non-zero return code
Installing dependencies from lock file
Verifying lock file contents can be installed on current platform.
Your lock file does not contain a compatible set of packages. Please run
composer update.

  Problem 1
    - composer/installers is locked to version v1.6.0 and an update of this
package was not requested.
    - composer/installers v1.6.0 requires composer-plugin-api ^1.0 -> found
composer-plugin-api[2.0.0] but it does not match the constraint.
  Problem 2
    - composer/installers v1.6.0 requires composer-plugin-api ^1.0 -> found
composer-plugin-api[2.0.0] but it does not match the constraint.
    - soberwp/controller 2.1.1 requires composer/installers ^1.0 ->
satisfiable by composer/installers[v1.6.0].
    - soberwp/controller is locked to version 2.1.1 and an update of this
package was not requested.

You are using Composer 2, which some of your plugins seem to be incompatible
with. Make sure you update your plugins or report a plugin-issue to ask them
to support Composer 2.
```

First I attempted to comment out:

```
#composer_global_packages:
# - { name: hirak/prestissimo }
```

Reprovisioned fine but deploy still doesn’t work.

Next I tried:

```
composer_keep_updated: false
composer_version: '1.10.6'
```

Reprovisioned fine but deploy still doesn’t work.

I then destroyed my droplet, spooled up a new one, provisioned a new server with the following lines removed:

```
composer_global_packages:
 - { name: hirak/prestissimo }
```

Provisioned fine, deploy doesn’t work.

I keep getting the same error that I posted above. I ran composer update and tried to deploy again. Still doesn’t work.

---

## Post 6 by @strarsis — 2020-10-30T04:48:38Z

Have you ensured that the actual `composer` executable on the Trellis web server is `1.x`, not `2.x`?  
You can use the `composer` [`self-update`](https://getcomposer.org/doc/03-cli.md#self-update-selfupdate-) command to force a specific version of composer, in this case `1.x`.  
Trellis should also offer a composer version field.

---

## Post 7 by @JordanC26 — 2020-10-30T10:38:04Z

Anyone with the issue of Trellis automatically updating to version 2.0. See this response on Github, it’s exactly what I’ve used and works fine, sticking to the version you define.

> <https://github.com/roots/trellis/issues/1245#issuecomment-716165875>
>
> I've read the guidelines for Contributing to Roots Projects
> This request isn't a duplicate of an existing issue (well, it is....

If you make this change, don’t modify/remove this. Leave as-is (if you’re forcing Trellis to use specific 1.x version.)

```
composer_global_packages:
 - { name: hirak/prestissimo }
```

---

## Post 8 by @theMosaad — 2020-10-30T14:19:30Z

Thanks, this worked for me with Trellis (1.5.0).

---

## Post 9 by @TJ_Khara — 2020-10-31T07:19:39Z

Hi Everyone,

Thank you for your answers.

I commented this out and did a vagrant up again

> [@silumesii](#):
>
> A temporary fix is to comment out the requirement for Prestissimo in `group_vars/all/main.yml` :
> 
> ```
> #composer_global_packages:
> # - { name: hirak/prestissimo }
> ```
> 
> … and then re-provision.

But, I get this error:

```
ystem info:
  Ansible 2.10.2; Vagrant 2.2.10; Linux
  Trellis version (per changelog): "Allow WP cron intervals to be configurable"
---------------------------------------------------
The "roots/wordpress-core-installer" plugin was skipped because it requires a
Plugin API version ("^1.0") that does not match your Composer installation
("2.0.0"). You may need to run composer update with the "--no-plugins"
option. Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform. Your lock
file does not contain a compatible set of packages. Please run composer
update. Problem 1 - roots/wordpress-core-installer is locked to version 1.1.0
and an update of this package was not requested. - roots/wordpress-core-
installer 1.1.0 requires composer-plugin-api ^1.0 -> found composer-plugin-
api[2.0.0] but it does not match the constraint. Problem 2 - roots/wordpress-
core-installer 1.1.0 requires composer-plugin-api ^1.0 -> found composer-
plugin-api[2.0.0] but it does not match the constraint.
```

So it seems like i need to try to keep the composer version to below 2.0.

For that i tried the following:

In group\_vars → all → main.yml

```
composer_keep_updated: false

composer_version: '1.10.6'
```

I tried changing the composer version like so:

```
tkhara@tkhara-lenovo:~/envs/trellis/trellis_example_1/trellis$ sudo composer self-update 1.10.6
[sudo] password for tkhara:          
Updating to version 1.10.6 (stable channel).
   Downloading (100%)         
Use composer self-update --rollback to return to version 1.10.13
tkhara@tkhara-lenovo:~/envs/trellis/trellis_example_1/trellis$
```

But, I keep getting this error:

```
The "roots/wordpress-core-installer" plugin was skipped because it requires a
Plugin API version ("^1.0") that does not match your Composer installation
("2.0.0"). You may need to run composer update with the "--no-plugins"
option. Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform. Your lock
file does not contain a compatible set of packages. Please run composer
update. Problem 1 - roots/wordpress-core-installer is locked to version 1.1.0
and an update of this package was not requested. - roots/wordpress-core-
installer 1.1.0 requires composer-plugin-api ^1.0 -> found composer-plugin-
api[2.0.0] but it does not match the constraint. Problem 2 - roots/wordpress-
core-installer 1.1.0 requires composer-plugin-api ^1.0 -> found composer-
plugin-api[2.0.0] but it does not match the constraint. - roots/wordpress
5.5.1 requires roots/wordpress-core-installer >=1.0.0 -> satisfiable by
roots/wordpress-core-installer[1.1.0]. - roots/wordpress is locked to version
5.5.1 and an update of this package was not requested. You are using Composer
2, which some of your plugins seem to be incompatible with. Make sure you
update your plugins or report a plugin-issue to ask them to support Composer
```

Any tips on this?

Thanks,

TJ.

---

## Post 10 by @strarsis — 2020-10-31T11:13:59Z

You have to apply the server playbook (provision step) before you can run the deploy script (separate playbook), otherwise the composer version is not ensured by ansible.

---

## Post 11 by @JordanC26 — 2020-10-31T11:58:56Z

@TJ_Khara - See this comment of mine regarding this issue/temp fix.

> [@RuntimeException no composer.json present in current directory](https://discourse.roots.io/t/runtimeexception-no-composer-json-present-in-current-directory/19374/7):
>
> Anyone with the issue of Trellis automatically updating to version 2.0. See this response on Github, it’s exactly what I’ve used and works fine, sticking to the version you define. If you make this change, don’t modify/remove this. Leave as-is (if you’re forcing Trellis to use specific 1.x version.) composer\_global\_packages: - { name: hirak/prestissimo }

---

## Post 12 by @TJ_Khara — 2020-10-31T13:42:37Z

Hi @JordanC26,

Thanks.

I now uncommented those two lines and ran vagrant up --provision and landed up with this error:

```
non-zero return code
Changed current directory to /root/.composer
Do not run Composer as root/super user! See https://getcomposer.org/root for
details

  [RuntimeException]
  No composer.json present in the current directory, this may be the cause of
the following exception.

  [InvalidArgumentException]
  Package hirak/prestissimo at version @stable has a PHP requirement
incompatible with your PHP version, PHP extensions and Composer version
```

First few lines of main.yml look like this:

```
composer_keep_updated: false

composer_global_packages:

- { name: hirak/prestissimo }

apt_cache_valid_time: 3600

apt_package_state: present

apt_security_package_state: latest

apt_dev_package_state: latest

ntp_timezone: Etc/UTC

ntp_manage_config: true

www_root: /srv/www
```

This is what you were saying right keeping these two lines in as is:

```
composer_global_packages:

    - { name: hirak/prestissimo }
```

Thanks,

TJ.

---

## Post 13 by @TJ_Khara — 2020-10-31T13:44:05Z

@strarsis,

Sorry… i’m not sure i understood what you were saying. Could you elaborate a bit more.

This is the start of my main.yml now:

```
composer_keep_updated: false

composer_global_packages:

- { name: hirak/prestissimo }

apt_cache_valid_time: 3600

apt_package_state: present

apt_security_package_state: latest

apt_dev_package_state: latest

ntp_timezone: Etc/UTC

ntp_manage_config: true

www_root: /srv/www
```

And then i run vagrant up --provision

What do you suggest i do differently?

Thanks.

---

## Post 14 by @JordanC26 — 2020-10-31T14:28:42Z

SSH into your vagrant box. Go to /trellis directory and run `vagrant ssh` now let’s check what version of composer is installed with `composer --version`

Can you confirm this first please.

Did you add the extra lines to dev.yml and server.yml as that comment states, where the composer version is defined?

---

## Post 15 by @TJ_Khara — 2020-11-01T05:55:07Z

> [@TJ_Khara](#):
>
> `composer_version: '1.10.6'`

Hi @JordanC26,

Thanks a lot. That step by step help worked. I was missing this line:

```
composer_keep_updated: false

composer_version: '1.10.6'

composer_global_packages:

- { name: hirak/prestissimo }

apt_cache_valid_time: 3600

apt_package_state: present

apt_security_package_state: latest

apt_dev_package_state: latest

ntp_timezone: Etc/UTC

ntp_manage_config: true

www_root: /srv/www
```

The composer version line and now my main.yml looks like the above.

composer version in the server is 1.10.6

The dev setup looks good to go.

I know this is not related to this thread, but could I ask you to suggest some documentation or resource you may have used to do your first deploy using trellis?

I’d like to make a few changes to this local environment and see if I can deploy it properly.

Thank you.

TJ.

---

## Post 16 by @system — 2020-12-06T11:15:00Z

This topic was automatically closed after 42 days. New replies are no longer allowed.
