laravel new; application already exists error

Viewed 6275

I have installed Laravel before and I deleted that folder, and now after several months I install Laravel installer but when I write the command laravel new in Windows Powershell it returns this error.

 _                               _
| |                             | |
| |     __ _ _ __ __ ___   _____| |
| |    / _` | '__/ _` \ \ / / _ \ |
| |___| (_| | | | (_| |\ V /  __/ |
|______\__,_|_|  \__,_| \_/ \___|_|


In NewCommand.php line 153:

  Application already exists!


new [--dev] [--jet] [-f|--force] [--] [<name>]
8 Answers

I created project. But I deleted it. When I create project again with the same name, I encountered this problem. After, I runned this command:

laravel new project-name --force

Only, I added --force end of command.

If you're having problems, delete the parent directory. There's a chance there are hidden folders scattered across it.

Otherwise you can try creating a new folder in another directory and running Laravel new in it.

The folder location doesn't matter, it just generates content of a Laravel app.

Once you've created a new folder, you can move all the files across to your other folder with the following: mv laravel/* /var/app/myfolderlocation

I have faced the same issue while creating a new project on the latest Laravel through Composer but didn't find any solution and at the last, I tried to create a Laravel project by the following command and it's working as expected.

composer create-project --prefer-dist laravel/laravel ProjectName

or, you should remove that folder and let it be created by command as follows:

laravel new ProjectName

Explanation:

As I get the following error.


 _                               _
| |                             | |
| |     __ _ _ __ __ ___   _____| |
| |    / _` | '__/ _` \ \ / / _ \ |
| |___| (_| | | | (_| |\ V /  __/ |
|______\__,_|_|  \__,_| \_/ \___|_|


In NewCommand.php line 184:

  Application already exists!


new [--dev] [--jet] [--stack [STACK]] [--teams] [-f|--force] [--] [<name>]

I tried to figure out this issue and found a function that is placed under %appdata%\Composer\vendor\laravel\installer\src\NewCommand.php on line 184 as follows:

    /**
     * Verify that the application does not already exist.
     *
     * @param  string  $directory
     * @return void
     */
    protected function verifyApplicationDoesntExist($directory)
    {
        if ((is_dir($directory) || is_file($directory)) && $directory != getcwd()) {
            throw new RuntimeException('Application already exists!');
        }
    }

here verifyApplicationDoesntExist function is checking that the application folder you are trying to create has existed or not, it's not checking the application folder's size so it doesn't matter if the folder is empty or not. so due to code like that, the composer thinks application already been created that's why it throws an error like your application already exists.

To tackle this issue, you just need to delete your empty project folder and create it by command laravel new ProjectName and that will create project folder itself without giving any error like Application already exist!.

It happened to me too. Maybe you created your laravel project directly in your linux shell instead of making it through the power shell "indirect" interface to your linux machine.

In my case I solved it following the next steps: 1.- Deleting the laravel-project directly in the ubuntu linux shell. rm -R laravel-project. 2.- Then, through power shell i executed again the curl command in the "sublinux" terminal like this: curl -s https://laravel.build/example-app | bash

Then the process started without problems, creating all the laravel files and docker images and containers.

All the tutorials followed by me direct to the microsoft step by step tutorial,

https://docs.microsoft.com/en-us/windows/wsl/install-win10

but it hidden some key steps that you can find in this amazing video:

https://www.youtube.com/watch?v=rr6AngDpgnM, thank you dogcomp for take the time that need some begginers (and not so beginners, like me).

The error means that the directory already exists.

Do the following to get around.

  1. Go to a temp directory.
  2. Execute the laravel new project-name there.
  3. Copy the contents of the newly created directory to the actual project directory.

Though this might be late but i think it might help someone in difficult times. This error is related to the folder already in existence

Here's how i was able solve this issue:

  1. i closed the vscode holding reference to the folder i intend installing laravel in. then cd .. to come out from the folder.

  2. next up. laravel new [target-folder-name] -f

and problem solved.

I'm hoping this would help someone.

While previously you would need to first create the directory then cd the console there and run laravel new, but currently you have to:

  1. First ensure the my-project directory does NOT exist.
  2. Run laravel new my-project to create the directory for you.
  3. Wait for composer install command (which will auto-run) to finish.

For me in the end, it just logs Application ready! Build something amazing.

But finally, maybe go further and edit the auto-generated ./my-project/.env file, for example, set DB_DATABASE to something other than my_project or change APP_URL=http://my-project.test to APP_URL=http://localhost address.

Related