cmc-csci145-math166 icon indicating copy to clipboard operation
cmc-csci145-math166 copied to clipboard

Permission Denied for Gensim

Open DestrosCMC opened this issue 3 years ago • 7 comments

Encountering permission error when trying to use gensim on the lambda server. Did anyone have a similar issue?

$ python3 pagerank.py --data=./data/lawfareblog.csv.gz --search_query='weapons'
Traceback (most recent call last):
  File "pagerank.py", line 14, in <module>
    vectors = gensim.downloader.load('glove-twitter-100')
  File "/home/Kieran.Daly.23/.local/lib/python3.6/site-packages/gensim/downloader.py", line 490, in load
    file_name = _get_filename(name)
  File "/home/Kieran.Daly.23/.local/lib/python3.6/site-packages/gensim/downloader.py", line 426, in _get_filename
    information = info()
  File "/home/Kieran.Daly.23/.local/lib/python3.6/site-packages/gensim/downloader.py", line 268, in info
    information = _load_info()
  File "/home/Kieran.Daly.23/.local/lib/python3.6/site-packages/gensim/downloader.py", line 212, in _load_info
    with open(cache_path, 'wb') as fout:
PermissionError: [Errno 13] Permission denied: '/home/Kieran.Daly.23/gensim-data/information.json'

DestrosCMC avatar Dec 08 '22 03:12 DestrosCMC

+1 we are all locked out, I think, plus we can't create any vim document and save it.

"pagerank3.py"

"pagerank3.py" E212: Can't open file for writing

afroCoderHanane avatar Dec 08 '22 03:12 afroCoderHanane

+1

sophiahuangg avatar Dec 08 '22 03:12 sophiahuangg

+1

QuinceyWilliams avatar Dec 08 '22 04:12 QuinceyWilliams

Same issue here. On top of that I don't even have permissions for basic operation like touch test.txt or mkdir test

ohorban avatar Dec 08 '22 07:12 ohorban

I am also running into a similar error when attempting to install gensim

$ pip3 install gensim
Exception:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 307, in run
    delete=build_delete) as build_dir:
  File "/usr/lib/python3/dist-packages/pip/utils/build.py", line 22, in __init__
    name = os.path.realpath(tempfile.mkdtemp(prefix="pip-build-"))
  File "/usr/lib/python3.6/tempfile.py", line 499, in mkdtemp
    prefix, suffix, dir, output_type = _sanitize_params(prefix, suffix, dir)
  File "/usr/lib/python3.6/tempfile.py", line 269, in _sanitize_params
    dir = gettempdir()
  File "/usr/lib/python3.6/tempfile.py", line 437, in gettempdir
    tempdir = _get_default_tempdir()
  File "/usr/lib/python3.6/tempfile.py", line 372, in _get_default_tempdir
    dirlist)
FileNotFoundError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/home/abhargava']

Bhargavaa1 avatar Dec 08 '22 07:12 Bhargavaa1

Same issue as @ohorban. Also, when I run ls -al, it looks like everything except some of my hidden files are now owned by 'abhargava'? Unsure how that came to be but it's probably related to whatever this permissions issue is

hfma2018@lambda-server:~$ ls -al
total 1673488
drwxr-xr-x  4 abhargava abhargava    12288 Dec  7 10:25 .
drwxr-xr-x 36 abhargava abhargava     4096 Nov 14 19:42 ..
-rw-------  1 hfma2018  hfma2018     32153 Dec  7 21:11 .bash_history
-rw-r--r--  1 hfma2018  hfma2018       220 Apr  4  2018 .bash_logout
-rw-r--r--  1 hfma2018  hfma2018      3771 Apr  4  2018 .bashrc
drwx------  2 hfma2018  hfma2018      4096 Nov 22 10:58 .cache
drwx------  3 hfma2018  hfma2018      4096 Nov 22 21:07 .gnupg
-rw-rw-r--  1 abhargava abhargava  1246358 Nov 24 19:21 model-baseline.vw
-rw-rw-r--  1 abhargava abhargava    32822 Nov 24 19:30 model-bp-12.vw
-rw-rw-r--  1 abhargava abhargava  1692374 Nov 24 19:26 model-bp-20.vw
... so on and so forth with my other models

I can't chown anything because I don't have sudo permissions

hfmandell avatar Dec 08 '22 07:12 hfmandell

This should be fixed now.

postmortem:

Yesterday, Adi came into my office with a problem about not being able to access certain files in his home folder. The cause of the problem was that these files were owned by a previous version of his account that was created for a different class. To fix the problem, I ran the commands

$ sudo chown abhargava *
$ sudo chown abhargava */*
$ sudo chown abhargava */*/*

in his home folder. This changed all of the normal files in his home folder into files owned by his new account, but it didn't change the hidden files like .local and .cache. By default, the glob * does not match hidden files.

Rather than rerunning separate chown commands on all these hidden files individually, I had the brilliant idea of modifying my previous commands above into

$ sudo chown abhargava .*
$ sudo chown abhargava .*/*
$ sudo chown abhargava .*/*/*

Now, the glob .* does match hidden files, and all of Adi's problems went away. Unfortunately, the glob .* also matches the special file .. which refers to the parent directory. So the glob .*/* when run in the directory /home/abhargava expands into /home/abhargava/../* which is equivalent to /home/*, and I accidentally changed everyone's home folder to be owned by Adi.

I fixed this by running the commands

$ cd /home
$ for file in *; do echo $file; sudo chown $file $file/*; done

which loops over everyone's home folder and resets it to be you as owner.

Embarrassingly, this is the THIRD time I've done this exact mistake on the lambda server, resulting in everyone being denied access. After the first time I told myself never to use the .* glob again ever no matter what... but I'll probably do it again next year sometime :/

(Also, the mistake is obviously 100% my own and not at all Adi's.)

mikeizbicki avatar Dec 08 '22 16:12 mikeizbicki