0

Basically, I have an upcoming school project (any computer science topic), and I decided to build a metadata viewer. I am not a programmer or coder, my coding course starts this year, and this project is just for intro and I am allowed to use online resources.

So, I just saw this GitHub Rep that was perfect for my project. I copied the code and deployed it on Heroku with some help from Google and finally I was successfully able to launch it. - https://meta-data-viewer.herokuapp.com/

The website seems to be working fine though, but the app doesn't work. When I enter an image's link over there, I just get an "500 internal server error", but the original website made by the original creator seems to work well, even I though I exactly copied the same code without editing anything.

I checked the log file on Heroku, but I don't understand anything. Here it is -

2022-05-22T20:40:43.939976+00:00 app[web.1]: result = func(*args, **kwargs) 2022-05-22T20:40:43.939976+00:00 app[web.1]: File "/app/./main.py", line 64, in fetch_data 2022-05-22T20:40:43.939976+00:00 app[web.1]: process = subprocess.Popen([EXIFTOOL_PATH, '-g0', '-j', '-c', '%+.6f', '-'], 2022-05-22T20:40:43.939977+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/subprocess.py", line 951, in init 2022-05-22T20:40:43.939978+00:00 app[web.1]: self._execute_child(args, executable, preexec_fn, close_fds, 2022-05-22T20:40:43.939978+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/subprocess.py", line 1821, in _execute_child 2022-05-22T20:40:43.939978+00:00 app[web.1]: raise child_exception_type(errno_num, err_msg, err_filename) 2022-05-22T20:40:43.939981+00:00 app[web.1]: PermissionError: [Errno 13] Permission denied: 'exiftool/exiftool' 2022-05-22T20:40:43.940707+00:00 app[web.1]: 10.1.30.195 - - [22/May/2022 20:40:43] "GET /?img=https%3A%2F%2Fwww.computerhope.com%2Fjargon%2Fd%2Fdd.jpg HTTP/1.1" 500 819 2022-05-22T20:40:45.279566+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=meta-data-viewer.herokuapp.com request_id=70404839-81e1-4e60-8489-c53ee110f270 fwd="5.107.156.38" dyno=web.1 connect=0ms service=1ms status=200 bytes=153 protocol=https 2022-05-22T20:40:45.279244+00:00 app[web.1]: 10.1.30.195 - - [22/May/2022 20:40:45] "GET /favicon.ico HTTP/1.1" 200 0 2022-05-22T20:48:58.921194+00:00 heroku[router]: at=info method=GET path="/" host=meta-data-viewer.herokuapp.com request_id=4fc65366-97a7-42d5-b3ea-bb14c2249331 fwd="5.107.156.38" dyno=web.1 connect=0ms service=2ms status=200 bytes=3913 protocol=https 2022-05-22T20:48:58.922029+00:00 app[web.1]: INFO:root:No image location specified 2022-05-22T20:48:58.922635+00:00 app[web.1]: 10.1.33.159 - - [22/May/2022 20:48:58] "GET / HTTP/1.1" 200 3757 2022-05-22T20:49:00.230925+00:00 app[web.1]: 10.1.33.159 - - [22/May/2022 20:49:00] "GET /favicon.ico HTTP/1.1" 200 0 2022-05-22T20:49:00.229447+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=meta-data-viewer.herokuapp.com request_id=185f7d6c-56d7-4d73-b973-944d3672cf8e fwd="5.107.156.38" dyno=web.1 connect=0ms service=1ms status=200 bytes=153 protocol=https

What can I try next?

halfer
  • 19,824
  • 17
  • 99
  • 186
  • 2
    The log is complaining that `EXIFTOOL_PATH` (whatever that may be) is not installed. This has nothing to do with Git or HTML, it's just a missing program. – torek May 22 '22 at 20:59
  • I have discovered the problem. The program isn't missing, but instead program's access on heroku has been denied. So, I just did a SSH to heroku and chmod the exiftool and now it works fine. But there also comes an another problem. This is only temporary. After a few minutes, the error comes again and I have to do the chmod thing again to make it work. Is there a permanent fix? – Martin Smith May 23 '22 at 18:10
  • Ah, yes, if it's not-executable that's as good (well, bad) as entirely-missing. If the permissions are changing like that, this means you have no stable storage, which is common in a lot of web deployment setups: you cannot store things in the file system as there *is no actual file system* (just a temporary one rebuilt from scratch every time the virtual installation is re-created). In this case you must put any necessary instructions, like `chmod +x`, into the setup scripts. – torek May 23 '22 at 18:32
  • Can you please guide me on that? I am complete noob to coding, so I can't write my own scripts. Kindly help me out. – Martin Smith May 24 '22 at 15:58
  • 1
    It looks like the `main.py` you have hardwires the external executable name as `exiftool/exiftool`. In your deployment code (maybe in Heroku somewhere) perhaps you can do `chmod +x exiftool/exiftool` to give it the execute permission as the current user. There isn't enough information here to give you instructions with any certainty, but that might be a start (your build script may have a different working directory, or may run as a different user). – halfer May 24 '22 at 20:13
  • I have tried doing `chmod +x` on Heroku console also but to no avail. The only thing that works here so far is SSH to Heroku dyno and then `chmod +x` to the `exiftool` file. And that's only for a small period of time. I have tried adding the python version of `chmod +x` on the `main.py` file, doesn't work. Even created a new bash file with the the chmod command and added a code in `main.py` file to execute that bash file, but still doesn't work. – Martin Smith May 25 '22 at 05:26
  • [This is the exact app that I trying to deploy on Heroku](https://github.com/JoseTomasTocino/image-metadata-viewer) - complete fork with no change.. the original website seems to work well, but this problem only exists for me. – Martin Smith May 25 '22 at 05:27
  • Your binary appears to be a Perl dependency loaded as a Git submodule. In your Git repo you could try editing `main.py` so that `'exiftool/exiftool'` becomes `'perl exiftool/exiftool'` or `'/usr/bin/perl exiftool/exiftool'`. This will elide the need for executable permissions. That change will need to be committed in your repo so that it is permanent. – halfer May 25 '22 at 07:40
  • U mean to change this code - `EXIFTOOL_PATH = '/exiftool/exiftool'` to `EXIFTOOL_PATH = 'perl exiftool/exiftool'`? I tried it right now, but it comes with the error `FileNotFoundError: [Errno 2] No such file or directory:`. Or, should I add a separate command before the `EXIFTOOL_PATH` code? Or replace the complete code to `perl exiftool/exiftool`? – Martin Smith May 25 '22 at 15:37
  • Yeah, that was one suggestion. Try the second one also. It's a string to an executable, so the full line might be something like `EXIFTOOL_PATH = '/usr/bin/perl exiftool/exiftool'`. (The Perl binary should already be executable). – halfer May 25 '22 at 15:59
  • I have tried both, both comes with the same error. – Martin Smith May 25 '22 at 16:00
  • You mentioned `/exiftool/exiftool`, but there is no such line. I said `exiftool/exiftool` - see line 19 in `main.py`. Make sure `exiftool/exiftool` does not have a preceding slash in any case - that is most unlikely to work. – halfer May 25 '22 at 16:00
  • You could try `which perl` at your console to get the exact path of your Perl binary too, and then use that instead, instead of `/usr/bin/perl`. – halfer May 25 '22 at 16:01
  • 1
    Yes, I did it exactly like u said. 1. `EXIFTOOL_PATH = '/usr/bin/perl exiftool/exiftool'` 2. `EXIFTOOL_PATH = 'perl exiftool/exiftool'` Both gets the same error – Martin Smith May 25 '22 at 16:02
  • Just did the `which perl` command, the dir seems to be correct `/usr/bin/perl` – Martin Smith May 25 '22 at 16:04
  • (Aside from the above, this problem is a mix of language library, operating system, and continuous integration oddities, and it would probably require an experienced person to roll their sleeves up and do some tinkering with/for you. That may make the question a poor fit here, since readers tend to prefer self-contained questions that can be presented inside a question post. Perhaps you can pair with a friend or someone from your course). – halfer May 25 '22 at 16:08

0 Answers0