RuntimeException no composer.json present in current directory

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.

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:

1 Like

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.

2 Likes

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!

1 Like

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.

2 Likes

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 command to force a specific version of composer, in this case 1.x.
Trellis should also offer a composer version field.

1 Like

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 }
2 Likes

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

Hi Everyone,

Thank you for your answers.

I commented this out and did a vagrant up again

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.

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.

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

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.

@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.

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?

2 Likes

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.

1 Like

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