question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PermissionError when running C binary that reads and writes files

See original GitHub issue

I have create an Azure Python Function that uses PuLP to solve linear problems. This library creates a problem file in /tmp and then calls a C binary (included in the PuLP package in site-packages) to solve the problem. This binary writes a file to /tmp with the result. The C binary throws a permission error, and I believe it has to do with writing the result file.

It works locally on my Windows PC, and I was also able to run the code on the docker image mcr.microsoft.com/azure-functions/python:2.0 (with root access). When I publish to Azure Functions and run the function, I receive a PermissionError:

Request was invalid: Traceback (most recent call last):
  File "/home/site/wwwroot/func_solve/__init__.py", line 19, in main
    solution = solve(goal, variables, constraints)
  File "/home/site/wwwroot/library/solver.py", line 43, in solve
    problem.solve()
  File "/home/site/wwwroot/.python_packages/lib/python3.6/site-packages/pulp/pulp.py", line 1671, in solve
    status = solver.actualSolve(self, **kwargs)
  File "/home/site/wwwroot/.python_packages/lib/python3.6/site-packages/pulp/solvers.py", line 1367, in actualSolve
    return self.solve_CBC(lp, **kwargs)
  File "/home/site/wwwroot/.python_packages/lib/python3.6/site-packages/pulp/solvers.py", line 1427, in solve_CBC
    cbc = subprocess.Popen(args, stdout = pipe, stderr = pipe)
  File "/usr/local/lib/python3.6/subprocess.py", line 729, in __init__
    restore_signals, start_new_session)
  File "/usr/local/lib/python3.6/subprocess.py", line 1364, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: '/home/site/wwwroot/.python_packages/lib/python3.6/site-packages/pulp/solverdir/cbc/linux/64/cbc'Request was invalid: Traceback (most recent call last):
  File "/home/site/wwwroot/func_solve/__init__.py", line 19, in main
    solution = solve(goal, variables, constraints)
  File "/home/site/wwwroot/library/solver.py", line 43, in solve
    problem.solve()
  File "/home/site/wwwroot/.python_packages/lib/python3.6/site-packages/pulp/pulp.py", line 1671, in solve
    status = solver.actualSolve(self, **kwargs)
  File "/home/site/wwwroot/.python_packages/lib/python3.6/site-packages/pulp/solvers.py", line 1367, in actualSolve
    return self.solve_CBC(lp, **kwargs)
  File "/home/site/wwwroot/.python_packages/lib/python3.6/site-packages/pulp/solvers.py", line 1427, in solve_CBC
    cbc = subprocess.Popen(args, stdout = pipe, stderr = pipe)
  File "/usr/local/lib/python3.6/subprocess.py", line 729, in __init__
    restore_signals, start_new_session)
  File "/usr/local/lib/python3.6/subprocess.py", line 1364, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: '/home/site/wwwroot/.python_packages/lib/python3.6/site-packages/pulp/solverdir/cbc/linux/64/cbc'

I have verified that there is execution permission to the binary.

Does the binary have restricted permissions? Is it not valid to write files to the disk?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8

github_iconTop GitHub Comments

2reactions
Rfaeringcommented, Aug 12, 2019

I am having the same issue, so I tried to use custom image instead, based on this article https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-function-linux-custom-image

This did solve the issue and I were able to use PuLP on both premium plan and dedicated plan.

But I did not do any real changes to the image except install dependencies and create a http endpoint. Should this not behave the same way as the image used in the consumption plan ?

0reactions
stefanushinardicommented, Dec 14, 2021

As pointed out, the workaround is to use custom container. Please reopen if you feel the issue is not yet solved

Read more comments on GitHub >

github_iconTop Results From Across the Web

Permission denied error while writing to a file in Python
Permission denied simply means the system is not having permission to write the file to that folder. Give permissions to the folder using...
Read more >
How to Fix Shell Script Permission Denied Error in Linux
To fix the permission denied error in Linux, one needs to change the file permission of the script. Use the “chmod” (change mode)...
Read more >
How to resolve the "Permission Denied" error in Linux
While using Linux, you may encounter the error, “permission denied”. This error occurs when the user does not have the privileges to make...
Read more >
How to solve the bash: permission denied error?
The error usually occurs when the script you are trying to execute does not have the necessary permissions. Modifying the permissions of the...
Read more >
Bash permission denied Explanation and Solution
On a Linux operating system, there are three types of permissions: Read; Write; Execute. You can have permission to read and write a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found