diff --git a/internal/config/config_filepaths.go b/internal/config/config_filepaths.go index 474625494..78df64967 100644 --- a/internal/config/config_filepaths.go +++ b/internal/config/config_filepaths.go @@ -414,11 +414,20 @@ func (c *Config) CachePath() string { return fs.Abs(c.options.CachePath) } -// CmdCachePath returns a path that CLI commands can use as cache directory. +// CmdCachePath returns a path that external CLI tools can use as cache directory. func (c *Config) CmdCachePath() string { return filepath.Join(c.CachePath(), "cmd") } +// CmdLibPath returns the dynamic loader path that external CLI tools should use. +func (c *Config) CmdLibPath() string { + if dir := os.Getenv("LD_LIBRARY_PATH"); dir != "" { + return dir + } + + return "/usr/local/lib:/usr/lib" +} + // ThumbCachePath returns the thumbnail storage directory. func (c *Config) ThumbCachePath() string { return c.CachePath() + "/thumbnails" diff --git a/internal/config/config_filepaths_test.go b/internal/config/config_filepaths_test.go index 4cec49033..bf234a2bf 100644 --- a/internal/config/config_filepaths_test.go +++ b/internal/config/config_filepaths_test.go @@ -133,6 +133,15 @@ func TestConfig_CmdCachePath(t *testing.T) { } } +func TestConfig_CmdLibPath(t *testing.T) { + c := NewConfig(CliTestContext()) + if dir := c.CmdLibPath(); dir == "" { + t.Fatal("cmd lib path is empty") + } else if !strings.HasPrefix(dir, "/usr") { + t.Fatalf("unexpected cmd lib path: %s", dir) + } +} + func TestConfig_CachePath2(t *testing.T) { c := NewConfig(CliTestContext()) assert.Equal(t, "/go/src/github.com/photoprism/photoprism/storage/testdata/cache", c.CachePath()) diff --git a/internal/photoprism/convert_jpeg.go b/internal/photoprism/convert_jpeg.go index 8b89f53e0..42879d03d 100644 --- a/internal/photoprism/convert_jpeg.go +++ b/internal/photoprism/convert_jpeg.go @@ -110,7 +110,10 @@ func (c *Convert) ToJpeg(f *MediaFile, force bool) (*MediaFile, error) { var stderr bytes.Buffer cmd.Stdout = &out cmd.Stderr = &stderr - cmd.Env = []string{fmt.Sprintf("HOME=%s", c.conf.CmdCachePath())} + cmd.Env = []string{ + fmt.Sprintf("HOME=%s", c.conf.CmdCachePath()), + fmt.Sprintf("LD_LIBRARY_PATH=%s", c.conf.CmdLibPath()), + } log.Infof("convert: converting %s to %s (%s)", clean.Log(filepath.Base(fileName)), clean.Log(filepath.Base(jpegName)), filepath.Base(cmd.Path)) diff --git a/scripts/dist/install-libheif.sh b/scripts/dist/install-libheif.sh index ffb68c785..a503b50c0 100755 --- a/scripts/dist/install-libheif.sh +++ b/scripts/dist/install-libheif.sh @@ -2,7 +2,7 @@ set -e -DESTDIR=$(realpath "${1:-/usr}") +DESTDIR=$(realpath "${1:-/usr/local}") LIBHEIF_VERSION=${2:-v1.13.0} SYSTEM_ARCH=$("$(dirname "$0")/arch.sh") DESTARCH=${DESTARCH:-$SYSTEM_ARCH}