代码之家  ›  专栏  ›  技术社区  ›  Mayur

无法准备上下文:未找到路径“\r”

  •  0
  • Mayur  · 技术社区  · 7 年前

    build_docker.sh windows计算机中包含以下内容的文件。

    #!/usr/bin/env bash
    #This script build docker image
    docker build -t hello-world .
    

    在这里,我尝试使用命令运行上述文件 sudo sh build_docker.sh
    Unable to prepare context: path ".\r" not found
    4.2.46(2)-release Bash版本

    我错过了什么?

    1 回复  |  直到 7 年前
        1
  •  2
  •   ticktack    5 年前

    将文件名从filename.sh更改为.bash解决了我的问题。

        2
  •  1
  •   Armali    7 年前

    使用 :set fileformat=unix sudo bash build_docker.sh 解决了我的问题 -玛尤

        3
  •  1
  •   techmagister    6 年前

    这也会起作用。

    1. Open all files using vim *
    2. Press "qq" to start recording
    3. :set ff=unix
    4. :wn
    5. Press again "q" to stop recording
    6. :wq!
    
        4
  •  1
  •   Vladimir Buskin    5 年前

    dos2unix build_docker.sh