3

I've installed composer and the laravel installer which is now located unter ~/.config/composer/vendor/bin. I want to use laravel directly as a command from anywhere, so I tried to add the directory to the $PATH variable. I probably could create a symlink for the installer to /usr/local/bin but I still don't know why I can't set it permanently. I tried multiple ways

  • export PATH=$PATH:~/.config/composer/vendor/bin
  • Adding it to ~/.profile like above and without the export statement and the value in quotes
  • Adding it to ~/.bashrc like above and without the export statement and the value in quotes
  • Adding it to /etc/environment like PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:~/.config/composer/vendor/bin"

After doing all of that (for 2 & 3 I even did source) it worked for the current session, but as soon as I closed the Terminal and reopened it the output would always be:

tzfrs@ubuntu:~$ laravel
laravel: command not found

I don't have any bash_login or bash_profile file in my home directory.

karel
  • 122,292
  • 133
  • 301
  • 332
Musterknabe
  • 262
  • 3
  • 13

2 Answers2

5
  • export PATH=$PATH:~/.config/composer/vendor/bin works for the current session only.

  • In ~/.profile and ~/.bashrc the ~/ doesn't get works within quotes, Either omit the quotes or use $HOME instead of ~/, e.g.

    export PATH=$PATH:$HOME/.config/composer/vendor/bin
    
  • /etc/environment doesn't allow any shell syntax so neither ~/ nor $HOME works. Instead you need to use the full path, e.g.

    PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/youruser/.config/composer/vendor/bin"
    
2

You need to have the full directory in the /etc/environment for the PATH statement.

/home/username/.config/composer/vendor/bin

After the changes made, you need to reboot the host so that the changes in /etc/environment can take effect.

Hope this helps!

Terrance
  • 43,712