Page MenuHomePhabricator

Running a core script fails with 'permission denied' creating a logfile folder
Closed, ResolvedPublic

Description

@MuhammadShuaib added a comment. in T146961:

When i trying to run a script e.g clean sandbox.py, it gives following error:

tools.-@tools-bastion-03:~/pycore$ python pwb.py clean_sandbox.py -simulate
WARNING: Skipped '/data/project/-/pycore/user-config.py': owned by someone else.
WARNING: family and mylang are not set.
Defaulting to family='test' and mylang='test'.
Traceback (most recent call last):
  File "pwb.py", line 270, in <module>
    if not main():
  File "pwb.py", line 264, in main
    run_python_file(filename, [filename] + args, argvu, file_package)
  File "pwb.py", line 109, in run_python_file
    main_mod.__dict__)
  File "./scripts/clean_sandbox.py", line 294, in <module>
    main()
  File "./scripts/clean_sandbox.py", line 266, in main
    local_args = pywikibot.handle_args(args)
  File "/data/project/-/pycore/pywikibot/bot.py", line 818, in handle_args
    writeToCommandLogFile()
  File "/data/project/-/pycore/pywikibot/bot.py", line 943, in writeToCommandLogFile
    command_log_filename = config.datafilepath('logs', 'commands.log')
  File "/data/project/-/pycore/pywikibot/config2.py", line 828, in datafilepath
    return makepath(os.path.join(base_dir, *filename))
  File "/data/project/-/pycore/pywikibot/config2.py", line 816, in makepath
    os.makedirs(dpath)
  File "/usr/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/data/project/-/pycore/logs'
<type 'exceptions.OSError'>
CRITICAL: Waiting for 1 network thread(s) to finish. Press ctrl-c to abort

Event Timeline

Restricted Application added subscribers: pywikibot-bugs-list, Aklapper. · View Herald Transcript

This has nothing to do with pywikibot -- the issue is with the permissions on that directory:

valhallasw@tools-bastion-03:/data/project/shuaib-bot$ ls -ld pycore
drwxr-sr-x 9 nadwi tools.shuaib-bot 4096 Sep 29 06:56 pycore

The pycore directory is owned by user nadwi, and the group tools.shuaib-bot does not have write permissions. While logged in as tools.shuaib-bot, try running take pycore; that should fix the ownership of the entire directory tree.

scfc assigned this task to valhallasw.
scfc subscribed.

The cause with the ownership/permissions of the directory and a solution has been explained by @valhallasw, so resolving this issue here. @MuhammadShuaib, if you need further help setting the ownership/permissions or general information on best practices for running Pywikibots, please reopen this task or ask on IRC/mailing list/etc.