3

I created a Drupal 8 site through the manual install process and configured the site through the admin UI for a while. However, I quickly discovered how critical it was to use Composer to add modules due to the prevalence of third-party libraries. But I am getting the following error whenever I try to add any new module, and I will use Drupal Commerce module as an example (note that my production site is currently housed in the /public_html/main directory):

username@mydomain.com [~/public_html/main]# php 
/home3/username/public_html/composer require drupal/commerce
Using version ^2.7 for drupal/commerce
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 14 installs, 1 update, 0 removals
 - Installing drupal/coder (8.2.12): Cloning 984c54a7b1 from cache


[RuntimeException]                                                           
Failed to execute git clone --no-checkout 
'/home3/username/.composer/cache/  
vcs/https---git.drupal.org-project-coder.git/' 
'/home3/username/public_html  
/main/vendor/drupal/coder' --dissociate --reference 
'/home3/username/.compo  
ser/cache/vcs/https---git.drupal.org-project-coder.git/' && cd 
'/home3/username/public_html/main/vendor/drupal/coder' && git remote 
set-url origin 
'https://git.drupal.org/project/coder.git' && git remote add composer 
'https://git.drupal.org/project/coder.git'                                           

Cloning into '/home3/username/public_html/main/vendor/drupal/coder'...       
done.                                                                        
fatal: unable to create thread: Resource temporarily unavailable             
fatal: cannot repack to clean up                                             


require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [-- 
no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update- 
with-dependencies] [--update-with-all-dependencies] [--ignore-platform- 
reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|-- 
optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] 
[--] [<packages>]...

Thanks for any help.

  • Looks like some permission problem to me. Have you tried to delete /home3/username/.composer/cache/ and /home3/username/public_html/main/vendor/ before retrying? – leymannx Jun 11 '18 at 7:14
1

I have successfully battled this error into submission over the past six hours.
I pieced together what I believe were the contributing problems and found a way for things to work correctly in a remote hosted (Bluehost) Drupal installation.

  1. You must be able to use composer commands. If composer is not installed on your remote host, you will need to install ssh and then install composer. SSH lets you use command line typing so you can interact/execute composer commands
  2. login to composer (I opened up Windows powershell and used SSH from there). You will be challenged to put in your password for ssh the first time you use it. If you have it configured tightly, you will be asked everytime.
  3. cd www/your-drupal-directory If you don't start off in the drupal directory, you will not get code dropped into modules/contrib which means nothing will show up in your administration 'install' link from your site. Specifically, you login into composer and then just type the command and hit enter. You'll then see your composer line now has your drupal path showing. My path was www/d8 because Bluehost serves pages from www and I installed drupal in the d8 subdirectory. I'm sure public_html would have worked as well.
  4. Commerce requires more than one module to run properly. When you visit the Commerce installation page, pay careful attention to the Ludwig installation information. The list of seven dependent modules is there. You will need to be sure each dependent module is installed (some may already be installed).
  5. --update-no-dev is the key to success. Adding this option on your composer command will stop the addition of development packages during your module install. A composer command for the general commerce package would be composer require drupal/commerce --update-no-dev then hit enter
  6. Your next problem will be inconsistent 'stability' releases. I used the default settings when I installed composer. You can get around that problem by explicitly referencing the module version you want to install. For example, Commerce requires the Entity module. I used composer require drupal/entity:1.0-beta4 --update-no-dev

The issue of coder not being found seems to come from a difference between what is found in the composer.json file and the composer.lock file. The update-no-dev is telling composer not to require the drupal/coder (and other things)

I am no expert on composer or drupal development. I'm sure others can provide a more technical explanation. It is always a good idea to check for updates periodically for all installed modules and themes. You should have a report in your administration link on your site that gives you an idea of available updates.

  • " If composer is not installed on your remote host" -- this generally is what everyone attempts to do, is use composer as if it were drush. The best course of action is to not worry about composer at all except in local dev or in CI environments. Whats shipped to dev/stage/prod is a result of a build, not the result of a composer operation on production servers. – Kevin Oct 12 '18 at 20:42
  • Good point Kevin. I'm not sure of all the where's and why's. I was taking my queue from this node: drupal.org/docs/8/update/update-core-via-drush which indicates "It's recommended to use Composer to manage Drupal dependencies; read Using Composer with Drupal for more information. Drush 9 no longer supports updating Drupal and leaves the work to composer. Hence it is recommended to use Composer to update Drupal. However, if you are a long-time Drush user, you may still use Drush 8 (8.14 or newer) to update Drupal 8." This should provide some guidance to the OP. – J W Oct 12 '18 at 22:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.