SDRausty / TermuxArch

You can use setupTermuxArch.bash 📲 to install Arch Linux in Amazon, Android, Chromebook and Windows. https://sdrausty.github.io/TermuxArch/docs/install
https://sdrausty.github.io/TermuxArch/
Other
1.41k stars 162 forks source link

Python's "pip install" fails with "permission denied" #30

Closed borisbrodski closed 6 years ago

borisbrodski commented 6 years ago

In a fresh installation of Termux+ArchLinux on unrooted Android device (Samsung Note 8) I am constantly getting error trying to install python packages:

$ pip install simplejson
...
    Copying simplejson.egg-info to /root/.local/lib/python3.6/site-packages/simplejson-3.13.2-py3.6.egg-info
error: [Errno 13] Permission denied: '/root/.local/lib/python3.6/site-packages/simplejson-3.13.2-py3.6.egg-info/PKG-INFO'

Permissions are ok, at least I can copy files to the destination directory. "pip install --user" or using virtual env pyvenv change nothing.

For full description please see https://stackoverflow.com/q/48125865/1860309

Is there a workaround for the problem?

Thank you!

SDRausty commented 6 years ago

Use su - archuser after useradd archuser and see if running pip install simplejson works as non root user. What you have encountered might be due to using root for a non root install.

borisbrodski commented 6 years ago

Thank you for the quick response. Unfortunately this produces exactly the same result both direct and using virtual env pyvenv...

Any other ideas, what I could try?

PS I suspect, that the problem is due to permission problems during reading from the tmp directory, where the stuff get built. Are you aware of any problems relating to tmp directory?

borisbrodski commented 6 years ago

No problems with python2...

SDRausty commented 6 years ago

Thank you for the update. Do you think this may be a 'simplejson' issue?

borisbrodski commented 6 years ago

This is not simplejson specific. It occurs with all other packages, that I have tried.

But I think, I got a bit closer to the solution. I traced the error to the call to the python shutil.copystat() method. Here you can try it yourself:

  1. Create copystat-test.py with the following content
#!/usr/bin/python

import sys
import shutil

print('Checking python copystat method')

if len(sys.argv) != 3:
    print('Usage: python copystat-test.py <src> <dest>')
    exit(1)

src = sys.argv[1]
dest = sys.argv[2]

print('Copystat %s to %s' % (src, dest))
shutil.copystat(src, dest)
  1. Test the copystat method
$ touch a b
$ python copystat-test.py a b

I get the result:

Checking python copystat method
Copystat a to b
Traceback (most recent call last):
  File "copystat-test.py", line 17, in <module>
    shutil.copystat(src, dest)
  File "/usr/lib/python3.6/shutil.py", line 225, in copystat
    _copyxattr(src, dst, follow_symlinks=follow)
  File "/usr/lib/python3.6/shutil.py", line 165, in _copyxattr
    os.setxattr(dst, name, value, follow_symlinks=follow_symlinks)
PermissionError: [Errno 13] Permission denied: 'b'

I think, this should have something to do with the file system or kernel, that runs under restricted Android Linux.

Do you see some workaround other, that removing somehow copystat from python pip install?

SDRausty commented 6 years ago

Permission denied #create-react-app https://github.com/termux/termux-packages/issues/1899 This might be another python3 issue too.

SDRausty commented 6 years ago

Issue closed because it does not concern setupTermuxArch itself.

SDRausty commented 6 years ago

Links to upstream in this thread are welcome.

tomty89 commented 6 years ago

@borisbrodski

$ alarm
[root@localhost ~]# git diff /usr/lib/python3.6/shutil.py{~,}
diff --git a/usr/lib/python3.6/shutil.py~ b/usr/lib/python3.6/shutil.py
index bd4760f..b7604ba 100644
--- a/usr/lib/python3.6/shutil.py~
+++ b/usr/lib/python3.6/shutil.py
@@ -159,6 +159,7 @@ if hasattr(os, 'listxattr'):
             if e.errno not in (errno.ENOTSUP, errno.ENODATA):
                 raise
             return
+        names.remove('security.selinux')
         for name in names:
             try:
                 value = os.getxattr(src, name, follow_symlinks=follow_symlinks)
[root@localhost ~]# pip install simplejson
Collecting simplejson
  Downloading simplejson-3.13.2.tar.gz (79kB)
    100% |################################| 81kB 61kB/s
Installing collected packages: simplejson
  Running setup.py install for simplejson ... done
