Error "The goal you specified requires a project to execute but there is no POM in this directory" after executing maven command
Asked Answered
L

21

170

I have a pom.xml in C:\Users\AArmijos\Desktop\Factura Electronica\MIyT\componentes-1.0.4\sources\pom.xml and I executed:

mvn install:install-file -DgroupId=es.mityc.jumbo.adsi -DartifactId=xmlsec-1.4.2-ADSI -Dversion=1.0 -Dpackaging=jar -Dfile=C:\Users\AArmijos\Desktop\Factura Electronica\MIyT\componentes-1.0.4\core\xmlsec-1.4.2-ADSI-1.0.jar

however it returned the error below:

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.310s
[INFO] Finished at: Thu May 02 16:48:29 COT 2013
[INFO] Final Memory: 2M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM
 in this directory (C:\Users\AArmijos). Please verify you invoked Maven from the
 correct directory. -> [Help 1]

Can someone explain why it fails?

Lueluebke answered 2/5, 2013 at 22:1 Comment(6)
Did you check here? maven.apache.org/plugins/maven-install-plugin/usage.html your template appears to be invalid. I see that .jar file come at first argument.Conspire
yes, this command is run correctly on another pc but I can not on my pc, I installed the latest version of jdk and mavenLueluebke
Ok now I see the error better. Do you have a pom.xml in this folder that you call mvn install-install-file? If you have, can you update your question?Conspire
Yes, I have a pom.xmlLueluebke
Can you post in your question please?Conspire
putting every parameter in side double qoute resolved my issue.Helotry
L
292

This link helped: https://mcmap.net/q/145040/-maven-generating-pom-file

I edit my command by adding quotes for every parameter like this:

mvn install:install-file "-DgroupId=org.mozilla" "-DartifactId=jss" "-Dversion=4.2.5" "-Dpackaging=jar" "-Dfile=C:\Users\AArmijos\workspace\componentes-1.0.4\deps\jss-4.2.5.jar"

It's worked.

Lueluebke answered 2/5, 2013 at 23:1 Comment(5)
Since when do I need quotes? I am so puzzled right now, and relieved to finally find an answer to such a rubbish error message ...Ferrer
I faced similar issue when doing deploy:deploy-file, but my issue was I just missed the dash ("-") in front of one of the options.Kibler
If you're in powershell, you can visually see how PowerShell is separating arguments with the colors on the command line, or by putting "echo" in front of the command. Like, "echo mvn install:install-file...".Crush
In earlier version of maven, I never used to provide the double-quotes. But, now it doesn't work without it. this solved my issue.Otology
This happens due to having spaces in the folder paths. Adding quotes solves the issue or you can just rename the folders having spaces with under-scores or something.Glenda
S
81

For any of those who are experiencing this on Windows and none of the above worked, try running this from cmd.exe. Executing these commands via PowerShell caused the install to fail each time.

Superstar answered 19/8, 2015 at 0:45 Comment(5)
Same issue, Powershell and CMD argument handling work differently and seem to be confusing MVNSemipalmate
Was following Maven's Getting Started guide and trying to execute "mvn -B archetype:generate ....." on Windows PowerShell and was getting similar error. Switching to different command line client (mintty git bash) solved the problem.Delusion
In PowerShell the . operator is significant because it's used for object property/method access as with most other .NET languages. If you have dots in the args generally I've quoted these in the past in order to get PowerShell to treat them as literal strings.Sheikh
Instead of the example for creating a project ``` mvn -B archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 ``` with quotes in PS this worked ``` mvn -B archetype:generate -DgroupId="com.mycompany.app" -DartifactId="my-app" -DarchetypeArtifactId="maven-archetype-quickstart" -DarchetypeVersion="1.4" ```Nicolis
Damn you made my day. I'm beginning with Maven and was already struggling because my VSCode opens a powershell by default x)Refill
M
65

On Windows when you are using PowerShell you have to enclose all parameters with quotes.

So if you want to create a maven webapp archetype you would do as follows:

Prerequisites:

  1. Make sure you have maven installed and have it in your PATH environment variable.

Howto:

  1. Open windows powershell
  2. mkdir MyWebApp
  3. cd MyWebApp
  4. mvn archetype:generate "-DgroupId=com.javan.dev" "-DartifactId=MyWebApp" "-DarchetypeArtifactId=maven-archetype-webapp" "-DinteractiveMode=false"

