diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py
index 1aca9c61a..011ac14b1 100644
--- a/mesonbuild/mesonmain.py
+++ b/mesonbuild/mesonmain.py
@@ -41,8 +41,8 @@ def create_parser():
                    help='Special wrap mode to use')
     p.add_argument('--profile-self', action='store_true', dest='profile',
                    help=argparse.SUPPRESS)
-    p.add_argument('builddir', nargs='?', default='..')
-    p.add_argument('sourcedir', nargs='?', default='.')
+    p.add_argument('builddir', nargs='?', default=None)
+    p.add_argument('sourcedir', nargs='?', default=None)
     return p
 
 def wrapmodetype(string):
@@ -331,6 +331,15 @@ def run(original_args, mainfile):
     dir1 = options.builddir
     dir2 = options.sourcedir
     try:
+        if dir1 is None:
+            if dir2 is None:
+                if not os.path.exists('meson.build') and os.path.exists('../meson.build'):
+                    dir2 = '..'
+                else:
+                    raise MesonException('Must specify at least one directory name.')
+            dir1 = os.getcwd()
+        if dir2 is None:
+            dir2 = os.getcwd()
         app = MesonApp(dir1, dir2, handshake, options)
     except Exception as e:
         # Log directory does not exist, so just print

Running `meson` in the source dir without any arguments takes the parent directory as the build dir
This is a major regression over 0.46. The parent dir implicit selection should only be for finding the source directory, not the build directory.
diff --git a/run_unittests.py b/run_unittests.py
index 4a47d5eab..df4603e3a 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -2406,6 +2406,24 @@ recommended as it is not supported on some platforms''')
             self.assertEqual(f.read().strip(), b'')
         self.assertRegex(out, r"DEPRECATION:.*\['array'\] is invalid.*dict")
 
+    def test_dirs(self):
+        with tempfile.TemporaryDirectory() as containing:
+            with tempfile.TemporaryDirectory(dir=containing) as srcdir:
+                mfile = os.path.join(srcdir, 'meson.build')
+                of = open(mfile, 'w')
+                of.write("project('foobar', 'c')\n")
+                of.close()
+                pc = subprocess.run(self.setup_command,
+                                    cwd=srcdir,
+                                    stdout=subprocess.PIPE,
+                                    stderr=subprocess.DEVNULL)
+                self.assertIn(b'Must specify at least one directory name', pc.stdout)
+                with tempfile.TemporaryDirectory(dir=srcdir) as builddir:
+                    subprocess.run(self.setup_command,
+                                   check=True,
+                                   cwd=builddir,
+                                   stdout=subprocess.DEVNULL,
+                                   stderr=subprocess.DEVNULL)
 
 class FailureTests(BasePlatformTests):
     '''

pip install -e .
parse_log_pytest
pytest
pytest
apt-get update apt-get install -y ninja-build
3.9
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
exceptiongroup @ file:///croot/exceptiongroup_1706031385326/work
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
-e git+https://github.com/mesonbuild/meson.git@8cfb8fd02c86e1667ded9a7841d77204f96a4a6d#egg=meson
packaging @ file:///croot/packaging_1734472117206/work
pluggy @ file:///croot/pluggy_1733169602837/work
pytest @ file:///croot/pytest_1738938843180/work
tomli @ file:///opt/conda/conda-bld/tomli_1657175507142/work

name: meson
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - exceptiongroup=1.2.0=py39h06a4308_0
  - iniconfig=1.1.1=pyhd3eb1b0_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - packaging=24.2=py39h06a4308_0
  - pip=25.0=py39h06a4308_0
  - pluggy=1.5.0=py39h06a4308_0
  - pytest=8.3.4=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tomli=2.0.1=py39h06a4308_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
prefix: /opt/conda/envs/meson

