{"record":{"id":"b71a4f4272b2cd7f","repo":"apache/maven","slug":"the-goal-you-specified-requires-a-project-to-execu","errorCode":null,"errorMessage":"The goal you specified requires a project to execute but there is no POM in this directory ({}). Please verify you invoked Maven from the correct directory.","messagePattern":"The goal you specified requires a project to execute but there is no POM in this directory \\((.+?)\\)\\. Please verify you invoked Maven from the correct directory\\.","errorType":"exception","errorClass":"MissingProjectException","httpStatus":null,"severity":"error","filePath":"impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleStarter.java","lineNumber":86,"sourceCode":"        this.eventCatapult = eventCatapult;\n        this.defaultLifeCycles = defaultLifeCycles;\n        this.buildListCalculator = buildListCalculator;\n        this.lifecycleDebugLogger = lifecycleDebugLogger;\n        this.lifecycleTaskSegmentCalculator = lifecycleTaskSegmentCalculator;\n        this.builders = builders;\n    }\n\n    @Override\n    public void execute(MavenSession session) {\n        eventCatapult.fire(ExecutionEvent.Type.SessionStarted, session, null);\n\n        ReactorContext reactorContext = null;\n        ProjectBuildList projectBuilds = null;\n        MavenExecutionResult result = session.getResult();\n\n        try {\n            if (buildExecutionRequiresProject(session) && projectIsNotPresent(session)) {\n                throw new MissingProjectException(\"The goal you specified requires a project to execute\"\n                        + \" but there is no POM in this directory (\" + session.getExecutionRootDirectory() + \").\"\n                        + \" Please verify you invoked Maven from the correct directory.\");\n            }\n\n            List<TaskSegment> taskSegments = lifecycleTaskSegmentCalculator.calculateTaskSegments(session);\n            projectBuilds = buildListCalculator.calculateProjectBuilds(session, taskSegments);\n\n            if (projectBuilds.isEmpty()) {\n                throw new NoGoalSpecifiedException(\"No goals have been specified for this build.\"\n                        + \" You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or\"\n                        + \" <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>.\"\n                        + \" Available lifecycle phases are: \" + defaultLifeCycles.getLifecyclePhaseList() + \".\");\n            }\n\n            if (logger.isDebugEnabled()) {\n                lifecycleDebugLogger.debugReactorPlan(projectBuilds);\n            }\n","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleStarter.java#L68-L104","documentation":"DefaultLifecycleStarter.execute() throws MissingProjectException before any task calculation when the requested tasks require a project but session.getRequest().isProjectPresent() is false — i.e., Maven was started in a directory containing no pom.xml (and none supplied with -f/-p). The directory printed is the execution root directory.","triggerScenarios":"Running 'mvn package' (or any project-requiring goal) in a folder without a pom.xml; running from a parent folder assuming the reactor will find child POMs; -f pointing at a directory or file that does not exist so no project got loaded.","commonSituations":"Wrong terminal/cwd when launching Maven; CI checking out a subdirectory but running the build from the workspace root; scripts run in $HOME or /tmp; POM named something other than pom.xml without -f.","solutions":["cd into the directory that contains pom.xml and re-run","Or point Maven at the POM explicitly: mvn -f /path/to/project/pom.xml package","If the goal genuinely needs no project (e.g. archetype:generate from scratch), verify its name — most core phases do require one","In CI, assert the POM exists before invoking Maven"],"exampleFix":"# before\ncd /tmp && mvn package   # no pom.xml in /tmp\n\n# after\ncd /path/to/project && mvn package\n# or: mvn -f /path/to/project/pom.xml package","handlingStrategy":"validation","validationCode":"// guard scripts/embedders before invoking\nif (!Files.exists(rootDir.resolve(\"pom.xml\"))) {\n    throw new IllegalStateException(\"No pom.xml in \" + rootDir + \" - cd or use -f\");\n}","typeGuard":null,"tryCatchPattern":"catch (MissingProjectException e) {\n    // message names the offending directory; switch cwd or add -f and retry\n}","preventionTips":["Always invoke Maven with an explicit -f path in CI scripts","Assert pom.xml existence in pipeline pre-steps","Set projectless goals apart from project builds in scripts"],"tags":["maven","cli","missing-pom","cwd","project-required"],"backgroundTag":"no-pom-in-directory","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}