Skip to content

declare_dependency variable's value cannot be an unstatable file #13584

Open
@Ericson2314

Description

@Ericson2314

Describe the bug

The declare_dependency extra variable logic does not work with strings that are unreadable files, at least on macOS.

To Reproduce

Given /absolute/path/to/disallowed is a directory without permission to read (I tried chmod 000)

project('foo')

declare_dependency(
  variables: {
    'foo': '/absolute/path/to/disallowed/cant-look-inside-at-me'
  }
)

I get

  File "/nix/store/5s1iy38gicvf90a9k0dn0b2x1kb072zm-meson-1.4.2/lib/python3.11/site-packages/mesonbuild/mesonmain.py", line 270, in run
    return msetup.run(['--reconfigure'] + args[2:])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/5s1iy38gicvf90a9k0dn0b2x1kb072zm-meson-1.4.2/lib/python3.11/site-packages/mesonbuild/msetup.py", line 363, in run
    app.generate()
  File "/nix/store/5s1iy38gicvf90a9k0dn0b2x1kb072zm-meson-1.4.2/lib/python3.11/site-packages/mesonbuild/msetup.py", line 187, in generate
    return self._generate(env, capture, vslite_ctx)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/5s1iy38gicvf90a9k0dn0b2x1kb072zm-meson-1.4.2/lib/python3.11/site-packages/mesonbuild/msetup.py", line 226, in _generate
    intr.run()
  File "/nix/store/5s1iy38gicvf90a9k0dn0b2x1kb072zm-meson-1.4.2/lib/python3.11/site-packages/mesonbuild/interpreter/interpreter.py", line 3011, in run
    super().run()
  File "/nix/store/5s1iy38gicvf90a9k0dn0b2x1kb072zm-meson-1.4.2/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 162, in run
    self.evaluate_codeblock(self.ast, start=1)
  File "/nix/store/5s1iy38gicvf90a9k0dn0b2x1kb072zm-meson-1.4.2/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 188, in evaluate_codeblock
    raise e
  File "/nix/store/5s1iy38gicvf90a9k0dn0b2x1kb072zm-meson-1.4.2/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 180, in evaluate_codeblock
    self.evaluate_statement(cur)
  File "/nix/store/5s1iy38gicvf90a9k0dn0b2x1kb072zm-meson-1.4.2/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 194, in evaluate_statement
    return self.function_call(cur)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/5s1iy38gicvf90a9k0dn0b2x1kb072zm-meson-1.4.2/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 520, in function_call
    res = func(node, func_args, kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/5s1iy38gicvf90a9k0dn0b2x1kb072zm-meson-1.4.2/lib/python3.11/site-packages/mesonbuild/interpreterbase/decorators.py", line 53, in wrapped
    return f(*wrapped_args, **wrapped_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/5s1iy38gicvf90a9k0dn0b2x1kb072zm-meson-1.4.2/lib/python3.11/site-packages/mesonbuild/interpreterbase/decorators.py", line 569, in wrapper
    return f(*wrapped_args, **wrapped_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/5s1iy38gicvf90a9k0dn0b2x1kb072zm-meson-1.4.2/lib/python3.11/site-packages/mesonbuild/interpreter/interpreter.py", line 714, in func_declare_dependency
    if p.is_absolute() and p.is_dir() and srcdir / self.root_subdir in [p] + list(Path(os.path.abspath(p)).parents):
                           ^^^^^^^^^^
  File "/nix/store/7m3ii30148dwjmfvl9w0m51idnv3y91m-python3-3.11.9/lib/python3.11/pathlib.py", line 1250, in is_dir
    return S_ISDIR(self.stat().st_mode)
                   ^^^^^^^^^^^
  File "/nix/store/7m3ii30148dwjmfvl9w0m51idnv3y91m-python3-3.11.9/lib/python3.11/pathlib.py", line 1013, in stat
    return os.stat(self, follow_symlinks=follow_symlinks)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
PermissionError: [Errno 13] Permission denied: '/Users/jcericson/src/nix/build/secret/asdf'

ERROR: Unhandled python OSError. This is probably not a Meson bug, but an issue with your build environment.

Expected behavior

Variable works, can be queried later.

*system parameters

Meson 1.4.2 on macOS

$ sw_vers
ProductName:		macOS
ProductVersion:		13.4.1
BuildVersion:		22F82

Metadata

Metadata

Assignees

Labels

bugexceptionMajor bug that raises a python-level exceptionpathlibupgrading to/downgrading from pathlib.Path--including temporary workarounds for older Python

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions