【问题标题】:Pathing issues with using ./ in a Rakefile on Windows在 Windows 上的 Rakefile 中使用 ./ 的路径问题
【发布时间】:2018-03-20 06:07:27
【问题描述】:

我有以下 Rakefile...

namespace :dev do
    desc "Execute my-bash-script."
    task :done do
        sh "./bin/my-bash-script.sh" # <-- Error on this line
    end 
end

我用rake dev:done在我的Mac上成功执行了

但是,当我在我的 Windows 机器上运行该命令时,我在 sh "./bin/my-bash-script.sh" 行上收到 Command failed with status (127) 错误。

我认为使用 ./ 存在路径问题,因此我尝试将 Rakefile 中的 ./ 替换为 #{File.dirname(__FILE__)},但仍然收到相同的错误。

我做错了什么?

【问题讨论】:

  • 不,仍然收到同样的错误:(
  • 你能在 ruby​​ 脚本之外运行sh 脚本吗? (例如从命令行)
  • 是的。该脚本可从 Rakefile 外部执行

标签: javascript ruby windows bash rake


【解决方案1】:

在 windows 下,在 shell 路径中传递正斜杠不起作用。 您需要将命令字符串中的所有 '/' 替换为 '\'。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-29
    • 1970-01-01
    • 2021-04-02
    • 2011-06-05
    • 1970-01-01
    • 2016-08-04
    相关资源
    最近更新 更多