我已经创建了Homestead的每个项目安装。我已经包含after.sh
(在根目录中)来配置其他软件包(如RethinkDB)没有问题,但aliases
文件(也在根目录中)虽然在VM中显示为〜/。当我输入别名时,bash_aliases不会运行任何别名。例如,这些别名:
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_aliases(或/home/vagrant/.bash_aliases),它绝对是别名的副本。只是没有任何命令被用作好像它不存在或者好像文件虽然在正确的位置是不可访问的。
任何人都知道为什么?或者如何解决这个问题?令人惊讶的是,如果不能使用我通常会在本地使用的别名,或者在使用此VM时全局安装Homestead,这是多么令人讨厌。
更新
我注意到当我通过SSH连接到我所包含的别名数量时,我得到了command not found
错误列表。如果我运行source ~/.bash_aliases
,则会显示相同的列表。为了完整清晰,.bash_aliases
位于映射的源文件夹/home/vagrant
旁边的/home/vagrant/app
中,并且SSHing到VM的输出以及相关的别名文件包括在内:
SSH进入虚拟机
$ 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"
After.sh文件
#!/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_aliases
的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'
仅输入alias
到终端输出
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
答案 0 :(得分:2)
是否将bash配置为查看.bash_aliases
文件?
如果您运行source ~/.bash_aliases
会怎样?那他们工作了吗?
编辑:当前的理论是一个奇怪的角色,可能是回车符(\ r)嵌入在文件的某个地方,如同问题:https://unix.stackexchange.com/questions/35642/why-are-these-aliases-failing