enter image description here

Note: This is tested only on windows 10 powershell

Multitudinous answered 20/10, 2017 at 8:56 Comment(2)
Verified on Mac OS X. Also, for dprowizard java-simple you can use the following command: mvn archetype:generate "-DarchetypeGroupId=io.dropwizard.archetypes" "-DarchetypeArtifactId=java-simple" with interactive mode or with extra parameters.Tangleberry
same problem exists also on command prompt. enclosing parameter values within quotes is the real solution.Falcate
R
16

Adding one more answer for Windows users. If none of this solves the problems.

Do not add space before or after =

-DgroupId= com.company.module //Wrong , Watch the space after the equal to 
-DgroupId=com.company.module //Right 

Its better to put everything inside double quotes, like "-DgroupId=com.." This will give you exact error rather than some random error.

Weird that , maven does not even care to mention this in the documentation.

Result answered 22/3, 2017 at 5:33 Comment(1)
your solution worked , I put all the -D section within ""... it's really amazing that product so poorly engineered and ill-coded like Maven has managed to become so popular...Information
S
9

In my case, its because I copied pasted the command from the browser and it turned out that the dash was not the ASCII dash, just delete and type the dash again.

http://www.toptip.ca/2017/04/maven-most-weird-error-causing-failure.html

Staffman answered 7/2, 2018 at 7:57 Comment(0)
N
9

Totally true. When using PowerShell, you need to put quotes.
I run the command and put quotes around the parameters that have a dot, this works.
Instead of typing 1.4, you should type "1.4".

First time:

mvn archetype:generate 
   -DgroupId=com.mycompany.app 
   -DartifactId=my-app 
   -DarchetypeArtifactId=maven-archetype-quickstart 
   -DarchetypeVersion=1.4 -DinteractiveMode=false
Error:
[ERROR] The goal you specified requires a project to execute 
but there is no POM in this directory 
(C:\Users\jcrojas\OneDrive - Superfinanciera\Personal\Aprendizaje\Maven\test). 
Please verify you invoked Maven from the correct directory. -> [Help 1]

Second time:

mvn archetype:generate 
   -DgroupId=**"com.mycompany.app"** 
   -DartifactId=my-app 
   -DarchetypeArtifactId=maven-archetype-quickstart 
   -DarchetypeVersion=**"1.4"** 
   -DinteractiveMode=false

...BUILD SUCCESS...

The command also works if it is run with the Windows command line, CMD.
In this case, the quotation marks are not necessary.

Norite answered 9/9, 2022 at 22:47 Comment(1)
Thanks Juan. Your double quotes one tip helped me to solve my issue.Carouse
F
4

I was trying to install java jms-1.1.jar after downloading a copy from jboss repository.

Encountered exact same error and specifically on windows. Tried everything i.e. changed maven version / jdk version but no avail.

I was using the command below .

mvn install:install-file -DgroupId=javax.jms -DartifactId=jms -Dversion=1.1 -Dpackaging=jar -Dfile=jms-1.1.jar

Finally took a que from the comment in the main question and put every parameter value within double quotes

mvn install:install-file -DgroupId="javax.jms" -DartifactId="jms" -Dversion="1.1" -Dpackaging="jar" -Dfile="jms-1.1.jar"

This solved the problem. The issue seems very specific to windows environment. On ubuntu and mac the command works without any issues.

Falcate answered 27/12, 2021 at 5:41 Comment(1)
Some other answers and posts suggest to use a variation of the jar from apache but since the artifact ids are different its not really a solution.Falcate
T
2

In windows don't use powershell use cmd and it will work.

Tuque answered 3/9, 2023 at 11:36 Comment(0)
E
1

Changing mvn clean to mvn clean --file *.pom fixed this issue for me.

Erased answered 12/9, 2015 at 6:58 Comment(0)
C
1

On Windows, I got this error when running under a non-administrator command prompt. When I ran this as administrator, the error went away.

Crosswind answered 27/10, 2015 at 23:41 Comment(1)
Potentially you were running non-administrator under PowerShell and CMD for administrator so that the real difference was whether it was being run in PowerShell or not.Sheikh
U
1

1.create a lib folder in your project file,

2.copy your jarFiles to the lib folder

3.right click on to your jarFile go to build path>Add to build path (now your jar file is part of your refrerenced libraries )

4.open command prompt and navigate to your project directory and write