run_unittests.py::AllPlatformTests::test_dirs
run_unittests.py::AllPlatformTests::test_absolute_prefix_libdir run_unittests.py::AllPlatformTests::test_always_prefer_c_compiler_for_asm run_unittests.py::AllPlatformTests::test_check_module_linking run_unittests.py::AllPlatformTests::test_compiler_detection run_unittests.py::AllPlatformTests::test_compiler_options_documented run_unittests.py::AllPlatformTests::test_default_options_prefix run_unittests.py::AllPlatformTests::test_preprocessor_checks_CPPFLAGS run_unittests.py::AllPlatformTests::test_templates run_unittests.py::FailureTests::test_boost_BOOST_ROOT_dependency run_unittests.py::FailureTests::test_boost_notfound_dependency run_unittests.py::FailureTests::test_dependency_invalid_method run_unittests.py::FailureTests::test_gnustep_notfound_dependency run_unittests.py::FailureTests::test_llvm_dependency run_unittests.py::FailureTests::test_sdl2_notfound_dependency run_unittests.py::FailureTests::test_using_recent_feature run_unittests.py::FailureTests::test_using_too_recent_feature run_unittests.py::FailureTests::test_using_too_recent_feature_dependency run_unittests.py::FailureTests::test_wx_notfound_dependency run_unittests.py::WindowsTests::test_find_program run_unittests.py::WindowsTests::test_rc_depends_files run_unittests.py::LinuxlikeTests::test_build_rpath run_unittests.py::LinuxlikeTests::test_compiler_check_flags_order run_unittests.py::LinuxlikeTests::test_compiler_cpp_stds run_unittests.py::LinuxlikeTests::test_cpp_std_override run_unittests.py::LinuxlikeTests::test_order_of_l_arguments run_unittests.py::LinuxArmCrossCompileTests::test_cflags_cross_environment_pollution run_unittests.py::LinuxArmCrossCompileTests::test_cross_file_overrides_always_args run_unittests.py::RewriterTests::test_basic run_unittests.py::RewriterTests::test_subdir
run_unittests.py::InternalTests::test_compiler_args_class run_unittests.py::InternalTests::test_extract_as_list run_unittests.py::InternalTests::test_find_library_patterns run_unittests.py::InternalTests::test_listify run_unittests.py::InternalTests::test_mode_symbolic_to_bits run_unittests.py::InternalTests::test_needs_exe_wrapper_override run_unittests.py::InternalTests::test_pkgconfig_module run_unittests.py::InternalTests::test_snippets run_unittests.py::InternalTests::test_string_templates_substitution run_unittests.py::InternalTests::test_version_number run_unittests.py::AllPlatformTests::test_all_forbidden_targets_tested run_unittests.py::AllPlatformTests::test_array_option_bad_change run_unittests.py::AllPlatformTests::test_array_option_change run_unittests.py::AllPlatformTests::test_array_option_empty_equivalents run_unittests.py::AllPlatformTests::test_build_by_default run_unittests.py::AllPlatformTests::test_command_line run_unittests.py::AllPlatformTests::test_compiler_run_command run_unittests.py::AllPlatformTests::test_configure_file_warnings run_unittests.py::AllPlatformTests::test_conflicting_d_dash_option run_unittests.py::AllPlatformTests::test_cpu_families_documented run_unittests.py::AllPlatformTests::test_cross_file_system_paths run_unittests.py::AllPlatformTests::test_custom_target_changes_cause_rebuild run_unittests.py::AllPlatformTests::test_custom_target_exe_data_deterministic run_unittests.py::AllPlatformTests::test_dash_d_dedup run_unittests.py::AllPlatformTests::test_default_options_prefix_dependent_defaults run_unittests.py::AllPlatformTests::test_dist_git run_unittests.py::AllPlatformTests::test_dist_hg run_unittests.py::AllPlatformTests::test_feature_check_usage_subprojects run_unittests.py::AllPlatformTests::test_flock run_unittests.py::AllPlatformTests::test_forcefallback run_unittests.py::AllPlatformTests::test_free_stringarray_setting run_unittests.py::AllPlatformTests::test_guessed_linker_dependencies run_unittests.py::AllPlatformTests::test_identical_target_name_in_subdir_flat_layout run_unittests.py::AllPlatformTests::test_identical_target_name_in_subproject_flat_layout run_unittests.py::AllPlatformTests::test_install_introspection run_unittests.py::AllPlatformTests::test_internal_include_order run_unittests.py::AllPlatformTests::test_libdir_must_be_inside_prefix run_unittests.py::AllPlatformTests::test_markdown_files_in_sitemap run_unittests.py::AllPlatformTests::test_ndebug_if_release_disabled run_unittests.py::AllPlatformTests::test_ndebug_if_release_enabled run_unittests.py::AllPlatformTests::test_permitted_method_kwargs run_unittests.py::AllPlatformTests::test_prebuilt_object run_unittests.py::AllPlatformTests::test_prebuilt_shared_lib run_unittests.py::AllPlatformTests::test_prebuilt_static_lib run_unittests.py::AllPlatformTests::test_prefix_dependent_defaults run_unittests.py::AllPlatformTests::test_rpath_uses_ORIGIN run_unittests.py::AllPlatformTests::test_run_target_files_path run_unittests.py::AllPlatformTests::test_same_d_option_twice run_unittests.py::AllPlatformTests::test_same_d_option_twice_configure run_unittests.py::AllPlatformTests::test_same_dash_option_twice run_unittests.py::AllPlatformTests::test_same_dash_option_twice_configure run_unittests.py::AllPlatformTests::test_same_project_d_option_twice run_unittests.py::AllPlatformTests::test_same_project_d_option_twice_configure run_unittests.py::AllPlatformTests::test_source_changes_cause_rebuild run_unittests.py::AllPlatformTests::test_static_compile_order run_unittests.py::AllPlatformTests::test_static_library_lto run_unittests.py::AllPlatformTests::test_static_library_overwrite run_unittests.py::AllPlatformTests::test_subproject_promotion run_unittests.py::AllPlatformTests::test_suite_selection run_unittests.py::AllPlatformTests::test_testsetup_selection run_unittests.py::AllPlatformTests::test_uninstall run_unittests.py::AllPlatformTests::test_warning_location run_unittests.py::FailureTests::test_dict_forbids_duplicate_keys run_unittests.py::FailureTests::test_dict_forbids_integer_key run_unittests.py::FailureTests::test_dict_requires_key_value_pairs run_unittests.py::FailureTests::test_exception_exit_status run_unittests.py::FailureTests::test_objc_cpp_detection run_unittests.py::FailureTests::test_subproject_variables run_unittests.py::LinuxlikeTests::test_basic_soname run_unittests.py::LinuxlikeTests::test_compiler_c_stds run_unittests.py::LinuxlikeTests::test_cross_find_program run_unittests.py::LinuxlikeTests::test_custom_soname run_unittests.py::LinuxlikeTests::test_install_umask run_unittests.py::LinuxlikeTests::test_installed_modes run_unittests.py::LinuxlikeTests::test_installed_modes_extended run_unittests.py::LinuxlikeTests::test_installed_soname run_unittests.py::LinuxlikeTests::test_pch_with_address_sanitizer run_unittests.py::LinuxlikeTests::test_pic run_unittests.py::LinuxlikeTests::test_pkg_unfound run_unittests.py::LinuxlikeTests::test_reconfigure run_unittests.py::LinuxlikeTests::test_run_installed run_unittests.py::LinuxlikeTests::test_soname run_unittests.py::LinuxlikeTests::test_unity_subproj
mesonbuild/mesonmain.py
mesonbuild/mesonmain.py