Successfully installed simplejson-3.13.2
[root@localhost ~]#
$ alarm
[root@localhost ~]# ls
[root@localhost ~]# touch blah
[root@localhost ~]# python
Python 3.6.4 (default, Jan 24 2018, 23:01:57)
[GCC 7.2.1 20180116] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os; hasattr(os, 'listxattr')
True
>>> os.listxattr('blah')
['security.selinux']
>>>
[root@localhost ~]# python2
Python 2.7.14 (default, Jan 24 2018, 21:16:56)
[GCC 7.2.1 20180116] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os; hasattr(os, 'listxattr')
False
>>>
[root@localhost ~]# logout
$ python
Python 3.6.4 (default, Jan  7 2018, 03:52:16)
[GCC 4.2.1 Compatible Android Clang 5.0.300080 ] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os; hasattr(os, 'listxattr')
False
>>>
$ python2
Python 2.7.14 (default, Jan  7 2018, 04:00:23)
[GCC 4.2.1 Compatible Android Clang 5.0.300080 ] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os; hasattr(os, 'listxattr')
False
>>>
tomty89 commented 6 years ago

Fixed with https://github.com/termux/termux-packages/pull/2156

SDRausty commented 6 years ago

Commit https://github.com/sdrausty/TermuxArch/commit/f16c27d4336ff6e38e1338e7846adc8843b9c0fc adds Arch Linux IRC channel upstream contact information to the TermuxArch motd and logout.

See https://wiki.archlinux.org/index.php/IRC_channel for available Arch Linux IRC channels.

tomty89 commented 6 years ago

There will hardly be any support. proot isn't even in Arch's official repo, not to mention that we are using a fork of the official proot to use Arch on Android.

By the way, with your way of "promoting" your "project", you'll probably be banned from #archlinux within a day (or less).

I have no idea why you notify us about that update in this issue either. Wasn't relevant at all.

SDRausty commented 6 years ago

why you notify us about that update in this issue

Links to upstream in this thread are welcome.

Commented Jan 31 in this thread @tomty89.

your "project",

Our project; See https://sdrausty.github.io/TermuxArch/CONTRIBUTORS for participants list.

tomty89 commented 6 years ago

Links to upstream in this thread are welcome.

And? How is commit relevant to that? This is the upstream you need: https://github.com/termux/proot

There will be no help available from upstream Arch for us just like you won't really get any help there for using Arch on Windows (WSL).

Our project

Nope. I participated just because I like to correct mistakes and I don't want people fall into traps in your shell scripts. That doesn't make it my project.

I don't even think we need a project to use Arch on Termux. It's just a two step thing: extraction and starting. If we really need a project, it will be a project that lists some notes or tips for newbs (e.g. uninstalling the kernel package may be the first thing you want to do after starting) and provides assistance on issue related to proot/Android exactly like this one (while you closed it before the OP got any hint from anybody), not a bunch of wrappers that barely help (like why would anyone need a wrapper for useradd?).

The worse thing is you don't even know bash well enough, or know how to manage a git repo/project properly (that's one of the reasons I never made a PR here). You really have better things to spend time on than spamming over the Termux repo.

SDRausty commented 6 years ago

Constructive comments are appreciated. Biased destructive opinions are not welcome:

The worse thing is you don't even know bash well enough,

Learn English grammar bud. You do have a computer to help you. The worst is not worse; then maybe you can progress to constructive comments about computers, programming and BASH scripting. To show one of your misleading examples: Your comments in threads about using $* instead of $@ would only make TermuxArch worse, not better. Learn what you are preaching before you preach nonsense to me, and fellow users! Your comments to do it a certain way, then later not to, are not infuriating; these contributions that you make belittle you, and your persona here at GitHub.

I don't even think we need a project to use Arch on Termux

Was it better before when it did not work? Because that is what it was, and still is at Termux. Please fix it, and package requested is what it was before TermuxArch for the most part. The other part was how do you use it? Is this what you want Termux users to experience? I don't. Why do you think there is a TermuxArch in the first place. What have you contributed? Your project links are requested. Why do think TermuxArch was created? Because it didn't work on device in Termux. TermuxArch is happening, now, here at GitHub! It works on device as intended.

@tomty89 you know a little. You profes you are expert. You are not expert. You only seek self-gratification through putting contributers down using the knowledge that you posses about computers and programming to bring projects like this into chaos. Don't you want people to be free; Free from the oppression you seed through ridicule, misinformation and self proclaimed superiority?

SDRausty commented 6 years ago

Put another words; Have you created anything like TermuxArch? Reviewing your GitHub portfolio, I see not. Can you contribute something that we like, something constructive at your portfolio of projects for us to use, and admire at GitHub, that works as expected in Termux on device?

I interpretted your comments to improve TermuxArch as much as possible, sifting out your horrendous advice from a sprinkling of the beneficial ones. Not to mention your backtracking on advice given by you. Complete chaos infused into code, through developer's fingers; Do it this way. NO, No do it the other way around like before. In view of:

Our project

Nope.

Would you like to be removed from https://sdrausty.github.io/TermuxArch/CONTRIBUTORS so we have a little uniformity in our discussion? After all, if I applied every bit of advice you have given, Termux users would be complaining to me, and opening up issues about the fact that it does not work on device as intended, or at all.

waste v. To use, consume, spend, or expend thoughtlessly or carelessly.

You probably got what you intended, waste of developer's time on something other than fruitful development, and self gratitude through online ridicule. It did take a lot of time to write this. It did. Can you improve your stance @tomty89? Hopefully you will be able to understand what I wrote, and you shall.

SDRausty commented 6 years ago

The preceding two posts are reply to @tomty89 regarding contributing chaos into GitHub projects, including TermuxArch. Instead of analyzing good advice from bad suggestions and applying this into TermuxArch development, considerable time and thinking was used to publicly reply to this communication:

Links to upstream in this thread are welcome.

And? How is commit relevant to that? This is the upstream you need: https://github.com/termux/proot

There will be no help available from upstream Arch for us just like you won't really get any help there for using Arch on Windows (WSL).

Our project

Nope. I participated just because I like to correct mistakes and I don't want people fall into traps in your shell scripts. That doesn't make it my project.

I don't even think we need a project to use Arch on Termux. It's just a two step thing: extraction and starting. If we really need a project, it will be a project that lists some notes or tips for newbs (e.g. uninstalling the kernel package may be the first thing you want to do after starting) and provides assistance on issue related to proot/Android exactly like this one (while you closed it before the OP got any hint from anybody), not a bunch of wrappers that barely help (like why would anyone need a wrapper for useradd?).

The worse thing is you don't even know bash well enough, or know how to manage a git repo/project properly (that's one of the reasons I never made a PR here). You really have better things to spend time on than spamming over the Termux repo.

Untrue, posts by me are tailored to wants and expressed needs; Termux users are still calling for help simply because many don't know. Do you enjoy listening to users posting please help me with knowledge of the solution, and NOT sharing? Or is infusing chaos into such a thread through presenting advice with unwavering authority that is tainted, but this is difficult for the beginner user to see, in your opinion when sharing, your cup of tea?

Let's stay in a great frame of mind. It works in Arch Linux in Termux PRoot as intended. Hooray! Hoorah! :musical_keyboard: :notes: :trombone: :trumpets: :strings: :musical_note: :musical_score: :drum: :violin:

The trickle down effect from Arch Linux in Termux PRoot is slowly infusing directly into Termux packages development. Do you agree?

tomty89 commented 6 years ago

I don't really mind being removed from the contributor list. Do whatever you wish.

If you have to take my last comment as a "destructive" one, that's your choice. I don't go slamming people out of no reason.

I don't expect everyone to be exceptionally good in bash, neither am I. But the thing is you are hosting a project written mostly/entirely in bash, I do expect you to familiarize yourself with bash before hardselling your work everywhere, otherwise you are just misleading people into traps.

I will not go into details about $*/$N against $@ again, because I have provided tons of explanations and cases already, and yet you didn't even bother to get to know why you need to quote a line like a && b for bash/su's -c in any case. The funny thing is the OP of that thread ultimately use a a wrapper that uses $* him/herself. You probably didn't even bother to read that though (but just "good" words like "works" and "thanks").

I don't need to be "contributive" enough to comment on a certain project. That's false logic and hypocrisy. And I don't create "projects'" that overcomplicate things when it's actually plain and simple. That's one of the Arch ways btw: read the fine manual and don't get blindly sucked into unnecessary silly wrappers. You didn't even care to think how the values for -w in proot should be adjusted for different cases. What can I expect?

You have hardly been sharing knowledge, but just busy sharing your "greatness". I don't mind you keep yourself busy in pointless things (because that's your freedom, and I do that myself as well, by participating in this project in any way; most people who aren't as free as I am would probably have just left with "ugh" in their mind). But I do mind you are more busy in spreading your work than you are in making it right.

Worst or not? I don't know. That's why I used "worse". Maybe it's not grammatically correct to use "worse" with "the". I don't attack people on a whole different subject in a discussion though.

SDRausty commented 6 years ago

@tomty89 was notified with this https://github.com/termux/termux-packages/pull/2306#issuecomment-381747690 regarding contributions.

@tomty89 I don't want your broken ideas anymore https://github.com/sdrausty/TermuxArch/commit/1660e3664fe009be4351d91fca38e4a8609510a0

+#### [tomty89](https://github.com/tomty89) has been banned from contributing anymore to this and similar projects for the following reasons: badgering to infuse tainted code, professing falsehoods as fact, and reversing on and deleting relevant comments for development of this project. 

References:

1) https://github.com/tomty89/proot_scripts/issues/1 1) Using $* can introduce security holes. 1) The worst = SE (social engineering) bait enabling tackle 2) https://github.com/sdrausty/TermuxArch/issues/30#issuecomment-375092877