作曲家更新内存限制 [英] Composer update memory limit

查看:63
本文介绍了作曲家更新内存限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在主机上运行composer更新,所以我使用ssh登录并尝试运行comand:

I need to run composer update at my hosting so I log in with ssh and try to run comand:

composer update

在/www文件夹中,里面有laravel和composer安装文件

inside /www folder where I have laravel and composer instalation

但是我得到了错误:

but I get error:

与我的托管服务提供商联系时,他们告诉我运行命令:

in contact with my hosting provider they tell me to run command:

php -d memory_limit=512M composer update

我运行此命令,但得到:无法打开文件:作曲家"

I run this command but I get: "Could not open file: composer"

该怎么办?这里的解决方案是什么?

What to do? What is the soluton here?

推荐答案

运行composer update时,操作系统将调查配置的路径并尝试查找具有该名称的可执行文件.

When you run composer update, the OS will look into the configured paths and try to locate an executable file with that name.

运行php composer update时,composer字符串被视为PHP的参数,该字符串不会在任何路径中搜索.您必须提供完整路径才能运行它.

When running php composer update, the composer string is treated as a parameter to PHP, which is not searched in any paths. You have to provide the full path in order to run it.

运行which composer会告诉您操作系统在哪里找到composer可执行文件,然后您只需在PHP命令中使用完整路径即可.

Running which composer will tell you where the OS finds the composer executable, and then you simply use the full path in the PHP command:

$>which composer
/usr/local/bin/composer

$>php -d memory_limit=512M /usr/local/bin/composer update
...

请注意,512MB可能太少了.我的看法是,根据使用的依赖项数量和理论上允许的版本的多样性,它会很高兴地占用1GB或更多的空间,即,如果允许使用Symfony ~2.3,则使Composer处理更多可能的版本与使用~2.7相比.

Note that 512MB might be too few. My perception is that it will happily take 1GB or more, depending on the number of dependencies you use and the variety of versions that you theoretically allow, i.e. if you allow Symfony ~2.3, then you make Composer deal with a lot more possible versions compared to using ~2.7.

还请注意,在生产计算机上运行Composer并非最佳方法.您将必须具有访问Github的权限,可能需要提供访问凭据,必须安装VCS工具,并且如果在更新过程中有任何远程托管服务器处于脱机状态,则很容易破坏站点.最好在完成所有准备工作的部署系统上使用Composer,然后将所有文件移动到生产服务器上.

Also note that running Composer on the production machine is not the best idea. You would have to have access to Github, maybe provide access credentials, have VCS tools installed, and you will easily break your site if any of the remote hosting servers is offline during your update. It is a better idea to use Composer on a deployment system that does all the preparation, and then moves all the files onto the production server.

更新

现在是2020年,Composer管理内存的方式已经发生了很大变化.最重要的是,如果Composer遇到的限制设置过低,它将自行增加内存限制.但是,这立即触发了内存不足的计算机上内存不足的问题.您可以通过设置COMPOSER_MEMORY_LIMIT=512M之类的环境变量来使Composer使用更少的内存,但是如果Composer需要更多的内存来正确操作,这会造成问题.

It's the year 2020 now, and the way Composer manages it's memory has changed quite a bit. The most important thing is that Composer will increase the memory limit by itself if it encounters a limit set too low. This however immediately triggers the problem of running out of memory on machines that have too few memory installed. You can make Composer use less memory by setting the environment variable like COMPOSER_MEMORY_LIMIT=512M, but this will create problems if Composer would need more memory to correctly operate.

我的主要观点仍然是正确的:不要在安装了太多内存的计算机上运行Composer.您可能需要1.5 GB的可用内存才能更新所有内容.

My main point remains true: Do not run Composer on machines that have too few memory installed. You potentially need 1.5 GB of free memory to be able to update everything.

这篇关于作曲家更新内存限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