为什么COMPOSER_HOME为空? [英] Why is COMPOSER_HOME empty?

查看:235
本文介绍了为什么COMPOSER_HOME为空?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对编程工具 composer 有疑问,该工具作为可执行文件安装在3的/usr/local/bin/composer中我在工作和家庭之间使用的不同机器.根据:

I have a question about the programming tool composer which is installed as an executable in /usr/local/bin/composer on 3 different machines that I use between work and home. According to:

composer help global

COMPOSER_HOME is c:\Users<user>\AppData\Roaming\Composer on Windows
and /home/<user>/.composer on unix systems.

Note: This path may vary depending on customizations to bin-dir in
composer.json or the environmental variable COMPOSER_BIN_DIR.

但是这两个都是空的:

echo $COMPOSER_HOME
echo $COMPOSER_BIN_DIR

当我跑步时:

composer global require <package>

它在我的Ubuntu 16.04桌面上安装到/home/<user>/.config/composer/vendor/bin ,但在其他任何地方,它也都适当安装到/home/<user>/.composer/vendor/bin

It installs to /home/<user>/.config/composer/vendor/bin only on my Ubuntu 16.04 desktop, but everywhere else it installs appropriately to /home/<user>/.composer/vendor/bin

为什么要安装到~/.config而不是~/.composer而不设置COMPOSER_HOME变量?

Why is it installing to ~/.config instead of ~/.composer and not setting the COMPOSER_HOME variable?

之所以注意到这一点,是因为我获取了包括全局作曲家bin路径在内的通用dotfiles.我知道我可以通过在bashrc中手动设置COMPOSER_HOME来解决此问题,但我宁愿理解为什么会首先发生这种情况.

I notice this because I source my common dotfiles which includes the global composer bin path. I know I can workaround this by manually setting COMPOSER_HOME in my bashrc, but I would rather understand why this is happening in the first place.

推荐答案

源代码揭示了计算Composer主目录的方式的其他一些复杂性.

The source code reveals some additional complexity to how Composer's home directory is computed.

如果您的系统使用的是freedesktop.org标准,则系统会通过查找XDG_ 开头的环境变量,然后Composer使用$XDG_CONFIG_HOME/composer/,如果未设置,则回落到$HOME/.config/composer/.

If your system uses freedesktop.org standards, which it detects by looking for environment variables beginning with XDG_, then Composer uses $XDG_CONFIG_HOME/composer/, falling back to $HOME/.config/composer/ if that isn't set.

您可能希望看到有一个

You might be interested to see that there is a special case: if $HOME/.composer/ exists and is a directory it will be used in favour of the freedesktop.org logic. Presumably this is for backwards compatibility. If you create this directory manually, Composer should use it.

我不确定为什么这只会影响您的Ubuntu 16.04计算机.我的旧笔记本电脑运行的是Ubuntu 14.04的变体,使用XDG_环境变量.

I'm not sure why this is just affecting your Ubuntu 16.04 machine. My old laptop running a variant of Ubuntu 14.04 uses XDG_ environment variables.

我怀疑您是在freedesktop.org逻辑是在2015年7月添加的,您的其他计算机在此之前都先安装了Composer.然后,它们现有的~/.composer/目录将确保Composer继续使用该位置.

I suspect that you installed Composer for the first time on that machine after the freedesktop.org logic was added in July of 2015 and that your other machines all had Composer first installed before then. Then their existing ~/.composer/ directories would ensure that Composer kept using that location.

这篇关于为什么COMPOSER_HOME为空?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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