Score:0

Sail up for a cloned laravel project does not work

cn flag
r j

I have Windows 10, WSL2, and Docker.

I've cloned a repository from GitHub, and when I try to sail up, I get this message: /usr/bin/env: ‘sh\r’: No such file or directory.

The following is from the laravel website which I believe is the solution to my problem:

docker run --rm \
    -u "$(id -u):$(id -g)" \
    -v $(pwd):/var/www/html \
    -w /var/www/html \
    laravelsail/php81-composer:latest \
    composer install --ignore-platform-reqs

The source of the above code: https://laravel.com/docs/8.x/sail#installing-composer-dependencies-for-existing-projects

I've tried docker run laravelsail/php81-composer:latest. I've also tried docker run --rm -v $(pwd):/app composer/composer install. Both times I continue to get /usr/bin/env: ‘sh\r’: No such file or directory.

Can you please guide me to get my sail up working so I can see my project on my localhost?

Thanks.

My composer.json file:

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "require": {
        "php": "^8.0.2",
        "guzzlehttp/guzzle": "^7.2",
        "laravel/framework": "^9.2",
        "laravel/sanctum": "^2.14.1",
        "laravel/tinker": "^2.7"
    },
    "require-dev": {
        "fakerphp/faker": "^1.9.1",
        "laravel/breeze": "^1.9",
        "laravel/sail": "^1.0.1",
        "mockery/mockery": "^1.4.4",
        "nunomaduro/collision": "^6.1",
        "phpunit/phpunit": "^9.5.10",
        "spatie/laravel-ignition": "^1.0"
    },
    "autoload": {
        "psr-4": {
            "App\\": "app/",
            "Database\\Factories\\": "database/factories/",
            "Database\\Seeders\\": "database/seeders/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-update-cmd": [
            "@php artisan vendor:publish --tag=laravel-assets --ansi --force"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

gb flag
which shell are you running this from?
r j avatar
cn flag
r j
@JoeNiland Ubuntu terminal that's available in Microsoft's App store.
gb flag
@r j my guess is it's due to line endings, see https://stackoverflow.com/questions/18172405/getting-error-usr-bin-env-sh-no-such-file-or-directory-when-running-command-p
r j avatar
cn flag
r j
@JoeNiland I took this approach already. It completely changed the way my PC's system was working. For example, it would no longer open the Microsoft Store's apps. So, I had to do a system restore.
r j avatar
cn flag
r j
I even did `git config --global core.autocrlf false` and still didn't work. @JoeNiland
Score:1
cn flag

It seems that after running git config --global core.autocrlf false the actual repository you clone before hasn't been affected yet, you need to refresh the repository.

You could achieve this goal with two approaches:

  1. Deleting the repository you cloned on first place, and cloning back, but now autcrlf should get effect.
  2. Renormalizing the repository

For option 2:

Save your current files in Git, so that none of your work is lost.

$ git add . -u
$ git commit -m "Saving files before refreshing line endings"

Add all your changed files back and normalize the line endings.

$ git add --renormalize .

Show the rewritten, normalized files.

$ git status

Commit the changes to your repository.

$ git commit -m "Normalize all the line endings"

source: https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings#refreshing-a-repository-after-changing-line-endings

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.