0

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
}

r j
  • 1
  • 1
  • which shell are you running this from? – Joe Niland Apr 08 '22 at 01:47
  • @JoeNiland Ubuntu terminal that's available in Microsoft's App store. – r j Apr 08 '22 at 02:05
  • @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 – Joe Niland Apr 08 '22 at 02:08
  • @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 Apr 08 '22 at 02:11
  • I even did `git config --global core.autocrlf false` and still didn't work. @JoeNiland – r j Apr 08 '22 at 02:43

1 Answers1

1

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

jarinlima
  • 11
  • 2