By carlbowles100 on
When I run commands as superuser I get the warning not to run from the superuser account but I can successfully run them.
When I try to run the same commands via a non superuser account I get the following error:
phpenv: composer: command not found
I believe this is something to do with the fact the account is not superuser or does not have correct permissions.
How can I fix this please so that I can run from the other account rather than superuser.
I'm on Ubuntu 20.04.6 LTS and using PuTTY for SSH.
Comments
Fix: phpenv: composer: command not found (Ubuntu 20.04)
This happens because Composer/phpenv aren’t in your non-root user’s
PATH.1. Install Composer system-wide
2. Add phpenv to PATH
3. Test
You can now run Composer and phpenv without
sudo.Why it happens: Root has a different
PATH. phpenv installs shims in your home dir, but they aren’t available to your user by default. Composer also warns against running as root for security reasons.Option A: Configure phpenv
Add this to
~/.bashrcor~/.profile:Reload and run
phpenv rehash.Option B: User-only Composer install (no sudo)
Troubleshooting
Once PATH is set correctly, you’ll be able to use Composer and phpenv as a regular user on Ubuntu 20.04 (PuTTY is just the SSH client, not the cause).
The issue is that composer is
The issue is that
composeris installed only for the superuser and its path isn’t in your non-root user’s$PATH. To fix:Make sure Composer is installed globally for all users:
sudo apt update sudo apt install composeror use the official installer for your user.
Ensure your non-root user’s PATH includes Composer:
export PATH="$HOME/.config/composer/vendor/bin:$PATH"Add that line to
~/.bashrcor~/.profileto make it permanent.After this,
composershould work without sudo.