[英]zsh: command not found laravel
I'm a newbie when it comes to Linux administration using bash... I was following a tutorial on how to install laravel 5.2 from here ... installed it successfully...我是使用 bash 进行 Linux 管理的新手......我正在学习如何从这里安装 laravel 5.2 的教程......安装成功......
firstly I installed composer and ran the following command首先我安装了作曲家并运行了以下命令
composer global require "laravel/installer"
after this put this in my path too in ~/.zshrc
like this在这之后把它也放在我的路径中
~/.zshrc
像这样
export PATH="~/.composer/vendor/bin:$PATH"
When I run the laravel
command from the terminal I get the following error当我从终端运行
laravel
命令时,出现以下错误
➜ ~ laravel
zsh: command not found: laravel
If I echo $PATH
it shows it have added up in the path如果我
echo $PATH
它表明它已经添加到路径中
Note: I have installed oh my zsh
on my terminal...注意:我已经在我的终端上安装了
oh my zsh
...
What do I have to do to get it working please help我需要做什么才能让它正常工作请帮忙
I think ZSH won't expand the ~
on PATH
.我认为 ZSH 不会在
PATH
上扩展~
。 Try this instead:试试这个:
export PATH="$HOME/.config/composer/vendor/bin:$PATH"
尝试这样做:
export PATH="$HOME/.config/composer/vendor/bin:$PATH"
As a follow up to Chris' answer,作为克里斯回答的后续行动,
The command export PATH="$HOME/.composer/vendor/bin:$PATH"
will work , but only for your current terminal session .命令
export PATH="$HOME/.composer/vendor/bin:$PATH"
将起作用,但仅适用于您当前的终端会话。
If you would like the path to always be available when zsh launches, add PATH="$HOME/.composer/vendor/bin:$PATH"
to the bottom of your ~/.zshrc
file.如果您希望在 zsh 启动时始终可用路径,请将
PATH="$HOME/.composer/vendor/bin:$PATH"
添加到~/.zshrc
文件的底部。 Run the zsh
command or restart your terminal and laravel
will be available in every session you start.运行
zsh
命令或重新启动终端, laravel
将在您启动的每个会话中可用。
I got the same problem on macOS Sierra.我在 macOS Sierra 上遇到了同样的问题。 Edit your .zshrc file with
编辑您的 .zshrc 文件
PATH=~/.composer/vendor/bin:$PATH
That worked for me.这对我有用。
On Ubuntu 20.04 with zsh (Oh My ZSH!) and macos.在带有 zsh(Oh My ZSH!)和 macos 的 Ubuntu 20.04 上。
add Laravel cli with composer: composer global require laravel/installer
使用 composer 添加 Laravel cli:
composer global require laravel/installer
edit ~/.zshrc
编辑
~/.zshrc
add添加
export PATH="$HOME/.config/composer/vendor/bin:$PATH"
run:跑:
source ~/.zshrc
就我而言,我在结束文件 '.zshrc' 上添加了以下行:
export PATH="$HOME/.composer/vendor/bin:$PATH"
cd 进入项目目录并运行composer create-project --prefer-dist laravel/laravel blog
When you run command laravel
in your terminal, you call the laravel file inside composer/vendor/bin directory.当您在终端中运行命令
laravel
时,您会调用 composer/vendor/bin 目录中的 laravel 文件。
If none of the above works, then find where your vendor dir is by running:如果上述方法均无效,请运行以下命令查找您的供应商目录所在的位置:
composer global about
you will see something like: "Changed current directory to /home/username/.config/composer".您将看到类似:“将当前目录更改为 /home/username/.config/composer”。
That means that your vendor dir is located in that path.这意味着您的供应商目录位于该路径中。 Then add an alias in .zshrc file:
然后在 .zshrc 文件中添加别名:
alias laravel="$HOME/.config/composer/vendor/bin/laravel"
. alias laravel="$HOME/.config/composer/vendor/bin/laravel"
。
Now you are pointing to the 'laravel' file in your filesys using the same command as you would normally.现在您使用与通常相同的命令指向文件系统中的“laravel”文件。
or you can add composer to your path: export PATH="$HOME/.config/composer/vendor/bin:$PATH"
, which is the recomended way.或者您可以将 composer 添加到您的路径:
export PATH="$HOME/.config/composer/vendor/bin:$PATH"
,这是推荐的方式。
export PATH="$HOME/.config/composer/vendor/bin:$PATH"
or better still edit the .zshrc file as below或者最好还是编辑 .zshrc 文件,如下所示
echo "PATH=\"$HOME/.config/composer/vendor/bin:$PATH\"" >> ~/.zshrc source ~/.zshrc
Try to do this:尝试这样做:
macOS:苹果系统:
$HOME/.composer/vendor/bin
Windows:视窗:
%USERPROFILE%\AppData\Roaming\Composer\vendor\bin
GNU / Linux Distributions: GNU / Linux 发行版:
$HOME/.config/composer/vendor/bin or $HOME/.composer/vendor/bin
I too was getting the same error while creating a new Laravel project using composer but anything mentioned about the path didn't solved it and a simple trick help to resolve this issue.在使用 composer 创建一个新的 Laravel 项目时,我也遇到了同样的错误,但是任何提到的路径都没有解决它,一个简单的技巧可以帮助解决这个问题。
Try to run this command on the terminal of your project folder :尝试在项目文件夹的终端上运行此命令:
composer global require laravel/installer
Article from laracasts helped me: https://laracasts.com/discuss/channels/laravel/laravel-command-not-found-by-zsh-on-macos laracasts 的文章帮助了我: https ://laracasts.com/discuss/channels/laravel/laravel-command-not-found-by-zsh-on-macos
Put this to .zshrc file:把它放到 .zshrc 文件中:
export PATH="$HOME/.composer/vendor/bin:$PATH"
And make sure you run:并确保您运行:
source ~/.zshrc
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.