未找到Laravel Homestead Per Project Install Bash alias命令
我已经创建了一个每个项目安装的家园。我已经在.sh之后加入了未找到Laravel Homestead Per Project Install Bash alias命令,laravel,laravel-5,vagrant,homestead,Laravel,Laravel 5,Vagrant,Homestead,我已经创建了一个每个项目安装的家园。我已经在.sh之后加入了(在根目录中)来提供其他包,比如RejectionDB,没有任何问题,但是别名文件(也在根目录中)虽然在VM中显示为~/.bash\u别名,但在我键入它们时,它们不会运行任何别名。例如,这些别名: alias artisan='php artisan' alias autoload='composer dump-autoload' 在命令提示中,显示为: artisan migrate:refresh --seed autoload
(在根目录中)来提供其他包,比如RejectionDB,没有任何问题,但是别名
文件(也在根目录中)虽然在VM中显示为~/.bash\u别名,但在我键入它们时,它们不会运行任何别名。例如,这些别名:
alias artisan='php artisan'
alias autoload='composer dump-autoload'
在命令提示中,显示为:
artisan migrate:refresh --seed
autoload
抛出以下错误:
Could not open input file: artisan
autoload: command not found
我尝试的任何别名都会出现这种情况。我已经用nano检查过~/.bash_别名(或/home/vagrant/.bash_别名)是否存在,它肯定是别名的副本。只是没有一个命令被使用,就好像它不存在,或者好像位于正确位置的文件不可访问一样
有人知道为什么吗?或者如何解决这个问题?令人惊讶的是,当使用这个虚拟机时,不能使用我通常会在本地使用的别名,或者在Homestead的全局安装上使用的别名是多么烦人
更新
我注意到,当我SSH到VM中时,我得到了一个command not found
错误列表,它与我包含的别名数量相等。如果运行source~/.bash\u别名
,则会出现相同的列表。为完全清楚起见,.bash_别名
位于映射的源文件夹/home/vagrant/app
旁边的/home/vagrant/app中,并包含从SSHing到VM的输出以及相关的别名文件:
SSH到VM
$ vagrant ssh
Welcome to Ubuntu 14.04.3 LTS (GNU/Linux 3.19.0-25-generic x86_64)
* Documentation: https://help.ubuntu.com/
Last login: Mon Feb 15 00:37:39 2016 from 10.0.2.2
: command not found
: command not found
: command not found
: command not found
: command not found
: command not found
: command not found
: command not found
: command not found
: command not found
vagrant@app:~$
别名文件
# Homestead --------------------------------------------------------------------
alias ..="cd .."
alias ...="cd ../.."
alias h='cd ~'
alias c='clear'
alias phpspec='vendor/bin/phpspec'
alias phpunit='vendor/bin/phpunit'
# Laravel ----------------------------------------------------------------------
# Access Artisan when within project folder
alias artisan='php artisan'
# Access Tinker when within project folder
alias tinker="php artisan tinker --env=local"
# Composer --------------------------------------------------------------------
alias autoload='composer dump-autoload'
# App -------------------------------------------------------------------------
alias app="cd app"
#!/usr/bin/env bash
#
# Install RethinkDB on Ubuntu
# @see https://www.rethinkdb.com/docs/install/ubuntu/
#
# Add RethinkDB repository and install
source /etc/lsb-release && echo "deb http://download.rethinkdb.com/apt $DISTRIB_CODENAME main" | sudo tee /etc/apt/sources.list.d/rethinkdb.list
wget -qO- https://download.rethinkdb.com/apt/pubkey.gpg | sudo apt-key add -
sudo apt-get update
sudo apt-get install -y rethinkdb
# Setup RethinkDB as a service using default configuration file
#sudo cp /etc/rethinkdb/default.conf.sample /etc/rethinkdb/instances.d/instance1.conf
#sudo vim /etc/rethinkdb/instances.d/instance1.conf
#sudo /etc/init.d/rethinkdb restart
# Setup RethinkDB as a service by copying the custom configuration file
sudo cp /home/vagrant/app/rethinkdb.conf /etc/rethinkdb/instances.d/instance1.conf
sudo /etc/init.d/rethinkdb restart
After.sh文件
# Homestead --------------------------------------------------------------------
alias ..="cd .."
alias ...="cd ../.."
alias h='cd ~'
alias c='clear'
alias phpspec='vendor/bin/phpspec'
alias phpunit='vendor/bin/phpunit'
# Laravel ----------------------------------------------------------------------
# Access Artisan when within project folder
alias artisan='php artisan'
# Access Tinker when within project folder
alias tinker="php artisan tinker --env=local"
# Composer --------------------------------------------------------------------
alias autoload='composer dump-autoload'
# App -------------------------------------------------------------------------
alias app="cd app"
#!/usr/bin/env bash
#
# Install RethinkDB on Ubuntu
# @see https://www.rethinkdb.com/docs/install/ubuntu/
#
# Add RethinkDB repository and install
source /etc/lsb-release && echo "deb http://download.rethinkdb.com/apt $DISTRIB_CODENAME main" | sudo tee /etc/apt/sources.list.d/rethinkdb.list
wget -qO- https://download.rethinkdb.com/apt/pubkey.gpg | sudo apt-key add -
sudo apt-get update
sudo apt-get install -y rethinkdb
# Setup RethinkDB as a service using default configuration file
#sudo cp /etc/rethinkdb/default.conf.sample /etc/rethinkdb/instances.d/instance1.conf
#sudo vim /etc/rethinkdb/instances.d/instance1.conf
#sudo /etc/init.d/rethinkdb restart
# Setup RethinkDB as a service by copying the custom configuration file
sudo cp /home/vagrant/app/rethinkdb.conf /etc/rethinkdb/instances.d/instance1.conf
sudo /etc/init.d/rethinkdb restart
更新2
.bash\u alias
的Nano输出,它看起来像我的别名文件,但之后的alias
输出会截断别名的第一个字母
# Homestead ----------------------------------------------------------------------
alias ..="cd .."
alias ...="cd ../.."
alias h='cd ~'
alias c='clear'
alias phpspec='vendor/bin/phpspec'
alias phpunit='vendor/bin/phpunit'
# Laravel ----------------------------------------------------------------------
# Access Artisan when within project folder
alias artisan='php artisan'
# Access Tinker when within project folder
alias tinker="php artisan tinker --env=local"
# Composer --------------------------------------------------------------------
alias autoload='composer dump-autoload'
仅在终端中键入别名
的输出:
vagrant@app:~$ alias
'lias ..='cd ..
'lias ...='cd ../..
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
'lias artisan='php artisan
'lias autoload='composer dump-autoload
'lias c='clear
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
'lias h='cd ~
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -alF'
alias ls='ls --color=auto'
'lias phpspec='vendor/bin/phpspec
'lias phpunit='vendor/bin/phpunit
'lias tinker='php artisan tinker --env=local
最终解决方案
感谢@JoshRumbut解决了这个问题,请参见下面的评论
vagrant@app:~$ tr -d '\r' <~/.bash_aliases >~/tmp
vagrant@app:~$ mv ~/tmp ~/.bash_aliases
vagrant@app:~$ unalias -a
vagrant@app:~$ source .bash_aliases
vagrant@app:~$tr-d'\r'~/tmp
vagrant@app:~$mv~/tmp~/.bash\u别名
vagrant@app:~$unalias-a
vagrant@app:~$source.bash\u别名
是否将bash配置为查看.bash\u别名
文件
如果运行source~/.bash\u别名
,会发生什么情况?那他们工作吗
编辑:目前的理论是,文件中某处嵌入了一个奇怪的字符,可能是回车符(\r),如问题所述:Hi,我刚刚尝试了你的建议,它抛出了一堆命令未找到的错误。这实际上是我每次SSH到VM时都会注意到的事情。未找到的命令的数量
错误等于别名的数量。这确实令人费解,请尝试在此处运行别名脚本(可能在.sh之后)以查看是否存在任何难以发现的问题:您还可以尝试查看别名的输出,以查看有什么问题(如果有的话)正在定义。我在问题中添加了两个文件,以防有帮助。查看alias
的输出似乎会转储别名文件的内容,但这是不正确的。。。我已经把它贴在上面了。似乎它截断了添加的别名的第一个字母。这很奇怪,也许别名文件中嵌入了某种奇怪的字符?另外,另一种尝试是unalias-a
(删除所有别名),然后尝试手动或再次使用源代码添加它们。也许有了一个清白的记录,就更容易看到发生了什么。这条线太可疑了source
可能会中断命令行source/etc/lsb release&&echo“deb”http://download.rethinkdb.com/apt $DISTRIB_CODENAME main“| sudo tee/etc/apt/sources.list.d/referencedb.list