Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Errno 13] Permission denied: #1108

Closed
ren-02 opened this issue May 17, 2020 · 35 comments
Closed

[Errno 13] Permission denied: #1108

ren-02 opened this issue May 17, 2020 · 35 comments

Comments

@ren-02
Copy link

ren-02 commented May 17, 2020

  • Python: 3.7
  • OS: Windows 10
  • Buildozer: buildozer 1.0

Description

// REPLACE ME: What are you trying to get done, what has happened, what went wrong, and what did you expect?

buildozer.spec

buildozer android debug
`

Spec file:

// REPLACE ME: Paste your buildozer.spec file here

Logs

Traceback (most recent call last):
File "/home/ren/.local/bin/buildozer", line 8, in
sys.exit(main())
File "/home/ren/.local/lib/python3.6/site-packages/buildozer/scripts/client.py", line 13, in main
Buildozer().run_command(sys.argv[1:])
File "/home/ren/.local/lib/python3.6/site-packages/buildozer/init.py", line 1071, in run_command
self.target.run_commands(args)
File "/home/ren/.local/lib/python3.6/site-packages/buildozer/target.py", line 92, in run_commands
func(args)
File "/home/ren/.local/lib/python3.6/site-packages/buildozer/target.py", line 104, in cmd_debug
self.buildozer.build()
File "/home/ren/.local/lib/python3.6/site-packages/buildozer/init.py", line 211, in build
self.build_application()
File "/home/ren/.local/lib/python3.6/site-packages/buildozer/init.py", line 739, in build_application
self._copy_application_libs()
File "/home/ren/.local/lib/python3.6/site-packages/buildozer/init.py", line 839, in _copy_application_libs
copytree(self.applibs_dir, join(self.app_dir, '_applibs'))
File "/usr/lib/python3.6/shutil.py", line 365, in copytree
raise Error(errors)
shutil.Error: [('/mnt/f/helo/.buildozer/applibs', '/mnt/f/helo/.buildozer/android/app/_applibs', "[Errno 13] Permission denied: '/mnt/f/helo/.buildozer/android/app/_applibs'")]

@quitegreensky
Copy link

I have this problem too . Don't know thy this happens

@AndreMiras
Copy link
Member

We don't have enough logs to tell. We need full log and buildozer.spec file. Also code needs to be formatted (use grace accent/backquote) to be read properly

@suvidh
Copy link

suvidh commented Aug 3, 2020

image
I am facing the same issue.
The issue persists regardless of what I add to buildozer.spec

WIndows 10:
Using it on WSL ubuntu

@stefan-sherwood
Copy link
Contributor

stefan-sherwood commented Sep 1, 2020

This happens because you are attempting to set permissions on files on mounted Windows drives from WSL, which is prohibited due to incompatibilities between Windows file permissions and Linux file permissions.

The function that is failing, copytree(), attempts to apply permissions to copied files, hence the Permission Denied error.

You can remedy this by building from a directory that is relative to the WSL root, e.g. ~/myProject

@al-chris
Copy link

This happens because you are attempting to set permissions on files on mounted Windows drives from WSL, which is prohibited due to incompatibilities between Windows file permissions and Linux file permissions.

The function that is failing, copytree(), attempts to apply permissions to copied files, hence the Permission Denied error.

You can remedy this by building from a directory that is relative to the WSL root, e.g. ~/myProject

please, how?

@stefan-sherwood
Copy link
Contributor

I explained how. Please use more words to describe what you don't understand about the solution I suggested.

@al-chris
Copy link

16001305558037296554512254151079
This I what I'm currently facing

@al-chris
Copy link

I explained how. Please use more words to describe what you don't understand about the solution I suggested.

I am building from ~/camera and getting:
PermissionError: [Errno 13] Permission denied: '/home/alchris/camera/main.py'

@stefan-sherwood
Copy link
Contributor

Thanks for the clarification. What do you see if you type ls -l /home/alchris/camera/main.py?

@stefan-sherwood
Copy link
Contributor

stefan-sherwood commented Sep 15, 2020

Also, strange that it's getting the error when opening the file, not when actually copying it. You can add this log statement in /usr/lib/python3.8/shuil.py just before line 261 print( f"{src=}, {dst=}" ) to get more clarity.

@SomyKamble
Copy link

Permission denied by Kivy at the very last stage of the build compile

: shutil.Error: [('/mnt/d/kivy_projects/basics/.buildozer/applibs', '/mnt/d/kivy_projects/basics/.buildozer/android/app/_applibs', "[Errno 13] Permission denied: '/mnt/d/kivy_projects/basics/.buildozer/android/app/_applibs'")]

image

Can anyone please help

@stefan-sherwood
Copy link
Contributor

@SomyKamble I described the cause and a workaround for the problem in my first comment.

@hladkky
Copy link

hladkky commented Jan 16, 2021

@stefan-sherwood Hello. I am facing the same issue.
As you recommended, I create ~/app directory and I have tried to build from there, but have got this error.
image

But I have got this file in my project root folder. What should I do?
Should I create the same file on the WSL, or someway give a route to the application root?

@stefan-sherwood
Copy link
Contributor

As shown in your screenshot, it's trying to set permissions on a file whose root is /mnt/d. That is a Windows directory. You cannot build projects located in a Windows directory. Move it to WSL and try again.

@hladkky
Copy link

hladkky commented Jan 16, 2021

In what way can I totally copy application root folder to WSL? And the same question for returning apk, that will have been built there.

@hladkky
Copy link

hladkky commented Jan 16, 2021

@stefan-sherwood I have started building, but at the very end got this error:

image
image

Where can I check logs?

@stefan-sherwood
Copy link
Contributor

Unfortunately the error is not shown. Try executing the exact command that comes after "Command failed: " and paste here what it says in response.

@hladkky
Copy link

hladkky commented Jan 16, 2021

This is a response of command. But this module has to be installed...

image

@hladkky
Copy link

hladkky commented Jan 16, 2021

After installing this package, I have got the same error, and after trying to debug got this:

image

@stefan-sherwood
Copy link
Contributor

The second one is a different error and it says exactly what the problem is 😮

@hladkky
Copy link

hladkky commented Jan 16, 2021

Well, what the solution could be?
I have followed buildozer installation steps for Ubuntu 20.04, given here: https://buildozer.readthedocs.io/en/latest/installation.html
After that:
buildozer init -> rewrite buildozer.sped -> buildozer android debug deploy run

@stefan-sherwood
Copy link
Contributor

If you Google the error message then the answer comes up as the first result. I am not going to debug your whole application, especially if you don't demonstrate diligence in figuring it out yourself.

@myNameIsHamza
Copy link

Permission problem probably from using root(sudo -s) while typing commands!

@bycellatt
Copy link

Do sudo su. Install the buildozer later

@skorpions2000
Copy link

Nothing changed and I have this mistake ... What happened? With sudo -s is working... What caused this error? Ten minutes earlier everything worked without root (sudo -s)

@Uni-Creator
Copy link

@hladkky
Fixed by installing libtool.

sudo apt-get install -y libtool

@Marcinosoft
Copy link

Marcinosoft commented Oct 9, 2021

Based on first post where Python complains that it cannot access directory:

shutil.Error: [('/mnt/f/helo/.buildozer/applibs', '/mnt/f/helo/.buildozer/android/app/_applibs', "[Errno 13] Permission denied: '/mnt/f/helo/.buildozer/android/app/_applibs'")]

So your project is inside F:\helo\ at Windows side.

Just grant full control access to folder F:\helo\ at Windows to your current Windows user.

obraz

If your "WindowsUsername" is not listed in your directory properties, click Edit button and add it first.

@stefan-sherwood
Copy link
Contributor

Just grant full control access to folder F:\helo\ at Windows to your current Windows user.

This is incorrect. As I explained above here you cannot grant a WSL full permissions to a non-WSL folder.

@Marcinosoft
Copy link

Marcinosoft commented Oct 9, 2021

Just grant full control access to folder F:\helo\ at Windows to your current Windows user.

This is incorrect. As I explained above here you cannot grant a WSL full permissions to a non-WSL folder.

You're wrong. Wanna proof of my Windows setup? I faced exactly same issue yesterday.

PS. I just reproduced it twice. Windows user require full access control to be able to pass shuil.py copy under Linux (in my case Ubuntu 20.04 LTS) by buildoizer. It may be significant, that I'm using WSL version 1 (not version 2). Why I'm using WSL v1 ? Because v2 require additional virtualization Windows features which are not compatible with Nox Android Emulator for example. How to switch between WSL 1 and 2 ?

wsl --set-default-version 1
wsl --set-default-version 2

@stefan-sherwood
Copy link
Contributor

this buildozer line will fail if the libraries are being copied from Windows to WSL. This is identical behavior in WSL 1 and 2.

What are the file paths being used in the copytree() call for you?

@Marcinosoft
Copy link

Ok, short story long.

In my case I placed project within:
C:\Kivy\Project\
I could create Kivy folder on root C: drive because I am member of Administrator group, which gives me indirectly Full control permission. But regular users by default have got: Read, Read & Execute, List folder content and Write. My user is an owner of C:\Kivy\ and everything inside of it to be clear. Permissions for nested objects are inherited from parents.

Then we have Ubuntu Linux (WSL) process, running under my Windows user. My user as I wrote before is part of Administrators group, but in Windows my user does not act as admin by default. It acts like regular user first, then if something require admin rights, then it's able to request additional rights, which usually require human confirmation (behaviour can be changed at UAC account setting).

Ubuntu Linux is able to operate on Windows folders because they are mounted as /mnt/?/, where ? is Windows drive letter, like c in my case. Ok, so under Linux I can operate on /mnt/c/Kivy/Project/ same as C:\Kivy\Project\ under Windows. When I create a file within /mnt/c/Kivy/Project/ folder, it will produce the same result like file created under Windows.

But when Linux world want to do something, which Windows user running wsl process cannot do directly, It can't invoke Windows behaviour which asks human to agree to do such operation as administrator. Linux always operate on Windows mounted file system based on regular, direct user rights.

That's why Buildozer launched under Linux is able to download and store over 1.3GB content within '/mnt/c/Kivy/Project/.buildozer/' without permission errors. At this phase regular users rights are enought. But copytree() require something more at Linux, and also Windows side. That's why it ends with [Errno 13] Permission denied: '/mnt/c/Kivy/Project/.buildozer/android/app/_applibs'.

copytree() under Linux invokes file permission operations (duplicating) at Windows side, which is allowed with Full control only.
When I granted it to C:\Kivy\ folder for my user, then no more admin right was required. Windows do not need to ask human to agree rights escalation. It directly have permissions to manage file rights under Windows, that's why copytree() under Linux succeed.

It's similar to this: https://stackoverflow.com/questions/11835833/why-would-shutil-copy-raise-a-permission-exception-when-cp-doesnt

@ghost
Copy link

ghost commented Dec 6, 2021

If someone would ever wonder, you can open root WSL directory on your windows by typing "cd ~" in ubuntu and next typing "explorer.exe . "

@MariwanJ
Copy link

MariwanJ commented Aug 9, 2022

@Marcinosoft
Thank you very much . You saved my time and you knew the solution. But, if this not working for you please try to know if you are missing other libraries.
I have Windows 10, and Ubuntu VM - you shouldn't use root to run buildozer

@zikkuratti
Copy link

zikkuratti commented Apr 25, 2023

solve it...
chmod 777 -R /home/YOURWSLNAME/.buildozer/

@Mishabich42
Copy link

sudo chmod +x /root/.buildozer/android/platform/android-sdk/tools/bin/sdkmanager
sudo chmod -R 755 /root/.buildozer/android/platform/android-sdk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests