Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FreeBSD Support? #215

Closed
DecusAnima opened this issue Aug 3, 2023 · 19 comments
Closed

FreeBSD Support? #215

DecusAnima opened this issue Aug 3, 2023 · 19 comments
Assignees
Labels
bug Something isn't working needs more information Further information is requested

Comments

@DecusAnima
Copy link

I recently attempted to install this workflow into a TrueNAS Core jail of Nextcloud. However while I did follow the installation of OCRmyPDF as well as Tesseract the language list of the flow on my Nextcloud site remains empty.

I imagine this is due to Workflow OCR looking for these apps in where a Linux machine would typically have these programs installed, and TrueNAS Core is FreeBSD. I was curious if you could confirm this, and there is a way for me to get it to get Workflow OCR to see my OCRmyPDF installation in the jail.

I should mention that both Tesseract and OCRmyPDF seem to be properly installed as I can run their commands manually through the shell and get outputs.

@DecusAnima DecusAnima added the bug Something isn't working label Aug 3, 2023
@R0Wi
Copy link
Contributor

R0Wi commented Aug 3, 2023

Hi, the app uses tesseract --list-langs to receive the installed languages on the backend system.

$commandStr = 'tesseract --list-langs';

Could you check if you can execute this command manually on your backend? Also would it be possible for you to share some Nextcloud logs after you opened the settings page and tried to configure the appropriate languages? Otherwise it will be quite hard for us to tell where the error comes from.

Could you also tell us which version (Nextcloud + app) you're using? We had something similar in #184

@R0Wi R0Wi added the needs more information Further information is requested label Aug 3, 2023
@DecusAnima
Copy link
Author

I ran tesseract --list-langs in the jail and got the output showing in the screenshot, I also went ahead and read the attached nextcloud.log and it seems the vast majority was some antivirus errors because I admittedly haven't fully setup. My Nextcloud is running version 27.0.0 and the app is running version 1.27.1.
nextcloud.log
tesseract --list-langs

@R0Wi
Copy link
Contributor

R0Wi commented Aug 3, 2023

Thanks for your fast feedback! I'd say that from a backend perspective everything looks good. I could only imagine that you're facing a frontend issue with the OCR workflow settings UI. To check that you should open your browsers devtools if possible. After that, please browse to the settings UI and try to open the languages dropdown. If there is an error in the frontend code, it should show up in the console tab. Please share your results here afterwards.

Btw: the OCR workflow should also work fine without a language set, even though the result might not be as accurate.

@DecusAnima
Copy link
Author

Ah, I found the source of the issue now, seems to be a 404 error with some of the js code for the OCR workflow, followed by error 500 when attempting to pull request the following files. It's possible this might be due to a lack of javascript plugins in my FreeBSD Jail, I'm going to look into that to see. If there is any other ideas you have for this I'd appreciate it.
Screenshot 2023-08-04 003722

Screenshot 2023-08-04 003338

@R0Wi
Copy link
Contributor

R0Wi commented Aug 4, 2023

Yes it indeed seems that the API endpoint which delivers the installed languages (/apps/workflow_ocr/ocrBackendInfo/installesLangs) fails with a server error 500. What's weird here is that this error should be logged in the nextcloud.log file, don't know why it's not there.

The app itself delivers all Javascripts it needs so there shouldn't be a need of anything else. The 404 errors is only complaining about missing source map files. You don't need them, they're just needed for development.

Could you try to directly browse to https://192.168.1.40/apps/workflow_ocr/ocrBackendInfo/installesLangs and see what's the result? Also please again check your NC log for any workflow_ocr related entries. You might also try to decrease your loglevel if needed.

@R0Wi
Copy link
Contributor

R0Wi commented Aug 4, 2023

Might be a duplicate of #183

@DecusAnima
Copy link
Author

Going to https://192.168.1.40/apps/workflow_ocr/ocrBackendInfo/installesLangs directly gives a page not found error with the following console log.
Screenshot 2023-08-04 020835
Reducing loglevel to 0 did produce some issues regarding /appinfo/app.php, but I'm not sure if this is the cause, unfortunately the log file is getting so large that I couldn't upload it. That being said nothing outside of the following line from the log doesn't seem to be in reference to OCR.

00:00","remoteAddr":"192.168.1.10","user":"DecusAnima","app":"encryption","method":"GET","url":"/apps/workflow_ocr/ocrBackendInfo/installedLangs","message":"/appinfo/app.php is deprecated, use \OCP\AppFramework\Bootstrap\IBootstrap on the application class instead.","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36","version":"27.0.0.8","data":{"app":"encryption"}}
{"reqId":"tiqw5igzNCOBIqlk32JF","level":0,"time":"2023-08-04T07:15:59+

@R0Wi
Copy link
Contributor

R0Wi commented Aug 4, 2023

Sorry I had a typo in my url, I meant https://192.168.1.40/apps/workflow_ocr/ocrBackendInfo/installedLangs. You can also copy the url directly from your browser console where you got the 500 error.

@DecusAnima
Copy link
Author

Seemed to have found the issue, going to the corrected link gives a CSRF check fail, wouldn't know if this has to do with OCR workflow or Tesseract though.

@R0Wi
Copy link
Contributor

R0Wi commented Aug 4, 2023

Ah sorry I think directly calling the endpoint is not possible due to the automatic CSRF check.

If you're on the settings page and open the devtools, could you please try to query the following in the console tab?

$.get('https://192.168.1.40/index.php/apps/workflow_ocr/ocrBackendInfo/installedLangs').then(res=>console.log(res))

I'd like to get more information on the 500 server error, either through the logs or through the frontend

@DecusAnima
Copy link
Author

Screenshot 2023-08-04 040517

@DecusAnima
Copy link
Author

Logs still seems to only show the /appinfo/app.php deprecation when referencing the https://192.168.1.40/index.php/apps/workflow_ocr/ocrBackendInfo/installedLangs pull

@R0Wi
Copy link
Contributor

R0Wi commented Aug 4, 2023

It has to be a really "hard" error if it's not logged in the nextcloud.log. Maybe you want to also check your webserver and/or php log files if possible.

What does the following give you?

$.get('https://192.168.1.40/index.php/apps/workflow_ocr/ocrBackendInfo/installedLangs').error(res=>console.log(res.responseText)).then(res=>console.log(res))

This should log the returned HTML page the server gives you

@DecusAnima
Copy link
Author

Screenshot 2023-08-04 044125
Couldn't find anything relevant in php logs. As for the pull results, looks like that bash can't see Tesseract.

@R0Wi
Copy link
Contributor

R0Wi commented Aug 4, 2023

Ok I think we're getting closer. Usually the error message "The command 'tesseract --list-langs' produced an error: Exited abnormally with exit-code 127 ..." should show up in the UI, that might be a bug.

But what this is telling us is that the user which runs the PHP or webserver-process (most likely www-data) is not able to use the tesseract command. Probably it's missing in the PATH of that user or there's some other problem why it can't be used.

To reproduce the behaviour, login to your box and do something like sudo -u www-data sh (replace www-data with the appropriate user) to open a new shell for that user. That's exacly the environment which is used by the OCR app. Try to figure out why the tesseract command is not available in that environment. Like I said, maybe you'll have to add the binary path to the PATH variable for that user.

Maybe also have a look at #203 where we had a similar problem.

@DecusAnima
Copy link
Author

Wow, after a few hours of messing with permissions and pathing, I finally got it. I guess the issue did indeed stem from where FreeBSD set the PATH variables, I had to dig through some forums to find how to add new commands to the list but afterwards the languages popped up. Thank you for guiding me through this.

@DecusAnima
Copy link
Author

It seems another issue is cropping up however, once I had everything set up when I try to save a flow I get the following
Screenshot 2023-08-04 071421

@R0Wi
Copy link
Contributor

R0Wi commented Aug 4, 2023

Glad to help! I think you're facing the same issue like mentioned here: #41

Btw: if you provide the full solution on how you fixed the error, I'd be happy to but some notes into the README.

@DecusAnima
Copy link
Author

Yeah I found the resolution for the above error quickly with the mentioned issue, thanks again.

For a full solution regarding this error, apparently it has to do with the user running the php and/or web programs for Nextcloud not having the path for tesseract commands. In my case the bin for tesseract was in /usr/local/bin. FreeBSD has a command for routing a new command path 'chsh' (e.g. chsh -s /usr/local/bin/tesseract).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs more information Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants