grails / grails-core

The Grails Web Application Framework
http://grails.org
Apache License 2.0
2.79k stars 949 forks source link

Error occurred running Grails CLI: No profile found for name [web] #10898

Closed c256985 closed 6 years ago

c256985 commented 6 years ago

After working with the project for a while, when I try to run grails from the command line, I get the following error message: Error occurred running Grails CLI: No profile found for name [web]

Since this uses the rest-api profile and not the web profile, there should be no reason for me getting this issue. Something in the project must be telling grails that this is a web project. However, I haven't been able to find any configuration variable, or any dependency that would suddenly require grails to use the web profile.

The project was created with grails 3.3.1.

Task List

Steps to Reproduce

  1. Start grails in interactive mode. (Just type "grails" at the command prompt).
  2. Error message appears.

Error occurred running Grails CLI: No profile found for name [web]. (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.) java.lang.IllegalStateException: No profile found for name [web]. at org.grails.cli.GrailsCli.initializeProfile(GrailsCli.groovy:519) at org.grails.cli.GrailsCli.initializeApplication(GrailsCli.groovy:307) at org.grails.cli.GrailsCli.execute(GrailsCli.groovy:270) at org.grails.cli.GrailsCli.main(GrailsCli.groovy:159)

Expected Behaviour

Grails should run.

If I upgrade gradle, the grails app should still run. If I upgrade grails, the app should still work. I shouldn't have to recreate the project, or do anything else except run the application, or do a clean build, or any of the normal things that every developer does. It shouldn't fail, and tell me some message that should never occur on a headless rest app.

Actual Behaviour

Tell us what happens instead

Environment Information

|Grails Version: 3.3.2 |Groovy Version: 2.4.13 |JVM Version: 1.8.0_144

Example Application

I've tried doing a gradle clean build. I've tried manually deleting the .gradle/4.4.1 directory. None of these things actually work.

jeffscottbrown commented 6 years ago

I can't reproduce this behavior. Can you please provide a sample project which demonstrates the problem?

Thanks for your feedback.

c256985 commented 6 years ago

@jeffbrown You might try creating an empty project with grails 3.3.1 and then try running it with grails 3.3.2. If that doesn't work then try building the same project with the latest version of gradle (4.4.1) and see if that does the trick.

If neither of those approaches work, let me know and I'll strip down this project and see if I can create something that reproduces this. Seeing as the error has been reported previously though, there should be some way of reproducing it.

Regards,

Mark

jeffscottbrown commented 6 years ago

You might try creating an empty project with grails 3.3.1 and then try running it with grails 3.3.2.

That wasn't able to reproduce the problem for me but even if it didn't, running a 3.3.1 app with 3.3.2 isn't supported anyway.

If that doesn't work then try building the same project with the latest version of gradle (4.4.1) and see if that does the trick.

If I have Gradle 4.4.1 on my path and start the Grails console by running grails with no args, that doesn't seem to trigger the problem.

jeffscottbrown commented 6 years ago

If neither of those approaches work, let me know and I'll strip down this project and see if I can create something that reproduces this.

If you could share a project like that, that would be a big help.

Thanks for the feedback.

puwanatfx commented 6 years ago

https://www.malcontentboffin.com/2016/12/Grails-Error-Error-occurred-running-Grails-CLI-No-profile-found-for-name-web-.html

puwanatfx commented 6 years ago

Sometimes after upgrading the version of Intelli-J that I'm using for development, when I try to run the command-line grails program, I receive the following error message:

Error occurred running Grails CLI: No profile found for name [web].

After searching around the web, I found that this was due to a problem with the build/.dependencies file located within your Grails project root. If you delete or rename this file, then run grails again, the dependencies will be corrected and you can run your app.

longwa commented 6 years ago

I'm also having a similar issue with 3.3.2. Working on updating our project from 2.5.5 and getting:

| Error Error occurred running Grails CLI: No profile found for name [web-plugin]. (Use --stacktrace to see the full trace)

This is an inline plugin that we are using. If I change application.groovy to 'web', it works. I also tested 'plugin' and it doesn't work either.

longwa commented 6 years ago

Nevermind, I found my problem. The profile in build.gradle needs to match the one in the configuration. I had copied some stuff from our webapp and forgot to change it.

    profile "org.grails.profiles:web-plugin" // needs to match the profile configured
kevintanhongann commented 6 years ago

Try and upgrade your Grails version and see if this issue persists. If it doesn't, please proceed to closing this issue right away.

So far there are no problems like this happening to me across the development of my project, and I've successfully done version migration.

spierepf commented 6 years ago

Here is an example of a project that exhibits this behaviour: https://github.com/spierepf/hms

ilopmar commented 6 years ago

Still not being able to reproduce it even with the sample project:

$ git clone git@github.com:spierepf/hms.git
Cloning into 'hms'...
remote: Counting objects: 168, done.
remote: Compressing objects: 100% (96/96), done.
remote: Total 168 (delta 39), reused 168 (delta 39), pack-reused 0
Receiving objects: 100% (168/168), 183.68 KiB | 691.00 KiB/s, done.
Resolving deltas: 100% (39/39), done.

$ cd hms
$ grails
| Resolving Dependencies. Please wait...

CONFIGURE SUCCESSFUL

| Starting interactive mode...
| Enter a command name to run. Use TAB for completion:
grails> 
c256985 commented 6 years ago

@ilopmar are you just running from the command line, or do you have the project also configured as an IDEA project?

ilopmar commented 6 years ago

I only run it from the command line. But now I've tried again cloning the repo, configuring it in IntelliJ and then executing grails on the command line. It still works.

bronoman commented 6 years ago

Problem appears to be isolated to IntelliJ (my current version is IDEA Ultimate 2017.3.4 with Grails 3.3.2). Kudos to @puwanatfx for his suggestion above on Jan 10, 2018 , this worked like a charm for me. I was also not able to reproduce this in Grails standalone or with a brandnew IntelliJ project. Suggest to close as IDE issue.

kevintanhongann commented 6 years ago

👍👍👍

On Mon, Feb 26, 2018, 8:07 PM Iván López notifications@github.com wrote:

Closed #10898 https://github.com/grails/grails-core/issues/10898.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/grails/grails-core/issues/10898#event-1491856030, or mute the thread https://github.com/notifications/unsubscribe-auth/AAV8cbqVgID7aOjC6QAKoWlojTVJ0wKHks5tYp6MgaJpZM4RPa8o .

--

Sincerely, Kevin H.A. Tan Polyglot Software Developer, Technopreneur http://about.me/kevintanhongann

+60182013739

luizcantoni commented 5 years ago

In my case this error happens on Grails 3.1.10 and the reason is because my Nexus Repository Manager was offline and Grails wasn't able to resolve dependencies. I discover that typing: "./gradlew clean"

demon101 commented 5 years ago

For me, problem was solved also by ./gradlew clean

lalitvchau commented 5 years ago

This error to due to maven was installed in you system..

follow the below steps

  1. delete the c:\Users.m2 or related directory in windows (Not sure about Unix or Mac but you can find the local cache of maven. Delete .m2 directory)
  2. delete maven related environment variable.
  3. delete ./gradlew
  4. delete environment variable related to groovy also

try to above step.. it will work fine

ntung commented 5 years ago

I got the same issue but in the context that I copied the source codes from the local machine to the server without cleaning up. I think this is the point we need to take into account. That's why someones here resolved the problem by just run clean.

joklek commented 5 years ago

I don't know if this will help anyone, but my solution was to delete the build folders and rerun the project.

digdas1 commented 4 years ago

Hi Joklek, I had the same issue (Grails 4.0.0) which I did not touch for some time, and deleting the build did solve the issue (even Intellij - grails - run - clean) did not work. Thanks

ppazos commented 4 years ago

Strange, this happened to me today, just running a project that ran OK before and getting this error.

tried ./gradlew clean and it worked, not sure what was going on.

ppazos commented 4 years ago

Tried the same project on another machine and got exactly the same error, anything grails xxx executed in the terminal terminates with the "no profile found" error. ./gradlew clean again worked.

joklek commented 4 years ago

@ppazos could you create an example repository and post it here, if you can still reproduce the issue. Also your Gradle and grails versions, your OS.

ppazos commented 4 years ago

@joklek it happened on a specific repo on two different machines, I have other projects in 3.3.x and didn't have an issue with those, not sure I can reproduce from scratch.

I'm on grails 3.3.10 linux mint 19

grailsVersion=3.3.10 gormVersion=6.1.12.RELEASE gradleWrapperVersion=3.5

digdas1 commented 3 years ago

I had the same issue, solved by executing the gradle clean task

bambbt commented 3 years ago

I do it all the time.

arjangch commented 3 years ago

I had the same issue this morning. Gradle clean didn't work. Deleting the build directory manually worked for me.

ppazos commented 3 years ago

Not sure why this keeps happening. I just worked all day on a grails project without any issues. At the next day I do grails run-app and got the profile not found thing.

vishwadeepghimirezph commented 2 years ago

Sometimes after upgrading the version of Intelli-J that I'm using for development, when I try to run the command-line grails program, I receive the following error message:

Error occurred running Grails CLI: No profile found for name [web].

After searching around the web, I found that this was due to a problem with the build/.dependencies file located within your Grails project root. If you delete or rename this file, then run grails again, the dependencies will be corrected and you can run your app.

Thank you @puwanatfx , It worked for me.

fleboho commented 2 years ago

A different situation maybe. I generally face the same problem time and again. But it only happens after I run a separate SpringBoot application using Gradle specifically. I will have to a grails clean operation to be able to run a grails app again.

On Tue, 30 Nov 2021, 05:38 vishwadeepghimirezph @.***> wrote:

Sometimes after upgrading the version of Intelli-J that I'm using for development, when I try to run the command-line grails program, I receive the following error message:

Error occurred running Grails CLI: No profile found for name [web].

After searching around the web, I found that this was due to a problem with the build/.dependencies file located within your Grails project root. If you delete or rename this file, then run grails again, the dependencies will be corrected and you can run your app.

Thank you @puwanatfx https://github.com/puwanatfx , It worked for me.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/grails/grails-core/issues/10898#issuecomment-982254373, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALTH5PNHPKHB6JQFPM6MGDUORBMNANCNFSM4EJ5V4UA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

EpicVoyage commented 1 year ago

I know this is an old issue and has been closed, but I am going to add another potential cause since a lot of people have found their way here:

build.groovy: profile "org.grails.profiles:angular"

application.yml: grails.profile: web

Make sure these agree with each other.