How to Fix PermissionError [Errno 13] in Frappe & ERPNext| Sabbirz | Blog

How to Fix PermissionError [Errno 13] in Frappe & ERPNext

Ubuntu or Frappe Permission Denied Errno 13

Frappe Permission Denied Error [Errno 13]

😫 The "Permission Denied" Nightmare

Picture this: You’re in the zone, coding away on your Frappe or ERPNext app. You make a quick change to a Workspace, a Dashboard, or maybe just a simple Report. You hit save, feeling good, and BAM! πŸ’₯

The terminal screams at you:

PermissionError: [Errno 13] Permission denied: 'apps/evento/evento/evento/workspace/evento/evento.json'

Or maybe it’s blocking your JavaScript:

PermissionError: [Errno 13] Permission denied: 'apps/my_app/my_app/public/js/my_script.js'

Panic sets in. "I just want to save my work!" you cry. 😭

If this feels familiar, don't worry. You are not alone, and more importantly, you haven't broken anything permanently. This is one of the most common rites of passage for new Frappe developers.

Let's fix this, understand why it happened, and make sure it never haunts you again. πŸ‘»


πŸ•΅οΈβ€β™‚οΈ Why is Linux Hating Me?

Here is the secret: Linux is just trying to protect you.

When you install Frappe Bench, you usually do it as a specific user (let's say your username is sab or frappe). This user owns all the files in your bench directory.

The problem starts when you get a little too enthusiastic with the sudo command. πŸ›‘οΈ

The Crime Scene 🚨

At some point in the past, you probably ran a command like this:

sudo bench start
# OR
sudo bench update

When you run bench with sudo, you are telling the system: "Hey, run this as the Root (Superuser)!" πŸ¦Έβ€β™‚οΈ

So, when Bench created or modified files during that command, it stamped them with Property of Root.

Now, when you go back to being a normal user (sab) and try to edit those files... Linux steps in:

"Stop! βœ‹ This file belongs to Root. You are just sab. You have no power here!"

And that is exactly what [Errno 13] Permission denied means.


πŸ” CSI: Frappe Bench

Don't take my word for it. Let's catch the culprit red-handed. πŸ“Έ

Look at the file path in your error message. For example: apps/evento/evento/evento/workspace/evento/evento.json

Run this command in your terminal to check the file's ID card:

ls -l apps/evento/evento/evento/workspace/evento/evento.json

You will likely see something like this:

-rw-r--r-- 1 root root 3302 Nov 16 09:40 evento.json
             ^^^^ ^^^^
             Owner Group

See that root root? That’s the smoking gun. πŸ”« It should say sab sab (or whatever your username is).

πŸ•΅οΈβ€β™€οΈ Are there others?

If one file is infected, others might be too. You can scan your entire app for files owned by root:

# Replace 'apps/your_app_name' with your actual app path
find apps/your_app_name -user root

If that list is long, we have some cleaning up to do. 🧹


πŸ› οΈ The Fix: Reclaiming Your Files

Good news! The fix is super easy. We just need to tell Linux: "Hey, these files actually belong to me."

We use the chown (Change Owner) command.

Step 1: Go to your Bench

cd ~/frappe-bench

Step 2: The Magic Command ✨

Run this command to give ownership back to your current user.

Note: $USER is a handy variable that automatically fills in your current username.

sudo chown -R $USER:$USER apps/your_app_name

Want to nuke the problem for ALL apps? (Recommended) πŸš€

sudo chown -R $USER:$USER apps

Step 3: Restart and Rejoice πŸŽ‰

Now, restart your bench to make sure everything loads fresh.

For Development:

bench start

For Production:

bench restart

Try saving your Workspace or Report again. It should work like a charm! ✨


πŸ›‘οΈ Pro-Tip: Never See This Again

The best way to fix a problem is to prevent it.

🚫 The Golden Rule

NEVER, EVER run bench commands with sudo.

❌ Bad:

sudo bench start
sudo bench build
sudo bench migrate

βœ… Good:

bench start
bench build
bench migrate

"But what about system stuff?" πŸ€”

Great question! You do need sudo for system-level services, but not for bench commands.

Use sudo for:

  • sudo apt install ... (Installing packages)
  • sudo service nginx reload (Web server)
  • sudo systemctl restart supervisor (Process manager)

Keep bench sudo-free!


πŸ“š Resources

Related posts