mvn install: install-file "-Dfile=<yourJarFileName>.jar" "-DgroupId=<yourGroupID>" "-DartifactId=<yourArtifactId>" "-Dversion=<yourVersion>" "-Dpackaging=jar" 

6.Rebuild your local repository index by opening in eclipse- go to window>show view>other>maven>maven Repositories. Right click on local Repositores and hit "RebuildIndex"

5.open your pom.xml file and add your dependency

    <dependency>
        <groupId><yourGroupID></groupId>
        <artifactId><yourArtifactId></artifactId>
        <version><yourVersion></version>
    </dependency>

and run

mvn clean
mvn compile 
mvn test 
Ultann answered 4/8, 2016 at 14:46 Comment(1)
I've been wondering how a simple maven command would be failing... I came up with your solution and voila! It worked! Nobody was writing the java params within the ", which was what I was missing. Thank you very much :)Annisannissa
C
0

I got this error suddenly in Netbeans (but it worked from the command line) and it turns out some other program had changed the default directory of the command prompt. And because Netbeans runs "cmd /c" when invoking maven, it starts in an incorrect directory.

Check out in Regedit the value for

HKEY_CURRENT_USER\Software\Microsoft\Command Processor\Autorun  

If it has been set, you probably should remove it to fix the problem. (1)

(I landed here when trying to resolve this issue, might not be 100% applicable to the current question - but might help others)

(1) Changing default startup directory for command prompt in Windows 7

Chesterfield answered 2/4, 2016 at 18:2 Comment(0)
P
0
  • The execution of maven command required pom.xml file that contains information about the project and configuration details used by Maven to build the project. It contains default values for most projects.

  • Make sure that porject should contains pom.xml at the root level.

Plano answered 20/10, 2017 at 11:0 Comment(0)
K
0

Add the Jenkinsfile where the pom.xml file has present. Provide the directory path on dir('project-dir'),

Ex:

node {

    withMaven(maven:'maven') {

        stage('Checkout') {
            git url: 'http://xxxxxxx/gitlab/root/XXX.git', credentialsId: 'xxxxx', branch: 'xxx'
        }

        stage('Build') {

            **dir('project-dir') {**
                sh 'mvn clean install'

                def pom = readMavenPom file:'pom.xml'

                print pom.version
                env.version = pom.version
            }
        }
    }
}
Klenk answered 9/7, 2018 at 11:46 Comment(0)
P
0

There may be a problem with Maven path configuration, if you used unix-like Operator System.

step 1: create new file in path ~/.bash_profile

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home
CLASSPAHT=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
PATH=$JAVA_HOME/bin:$PATH:
export JAVA_HOME
export CLASSPATH
export PATH

step 2: shell run source ~/.bash_profile OR modify zsh config file(add new line: source ~/.bash_profile)

Parquetry answered 15/7, 2020 at 7:11 Comment(0)
V
0

Just watch out for any spaces or errors in your arguments/command. The mvn error message may not be so descriptive but I have realised, usually spaces/omissions can also cause that error.

Valverde answered 27/12, 2020 at 11:49 Comment(0)
T
0

I just added the path to the pom.xml as such mvn -f path/to/pom.xml <goals> ... Worked great for me

Trilinear answered 26/7, 2022 at 15:56 Comment(0)
C
0

There could be some special characters added to your command like the '-' U+2013 and U+002d

Please remove the special characters and try the command

Coronet answered 22/8, 2022 at 10:24 Comment(0)
N
-1

"The goal you specified requires a project to execute": The answer is in your question. I faced the same issue. Run the "mvn command" within the project folder, Also make sure sure its a maven configured project and hence contains the "POM.xml" file and you should be good to go!

Numeration answered 30/3, 2016 at 17:39 Comment(1)
This command is to install local 3rd party jar. We dont have the project source code with usResult
P
-1

Check for the name of the file, i.e pom.xml file is spelled correctly with proper file extension .xml.

Example for this error are

pom.ml pm.xl

Pervert answered 13/4, 2020 at 6:33 Comment(0)
D
-3

Please run it from the directory where POM.XML resides.

Dyanne answered 28/1, 2014 at 0:46 Comment(2)
Downvoted because the install:install-file goal doesn't need to be (can't?) run on a project. It's used for manually installing an artifact into a repository.Lennielenno
I am trying to upload a zip file that has no Pom xml. downvotedWhitneywhitson

© 2022 - 2024 — McMap. All rights reserved.