Why am I Not Able to Write to Temp Dir Even After Manually Downloading the Binary and Setting the Bin Path?

This topic was automatically generated from Slack. You can find the original thread here.

I tried downloading the binary manually, putting it in temp, and setting the bin path, but TIL no write permission to temp dir :pensive:

you should have write permissions on /tmp . Can you show me exactly what you’re seeing?

[Errno 13] Permission denied: '/tmp/tmpsh81wmav/tesseract'

from

def handler(pd: "pipedream"):
    tess_url = 'https://github.com/AlexanderP/tesseract-appimage/releases/download/v5.3.3/tesseract-5.3.3-x86_64.AppImage'
    temp_dir = tempfile.TemporaryDirectory()
    tess_bin = os.path.join(temp_dir.name, 'tesseract')

    tess = requests.get(tess_url)
    with open(tess_bin, 'wb') as f:
        f.write(tess.content)

    pytesseract.pytesseract.tesseract_cmd = tess_bin

Can you try either writing directly to /tmp or create the intermediate directory before writing to it?

Lol, well it’s been ‘Testing…’ for about 5 mins now. Binary is 60 MB so not sure if throttled?

Also I’m aware this is a terrible workaround :zany_face:

I think it’s a clever workaround and I wish we had a better way to package your own binaries / libraries in your workflow. We’ve added very common software like gcc, rust, python, and other libs commonly required by third party packages, but we need a mechanism for you to add your own to the build! I’m giving this feedback to the team again

I did find this issue, which seems to imply the .js wrapper bundles the binary:

I’ll try that if this doesn’t work (which it’s looking like it won’t, I restarted but stuck on ‘Testing…’ again)

Ohh! I think the

Permission denied

is actually the Python wrapper trying to run the binary

Nope, os.chmod(tess_bin, 777)

same error :disappointed:

Could you do me a favor and create a GitHub issue for this? We’re out of the office for Thanksgiving but I’d like to see what the core issue is and if we can help unblock you

https://github.com/PipedreamHQ/pipedream/issues

Sure! Bug or feature? :thinking_face:

Bug is fine in this case

Posted thread to Discourse: Why am I Unable to Write to the Temp Directory After Manually Downloading and Setting the Binary Path?

What an interesting idea for a bot!

I never created that bug, but I ended up switching to node, I’m using a tesseract wrapper from NPM which (I presume) bundles the binary

And, the node wrapper is actually way more featureful!

oh great, glad to hear