【问题标题】:Error appearing in bash script when run with LaunchControl使用 LaunchControl 运行时出现在 bash 脚本中的错误
【发布时间】:2016-02-24 10:41:30
【问题描述】:

我有以下脚本

#!/usr/bin/env ruby
Dir.chdir('/Users/Chris/Sites/mentor') do
  audit = `/Users/Chris/.rvm/gems/ruby-2.1.6@mentor/bin/bundle-audit`
  system(%(osascript -e 'display notification "#{audit}" with title "bundle-audit"'))
end

当我从本地文件夹运行它时,它会发出类似的通知

bundle-audit
No vulnerabilities found

但是,当 LaunchControl 定期运行相同的脚本时,通知只是

bundle-audit

标准错误输出是

env: ruby_executable_hooks: No such file or directory

我该如何解决这个问题?

【问题讨论】:

  • 这是一个错误,而不是“输出丢失”。关于您的问题:您需要获取 RVM 初始化脚本。
  • 我尝试将source ~/.rvm/scripts/rvm 放入脚本中,但不起作用。如何在 Mac Osx 10.11.1 上source RVM init script
  • 请在问题中包括您将source ~/.rvm/scripts/rvm 准确地放入脚本中的程度。这很重要。
  • 我现在遵循这里提倡的方法,notes.jerzygangi.com/…。但即使这样也不能完全正常工作,所以我要问一个关于超级用户的更一般的问题,然后回到这里,希望能得到答案。

标签: ruby macos bash applescript rvm


【解决方案1】:

解决此问题的一种方法是使用here 列出的教程。我总结了以下方法。摘要包括对我按照教程进行操作时出现的问题的修复。

我的 ruby​​ 任务叫daily_checks.rb,如下:

#!/usr/bin/env ruby
Dir.chdir('/Users/Chris/Documents/Sites/mentor') do
  audit = `bundle-audit`
  system(%(osascript -e 'display notification "#{audit}" with title "bundle-audit"'))
end

/usr/local/bin/regular_checks.sh 设置一个 RVM 别名和一个 bash 文件,其中包含以下内容:

#!/bin/bash
    /Users/Chris/.rvm/wrappers/regular_checks/ruby /Users/Chris/Documents/Sites/mentor/script/daily_checks.rb

请注意,由于添加了#!/bin/bash 行,以上内容与教程不同。

完成后,launchControl 会成功运行 bundle-audit 命令。

【讨论】:

    猜你喜欢
    • 2017-06-03
    • 1970-01-01
    • 1970-01-01
    • 2016-08-19
    • 2014-03-28
    • 2023-03-07
    • 1970-01-01
    • 2014-12-08
    相关资源
    最近更新 更多