# GitLab 上传图片失败

# 日志查看

安装好 GitLab 之后上传图片报错,查看日志发现问题:

==> /var/log/gitlab/gitlab-workhorse/current <==
{"correlation_id":"LaEfEQROIE7","filename":"wechat.jpg","level":"info","msg":"running exiftool to remove any metadata","time":"2022-06-20T05:10:14+08:00"}
{"correlation_id":"LaEfEQROIE7","error":"handleFileUploads: extract files from multipart: failed to start EXIF metadata cleaner: start [exiftool -all= --IPTC:all --XMP-iptcExt:all -tagsFromFile @ -ResolutionUnit -XResolution -YResolution -YCbCrSubSampling -YCbCrPositioning -BitsPerSample -ImageHeight -ImageWidth -ImageSize -Copyright -CopyrightNotice -Orientation -]: fork/exec /opt/gitlab/embedded/bin/exiftool: no such file or directory","level":"error","method":"POST","msg":"error","time":"2022-06-20T05:10:14+08:00","uri":"/admin/appearance"}
{"correlation_id":"LaEfEQROIE7","duration_ms":1,"host":"gitlab.yuanke.com","level":"info","method":"POST","msg":"access","proto":"HTTP/1.1","referrer":"http://gitlab.yuanke.com/admin/appearance","remote_addr":"127.0.0.1:0","remote_ip":"127.0.0.1","status":500,"system":"http","time":"2022-06-20T05:10:14+08:00","uri":"/admin/appearance","user_agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36","written_bytes":2926}
{"correlation_id":"lZArmH6EsVa","duration_ms":116,"host":"gitlab.yuanke.com","level":"info","method":"GET","msg":"access","proto":"HTTP/1.1","referrer":"http://gitlab.yuanke.com/admin/appearance","remote_addr":"127.0.0.1:0","remote_ip":"127.0.0.1","status":301,"system":"http","time":"2022-06-20T05:10:14+08:00","uri":"/favicon.ico","user_agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36","written_bytes":174}

# 日志分析

看到错误,定位到问题,初步判断是缺少依赖:

"error":"handleFileUploads: extract files from multipart: failed to start EXIF metadata cleaner: start [exiftool -all= --IPTC:all --XMP-iptcExt:all -tagsFromFile @ -ResolutionUnit -XResolution -YResolution -YCbCrSubSampling -YCbCrPositioning -BitsPerSample -ImageHeight -ImageWidth -ImageSize -Copyright -CopyrightNotice -Orientation -]: fork/exec /opt/gitlab/embedded/bin/exiftool: no such file or directory"

# 解决方案

安装 perl,再次上传,问题解决。

yum -y install perl

参考文献:

Internal server error 500 at issue image upload (#28215) · Issues · GitLab.org _ GitLab · GitLab (opens new window)