1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Laravel×Homestead で、composer require laravel/uiを叩いたら、エラーがでた話

Posted at

Laravelには認証機能を実装できる便利なコマンドがあります。
しかし、その認証機能実装をする際にLaravel×Homesteadで詰まったので、メモ書きとして残します。

環境

  • OS : windows11 pro
  • VirtualBox (5.2.44)
  • vagrant (2.2.5)
  • Laravel8×Homestead

認証機能の実行

下記のコマンドをプロジェクト内で叩けば、実装できます。
composer require laravel/ui

しかし、実際に叩くと下記のようなエラー表示が・・・

Using version ^4.0 for laravel/ui
./composer.json has been updated
Running composer update laravel/ui
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires laravel/ui ^4.0 -> satisfiable by laravel/ui[v4.0.0, v4.0.1, v4.0.2, 4.x-dev].
    - laravel/ui[v4.0.0, ..., 4.x-dev] require illuminate/console ^9.21 -> found illuminate/console[v9.21.0, ..., 9.x-dev] but these were not loaded, likely because it conflicts with another require.

You can also try re-running composer require with an explicit version constraint, e.g. "composer require laravel/ui:*" to figure out if any version is installable, or "composer require laravel/ui:^2.1" if you know which you need.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.

エラー文を読み解く

原因は、下記の部分に

Problem 1
    - Root composer.json requires laravel/ui ^4.0 -> satisfiable by laravel/ui[v4.0.0, v4.0.1, v4.0.2, 4.x-dev].
    - laravel/ui[v4.0.0, ..., 4.x-dev] require illuminate/console ^9.21 -> found illuminate/console[v9.21.0, ..., 9.x-dev] but these were not loaded, likely because it conflicts with another require.

そのまま翻訳すると・・・

『問題1
- ルート composer.json requires laravel/ui ^4.0 -> laravel/ui[v4.0.0, v4.0.1, v4.0.2, 4.x-dev] で満たせます。
- laravel/ui[v4.0.0, ..., 4.x-dev] require illuminate/console ^9.21 -> found illuminate/console[v9.21.0, ..., 9.x-dev] but these were not loaded, likely because it conflicts with another require.これは、他のrequireと衝突しているようです。』

とのこと。
つまり、このままでは、衝突が起こりインストールできないと・・・

しかし、解決策はすぐ下に書いてありました。

You can also try re-running composer require with an explicit version constraint, e.g. "composer require laravel/ui:*" to figure out if any version is installable, or "composer require laravel/ui:^2.1" if you know which you need.

これも翻訳してみる

『composer require laravel/ui:*」のように、バージョンを指定してcomposer requireを実行し、インストール可能なバージョンを確認することもできます。』

書かれている通りに
composer require laravel/ui:*を叩いてみる。

すると
Package manifest generated successfully.
と表示がでて、問題なく認証機能を実装できることができました。

エラー表示をしっかり読む解くことが本当に大事だなと感じさせられました。

ちなみに、バージョン指定を行った結果

Laravel7系のように
composer require laravel/ui:2.*
のようにver.2の指定を行うと、下記のようなエラー表示がでました。

  Problem 1
    - laravel/ui[v2.0.0, ..., v2.4.1] require php ^7.2.5 -> your php version (8.1.8) does not satisfy that requirement.
    - laravel/ui[v2.5.0, ..., 2.x-dev] require illuminate/console ^7.0 -> found illuminate/console[v7.0.0, ..., 7.x-dev] but these were not loaded, likely because it conflicts with another require.
    - Root composer.json requires laravel/ui 2.* -> satisfiable by laravel/ui[v2.0.0, ..., 2.x-dev].

laravel/uiの最新バージョン(ver.3)でLaravel8のサポートが追加されてこれが指定したLaravelのバージョンと合ってなかったのが原因だと考えられます。

composer require laravel/ui:*
とversionを**ワイルドカード(*)**にしたことで、最新版のlaravel/uiが指定され、インストールがうまくいったと考えられます。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?