来源流浪了找不到 [英] Source not found on Vagrant up

查看:146
本文介绍了来源流浪了找不到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Vagrantfile 它调用下面的脚本低于code。该脚本运行良好,直到最后一行源$ dotfile 。当它到达,剧本说来源:找不到。前行,猫$ dotfile 工作得很好,因此该文件明显存在。

为什么这个文件不知何故未找到命令,但它的工作原理为previous 命令?

输出误差

  ==>默认:/vagrant/scripts/create_functions_dotfile.sh:14:/vagrant/scripts/create_functions_dotfile.sh:来源:未找到

Vagrantfile

  config.vm.provision#{脚本[名称]},键入:壳做|外壳|
  shell.inline =/ bin / sh的/vagrant/scripts/create_functions_dotfile.sh
结束

脚本/ create_functions_dotfile.sh

 #!/ bin / sh的dotfile = /家庭/流浪者/ .functions.sh在/文件游民/脚本/功能/ *;做
  回声猫$文件>> $ dotfile
  猫$文件>> $ dotfile
DONE回声源$ dotfile>> /home/vagrant/.bashrc
猫$ dotfile
来源$ dotfile


解决方案

来源是具体的#!/斌/ bash的,所以要么你


  1. 替代

     #!/ bin / sh的

     #!/斌/庆典


  2. 替代

     来源$ dotfile

     。 $ dotfile



ETA:作为事实上,错误抱怨说,源是找不到的,不是它的参数

I have the below code in my Vagrantfile which calls the below script. The script runs fine up until the last line source $dotfile. When it gets to source, the script says source: not found. The line before, cat $dotfile works just fine so the file clearly exists.

Why is this file somehow not found for the source command but it works for the previous cat command?

output error

==> default: /vagrant/scripts/create_functions_dotfile.sh: 14: /vagrant/scripts/create_functions_dotfile.sh: source: not found

Vagrantfile

config.vm.provision "#{script["name"]}", type: "shell" do |shell|
  shell.inline = "/bin/sh /vagrant/scripts/create_functions_dotfile.sh"
end

scripts/create_functions_dotfile.sh

#!/bin/sh

dotfile=/home/vagrant/.functions.sh

for file in /vagrant/scripts/functions/*; do
  echo "cat $file >> $dotfile"
  cat $file >> $dotfile
done

echo "source $dotfile" >> /home/vagrant/.bashrc
cat $dotfile
source $dotfile

解决方案

Source is specific for #!/bin/bash, so either you

  1. substitute

    #!/bin/sh 
    

    with

    #!/bin/bash 
    

  2. substitute

    source $dotfile
    

    with

    . $dotfile
    


ETA: as a matter of fact, the error complains that 'source' is not found, not its argument.

这篇关于来源流浪了找不到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