Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom_target: install:true without install_dir crashes #9522

Closed
mon opened this issue Nov 2, 2021 · 1 comment · Fixed by #9523
Closed

custom_target: install:true without install_dir crashes #9522

mon opened this issue Nov 2, 2021 · 1 comment · Fixed by #9523
Milestone

Comments

@mon
Copy link
Contributor

mon commented Nov 2, 2021

Describe the bug
When defining a custom_target with install:true, meson build will crash. If install_dir is provided, build works as expected.

Traceback:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/mesonbuild/mesonmain.py", line 138, in run
    return options.run_func(options)
  File "/usr/local/lib/python3.8/dist-packages/mesonbuild/msetup.py", line 294, in run
    app.generate()
  File "/usr/local/lib/python3.8/dist-packages/mesonbuild/msetup.py", line 185, in generate
    self._generate(env)
  File "/usr/local/lib/python3.8/dist-packages/mesonbuild/msetup.py", line 247, in _generate
    intr.backend.generate()
  File "/usr/local/lib/python3.8/dist-packages/mesonbuild/backend/ninjabackend.py", line 557, in generate
    self.generate_install()
  File "/usr/local/lib/python3.8/dist-packages/mesonbuild/backend/ninjabackend.py", line 1120, in generate_install
    self.create_install_data_files()
  File "/usr/local/lib/python3.8/dist-packages/mesonbuild/backend/backends.py", line 1495, in create_install_data_files
    pickle.dump(self.create_install_data(), ofile)
  File "/usr/local/lib/python3.8/dist-packages/mesonbuild/backend/backends.py", line 1483, in create_install_data
    self.generate_target_install(d)
  File "/usr/local/lib/python3.8/dist-packages/mesonbuild/backend/backends.py", line 1627, in generate_target_install
    dir_name = os.path.join('{prefix}', outdir)
  File "/usr/lib/python3.8/posixpath.py", line 90, in join
    genericpath._check_arg_types('join', a, *p)
  File "/usr/lib/python3.8/genericpath.py", line 152, in _check_arg_types
    raise TypeError(f'{funcname}() argument must be str, bytes, or '
TypeError: join() argument must be str, bytes, or os.PathLike object, not 'NoneType'

To Reproduce

project('test')

custom_target(
    output: 'bug.txt',
    install: true,
    capture: true,
    command: ['echo', 'foobar']
)

Expected behavior
Either an error of some sort ("install:true requires install_dir to be set") or default fallback (install_dir: '.' ??)

system parameters

  • Native build
  • Ubuntu 20.04
  • Python 3.8.10
  • Using the commit at time of bug report: d23ae8b
  • Ninja 1.10.0
@eli-schwartz
Copy link
Member

This happens because some code, but not all code, is migrated to use typed_kwargs. And the CustomTarget implementation just emits the relevant error if install_dir is not in the kwargs, but it might be passed and not truthy.

Seems like a simple solution.

eli-schwartz added a commit to eli-schwartz/meson that referenced this issue Nov 3, 2021
It's supposed to emit an error message, but instead it did a traceback.
It used to be, if no install_dir was specified then it was simply not in
kwargs, but due to typed_kwargs it will now be there, but not have
viable contents, so the dict membership check got skipped.

Fixes mesonbuild#9522
dcbaker pushed a commit that referenced this issue Nov 3, 2021
It's supposed to emit an error message, but instead it did a traceback.
It used to be, if no install_dir was specified then it was simply not in
kwargs, but due to typed_kwargs it will now be there, but not have
viable contents, so the dict membership check got skipped.

Fixes #9522
@eli-schwartz eli-schwartz added this to the 0.60.2 milestone Nov 3, 2021
nirbheek pushed a commit that referenced this issue Nov 25, 2021
It's supposed to emit an error message, but instead it did a traceback.
It used to be, if no install_dir was specified then it was simply not in
kwargs, but due to typed_kwargs it will now be there, but not have
viable contents, so the dict membership check got skipped.

Fixes #9522
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants