Skip to content

Commit 3c1439f

Browse files
committed
fix find start area under homebrew
1 parent af90931 commit 3c1439f

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

src/main.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,31 @@ const char *
7070
get_prefix(void)
7171
{
7272
if (!prefix_valid) {
73+
g_autofree char *basename = g_path_get_basename(main_argv0);
74+
g_autofree char *pathname = path_find_file(basename);
75+
7376
const char *prefix;
7477

75-
if (!(prefix = vips_guess_prefix(main_argv0, "VIPSHOME"))) {
78+
prefix = vips_guess_prefix(main_argv0, "VIPSHOME");
79+
80+
if (!prefix ||
81+
!existsf("%s/share/nip4", prefix)) {
82+
/* the libvips guesser failed to find our install area ... try
83+
* using the path to our executable
84+
*
85+
* This can happon with homebrew, for example, where the
86+
* compile-time libvips prefix will not match the nip4 prefix
87+
*/
88+
g_autofree char *trailing = g_strjoin("/", "bin", basename, NULL);
89+
if (pathname &&
90+
is_postfix(pathname, trailing))
91+
pathname[strlen(pathname) - strlen(trailing)] = '\0';
92+
93+
prefix = pathname;
94+
}
95+
96+
if (!prefix ||
97+
!existsf("%s/share/nip4", prefix)) {
7698
error_top(_("Unable to find install area"));
7799
error_vips();
78100

src/mainwindow.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,9 +1011,10 @@ mainwindow_size_images(VipsObject *object, size_t *size)
10111011
void
10121012
mainwindow_about(Mainwindow *main, VipsBuf *buf)
10131013
{
1014+
vips_buf_appendf(buf, _("VIPSHOME = %s\n"), g_getenv("VIPSHOME"));
1015+
vips_buf_appendf(buf, _("HOME = %s\n"), g_getenv("HOME"));
10141016
vips_buf_appendf(buf, _("argv0 = %s\n"), main_argv0);
10151017
vips_buf_appendf(buf, _("prefix = %s\n"), get_prefix());
1016-
vips_buf_appendf(buf, _("VIPSHOME = %s\n"), g_getenv("VIPSHOME"));
10171018
vips_buf_appendf(buf, "\n");
10181019

10191020
double sz = find_space(PATH_TMP);

0 commit comments

Comments
 (0)