How to change composer global vendor directory in ubuntu

288 Views Asked by At

Something is wrong with my composer local installation.

I'm under ubuntu 22, my global vendor directory path is pointing to a project directory and not to a SO global directory, such as /home/username/.composer/vendor.

Take a look to this output

composer config --global -l
Deprecation Notice: Using ${var} in strings is deprecated, use {$var} instead in phar:///home/gik/.local/bin/composer/src/Composer/Autoload/AutoloadGenerator.php:879
Deprecation Notice: Using ${var} in strings is deprecated, use {$var} instead in phar:///home/gik/.local/bin/composer/src/Composer/Autoload/AutoloadGenerator.php:884
[repositories.packagist.org.type] composer
[repositories.packagist.org.url] https://repo.packagist.org
[process-timeout] 300
[use-include-path] false
[use-parent-dir] prompt
[preferred-install] dist
[notify-on-install] true
[github-protocols] [https, ssh]
[gitlab-protocol] 
[vendor-dir] vendor (/home/username/workspaces/myproject/vendor)
[bin-dir] {$vendor-dir}/bin (/home/username/workspaces/myproject/vendor/bin)
[cache-dir] /home/username/.cache/composer
[data-dir] /home/username/.local/share/composer
[cache-files-dir] {$cache-dir}/files (/home/username/.cache/composer/files)
[cache-repo-dir] {$cache-dir}/repo (/home/username/.cache/composer/repo)
[cache-vcs-dir] {$cache-dir}/vcs (/home/username/.cache/composer/vcs)
[cache-ttl] 15552000
[cache-files-ttl] 15552000
[cache-files-maxsize] 300MiB (314572800)
[cache-read-only] false
[bin-compat] auto
[discard-changes] false
[autoloader-suffix] 
[sort-packages] false
[optimize-autoloader] false
[classmap-authoritative] false
[apcu-autoloader] false
[prepend-autoloader] true
[github-domains] [github.com]
[bitbucket-expose-hostname] true
[disable-tls] false
[secure-http] true
[cafile] 
[capath] 
[github-expose-hostname] true
[gitlab-domains] [gitlab.com]
[store-auths] prompt
[archive-format] tar
[archive-dir] .
[htaccess-protect] true
[use-github-api] true
[lock] true
[platform-check] php-onl
[home] /home/username/.config/composer

The question are: How can i change this directory path (vendor-dir and bin-dir) ? Why I am experiencing this problem? What I did wrong?

I tried to check if there is a "set" command that allows me to update this global config variables vendor-dir and bin-dir with no results.

1

There are 1 best solutions below

0
UnMoscerinoNelWeb On

I managed to do it using different searching keywords

As suggested here https://github.com/composer/composer/issues/4450

You can update whatever variable in your configuration (either global or local) using the following command:

composer config variable_name variable_value

hope this helps.