Software⏱️ 2 min read📅 2026-05-31
How to Fix: Composer: file_put_contents(./composer.json): failed to open stream: Permission denied
Composer permission denied error on Ubuntu 16.04 server.
Quick Answer: Run the command with sudo privileges: $ sudo composer global require hirak/prestissimo:^0.3
📋 Table of Contents
The 'file_put_contents(./composer.json): failed to open stream: Permission denied' error occurs when the Composer installation directory does not have the necessary permissions to write files.
💡 Why You Are Getting This Error
- [Cause]
🔧 Proven Troubleshooting Steps
Method 1: Changing Permissions
- Step 1: Open the terminal and run the command `sudo chown -R $USER:$USER /home/kramer65/.composer` to change the ownership of the directory to your current user.
Method 2: Running Composer with Elevated Privileges
- Step 1: Run the command `sudo -u $USER composer global require
❓ Frequently Asked Questions
Step 1: Open the terminal and run the command `sudo chown -R $USER:$USER /home/kramer65/.composer` to change the ownership of the directory to your current user.
🛠️ Related Fixes
How to Fix: Pc crashes shortly after launching game (rainbow
Pc crashes shortly after launching game, possible cause: outdated grap
How to Fix: Installing an APK on a locked down phone
Installing an APK on a locked down phone: Try using a rooted device, e
How to Fix: FPS drops
FPS drops in games can be caused by high system resource usage, outdat