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.

6
  • I believe your path statement would need to be the full folder name: /home/username/.config/composer/vendor/bin
    – Terrance
    Jun 28, 2016 at 20:17
  • Added it like this to ~/.profile and /etc/environment but no luck Jun 28, 2016 at 20:26
  • When you change /etc/environment I believe you need to reboot for the global changes to take effect.
    – Terrance
    Jun 28, 2016 at 20:29
  • I'll report back Jun 28, 2016 at 20:32
  • @Terrance - I'm using a VM, so will take 2-3 minutes. Jun 28, 2016 at 20:34

2 Answers 2

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"
    
3
  • Hi. I modified my /etc/environment but still no luck. It looks like this: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/tzfrs/.config/composer/vendor/bin" Jun 28, 2016 at 20:26
  • @Musterknabe: /etc/environment is only read by pam_environment at login time. So you need to log out and log in again to make it work. Jun 28, 2016 at 20:45
  • Hey. Yeah, that was it. But Terrance provided that info first so I accepted his answer. But I upvoted yours. Thanks for the tip with the /etc/environment/. Jun 28, 2016 at 20:47
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!

1
  • I'm accepting this answer, since he provided the information with the reboot first. Jun 28, 2016 at 20:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.