Does the external program have execute permissions? What external program are you trying to call? Where did you put the external program? Can you provide part of the code where you are calling run_command?
I am trying to call ecpg (PostgreSQL SQL embedded pre-compiler) . It can be called from the command line in a terminal and if I run meson from the command line and ninja it also works well. I got the error only if I try to run it on Gnome-Builder.
I canât say this will fix it but, you should always use find_program if you need to locate and call a program from the host system. So something like this.
I think I know what might be happening here. If you used one of the default project templates in GNOME Builder or have a flatpak manifest in your project, GNOME Builder tries to build a Flatpak by default and when building a flatpak, it does not have access to stuff on the host. So, it cannot find ecpg that is only available on the host.
To fix this, you need to
Use GNOME Builder installed via your distroâs package manager not Flatpak
Click on down arrow right next to hammer shaped âBuild projectâ button
Click on âActive Configurationâ and choose âDefaultâ
Program ecpg found: NO
../../../../../../Projetos/teste_gtk/src/meson.build:6:0: ERROR: Program 'ecpg' not found or not executable
It seems something related to gnome-builder because If I run the same from the command line it works well.
It does not work when I tried to compile and run using gnome-builder
marcotc@qvaliz23:~/Projetos/teste_gtk$ meson setup build
The Meson build system
Version: 1.0.1
Source dir: /home/marcotc/Projetos/teste_gtk
Build dir: /home/marcotc/Projetos/teste_gtk/build
Build type: native build
Project name: teste_gtk
Project version: 0.1.0
C compiler for the host machine: cc (gcc 12.3.0 "cc (Ubuntu 12.3.0-1ubuntu1~23.04) 12.3.0")
C linker for the host machine: cc ld.bfd 2.40
Host machine cpu family: x86_64
Host machine cpu: x86_64
Configuring config.h using configuration
Compiler for C supports arguments -Wcast-align: YES
Compiler for C supports arguments -Wdeclaration-after-statement: YES
Compiler for C supports arguments -Werror=address: YES
Compiler for C supports arguments -Werror=array-bounds: YES
Compiler for C supports arguments -Werror=empty-body: YES
Compiler for C supports arguments -Werror=implicit: YES
Compiler for C supports arguments -Werror=implicit-function-declaration: YES
Compiler for C supports arguments -Werror=incompatible-pointer-types: YES
Compiler for C supports arguments -Werror=init-self: YES
Compiler for C supports arguments -Werror=int-conversion: YES
Compiler for C supports arguments -Werror=int-to-pointer-cast: YES
Compiler for C supports arguments -Werror=main: YES
Compiler for C supports arguments -Werror=misleading-indentation: YES
Compiler for C supports arguments -Werror=missing-braces: YES
Compiler for C supports arguments -Werror=missing-include-dirs: YES
Compiler for C supports arguments -Werror=nonnull: YES
Compiler for C supports arguments -Werror=overflow: YES
Compiler for C supports arguments -Werror=parenthesis: NO
Compiler for C supports arguments -Werror=pointer-arith: YES
Compiler for C supports arguments -Werror=pointer-to-int-cast: YES
Compiler for C supports arguments -Werror=redundant-decls: YES
Compiler for C supports arguments -Werror=return-type: YES
Compiler for C supports arguments -Werror=sequence-point: YES
Compiler for C supports arguments -Werror=shadow: YES
Compiler for C supports arguments -Werror=strict-prototypes: YES
Compiler for C supports arguments -Werror=trigraphs: YES
Compiler for C supports arguments -Werror=undef: YES
Compiler for C supports arguments -Werror=write-strings: YES
Compiler for C supports arguments -Wformat-nonliteral: YES
Compiler for C supports arguments -Wignored-qualifiers: YES
Compiler for C supports arguments -Wimplicit-function-declaration: YES
Compiler for C supports arguments -Wlogical-op: YES
Compiler for C supports arguments -Wmissing-declarations: YES
Compiler for C supports arguments -Wmissing-format-attribute: YES
Compiler for C supports arguments -Wmissing-include-dirs: YES
Compiler for C supports arguments -Wmissing-noreturn: YES
Compiler for C supports arguments -Wnested-externs: YES
Compiler for C supports arguments -Wno-cast-function-type: YES
Compiler for C supports arguments -Wno-dangling-pointer: YES
Compiler for C supports arguments -Wno-missing-field-initializers: YES
Compiler for C supports arguments -Wno-sign-compare: YES
Compiler for C supports arguments -Wno-unused-parameter: YES
Compiler for C supports arguments -Wold-style-definition: YES
Compiler for C supports arguments -Wpointer-arith: YES
Compiler for C supports arguments -Wredundant-decls: YES
Compiler for C supports arguments -Wstrict-prototypes: YES
Compiler for C supports arguments -Wswitch-default: YES
Compiler for C supports arguments -Wswitch-enum: YES
Compiler for C supports arguments -Wundef: YES
Compiler for C supports arguments -Wuninitialized: YES
Compiler for C supports arguments -Wunused: YES
Compiler for C supports arguments -fno-strict-aliasing: YES
Compiler for C supports arguments -Werror=format-security -Werror=format=2: YES
Compiler for C supports arguments -fstack-protector-strong: YES
Program msgfmt found: YES (/usr/bin/msgfmt)
Program desktop-file-validate found: YES (/usr/bin/desktop-file-validate)
Program appstream-util found: NO
Program glib-compile-schemas found: YES (/usr/bin/glib-compile-schemas)
Program ecpg found: YES (/usr/bin/ecpg)
Found pkg-config: /usr/bin/pkg-config (1.8.1)
Run-time dependency gtk4 found: YES 4.10.4
Run-time dependency libadwaita-1 found: YES 1.3.3
Found pkg-config: /usr/bin/pkg-config (1.8.1)
Program glib-compile-resources found: YES (/usr/bin/glib-compile-resources)
Program msginit found: YES (/usr/bin/msginit)
Program msgmerge found: YES (/usr/bin/msgmerge)
Program xgettext found: YES (/usr/bin/xgettext)
Build-time dependency gio-2.0 found: YES 2.76.1
Program glib-compile-schemas found: YES (/usr/lib/x86_64-linux-gnu/glib-2.0/glib-compile-schemas)
Program gtk4-update-icon-cache found: YES (/usr/bin/gtk4-update-icon-cache)
Program update-desktop-database found: YES (/usr/bin/update-desktop-database)
Build targets in project: 8
Found ninja-1.11.1 at /usr/bin/ninja
marcotc@qvaliz23:~/Projetos/teste_gtk$ cd build
marcotc@qvaliz23:~/Projetos/teste_gtk/build$ ninja
[6/9] Compiling C object src/teste_gtk.p/main.c.o
main.pgc: In function âmainâ:
main.pgc:71:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
[9/9] Linking target src/teste_gtk
As you can see in this case meson finds ecpg.
I tried with execute_command running a shell script but it seems inside builder meson can only find programs in the source dir nothing outside the src dir works. And again it works fine if I donât use gnome-builder .