composer https://shivanjaikaran.com/ en Composer Memory Problem on Shared Web Hosting https://shivanjaikaran.com/composer-memory-problem-shared-web-hosting <span>Composer Memory Problem on Shared Web Hosting</span> <span><span>admin</span></span> <span>Mon, 08/03/2020 - 04:27</span> <ul class="links inline"><li class="comment-add"><a href="/composer-memory-problem-shared-web-hosting#comment-form" title="Share your thoughts and opinions." hreflang="en">Add new comment</a></li></ul> <div><p>If you are using shared web hosting for your composer managed Drupal website, you have probably ran into the problem of your server running out of memory for simple commands such as "composer install". Shared web hosting usually have memory limits which are shared across many websites.</p> <p>This problem becomes quickly apparent if you are trying to install a new Drupal website into your shared hosting account. Because this is probably the first time that you have to run "composer install" for this website. Composer will then have to go and fetch all the files and download them into your vendor directory. The high memory consumption in composer is mostly due to dependency resolution. This process is memory intensive. The end result is your process is abruptly killed without finishing.</p> <p><strong>Solution</strong></p> <p>A quick and easy solution is to install the site locally whereby you can successfully run "composer install". You would then have the vendor directory locally. Then use a service like FTP to manually upload the vendor folder into the correct directory on your hosting server. Then on your hosting server, try running "composer install" again. </p> <p>At this point, composer would not need to fetch all the files again. Composer may or may not have to update some files in the vendor directory. This is OK. But the process should now be able to complete within your memory limitations.</p> <p>It should be noted that the <a href="https://getcomposer.org/doc/faqs/should-i-commit-the-dependencies-in-my-vendor-directory.md" rel="nofollow">vendor directory should <strong>not</strong> be committed to your git directory</a> for a few important reasons. </p> <p>There are arguments for and against committing the vendor directory. It is not technically wrong but there some risks associated with it. The recommendation about not committing /vendor to the git repo is mostly related to avoiding headaches with git submodules (duplicated history, etc). The <a href="https://getcomposer.org/doc/faqs/should-i-commit-the-dependencies-in-my-vendor-directory.md" rel="nofollow">composer docs page</a> shows some ways that you can prevent hitting those.</p> </div> <div> <div>Tags</div> <div> <div><a href="/tag/drupal" hreflang="en">Drupal</a></div> <div><a href="/tag/drupal-planet" hreflang="en">Drupal Planet</a></div> <div><a href="/tag/composer" hreflang="en">composer</a></div> </div> </div> <section class="comments" > <article data-comment-user-id="0" id="comment-1629" class="js-comment comment"> <mark class="hidden" data-comment-timestamp="1596729223"></mark> <div class="comment-side"> <img src="/themes/custom/likable_subtheme/images/avatar.png" /> <div class="comment-submitted"> <p class="comment-name"> <span>Just-passin-thru (not verified)</span> </p> <p class="comment-time"> Thu, 08/06/2020 - 09:35 </p> <p class="comment-permalink"> <a href="/comment/1629#comment-1629" hreflang="en">Permalink</a> </p> </div> </div> <div class="comment-text"> <div class="comment-arrow"></div> <h3><a href="/comment/1629#comment-1629" class="permalink" rel="bookmark" hreflang="en">I&#039;ve used the following to…</a></h3> <div class="content"> <div><p>I've used the following to overcome this issue and it works fine:</p> <p> </p> <p>COMPOSER_MEMORY_LIMIT=-1 composer require ...</p> </div> <div class="sharethis-wrapper"> <span st_url="https://shivanjaikaran.com/taxonomy/term/84/feed#comment-1629" class="st_facebook"></span> <span st_url="https://shivanjaikaran.com/taxonomy/term/84/feed#comment-1629" class="st_email"></span> <span st_url="https://shivanjaikaran.com/taxonomy/term/84/feed#comment-1629" st_title="" class="st_twitter"></span> <span st_url="https://shivanjaikaran.com/taxonomy/term/84/feed#comment-1629" st_title="" class="st_sharethis"></span> <span st_url="https://shivanjaikaran.com/taxonomy/term/84/feed#comment-1629" st_title="" class="st_print"></span> <span st_url="https://shivanjaikaran.com/taxonomy/term/84/feed#comment-1629" st_title="" class="st_fblike"></span> </div> <drupal-render-placeholder callback="comment.lazy_builders:renderLinks" arguments="0=1629&amp;1=default&amp;2=en&amp;3=" token="W3tx8Vn9APB2vsZgPQhrFnwuibsRGEdmK2sSkurfj78"></drupal-render-placeholder> </div> </div> </article> <article data-comment-user-id="0" id="comment-1630" class="js-comment comment"> <mark class="hidden" data-comment-timestamp="1600841429"></mark> <div class="comment-side"> <img src="/themes/custom/likable_subtheme/images/avatar.png" /> <div class="comment-submitted"> <p class="comment-name"> <span>Khan Mohammad Nakib (not verified)</span> </p> <p class="comment-time"> Wed, 09/23/2020 - 01:31 </p> <p class="comment-permalink"> <a href="/comment/1630#comment-1630" hreflang="en">Permalink</a> </p> </div> </div> <div class="comment-text"> <div class="comment-arrow"></div> <h3><a href="/comment/1630#comment-1630" class="permalink" rel="bookmark" hreflang="en">Thanks for this. Exactly I…</a></h3> <div class="content"> <div><p>Thanks for this. Exactly I was looking for this.</p> </div> <div class="sharethis-wrapper"> <span st_url="https://shivanjaikaran.com/taxonomy/term/84/feed#comment-1630" class="st_facebook"></span> <span st_url="https://shivanjaikaran.com/taxonomy/term/84/feed#comment-1630" class="st_email"></span> <span st_url="https://shivanjaikaran.com/taxonomy/term/84/feed#comment-1630" st_title="" class="st_twitter"></span> <span st_url="https://shivanjaikaran.com/taxonomy/term/84/feed#comment-1630" st_title="" class="st_sharethis"></span> <span st_url="https://shivanjaikaran.com/taxonomy/term/84/feed#comment-1630" st_title="" class="st_print"></span> <span st_url="https://shivanjaikaran.com/taxonomy/term/84/feed#comment-1630" st_title="" class="st_fblike"></span> </div> <drupal-render-placeholder callback="comment.lazy_builders:renderLinks" arguments="0=1630&amp;1=default&amp;2=en&amp;3=" token="Mk69D0wRo-7LMmWcv0DnqHBaG_mUFdll5GHmeneke14"></drupal-render-placeholder> </div> </div> </article> <h2>Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=62&amp;2=comment_node_page&amp;3=comment_node_page" token="Ppp35F7iUh6pzztRZKLLLcivgmRKGol44_dnlUdGKPk"></drupal-render-placeholder> </section> <div id="field-language-display"><div class="js-form-item form-item js-form-type-item form-item- js-form-item-"> <label>Language</label> English </div> </div> Mon, 03 Aug 2020 08:27:53 +0000 admin 62 at https://shivanjaikaran.com