mxcl / swift-sh

Easily script with third-party Swift dependencies.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

crontab: error unable to invoke subcommand

dmoroz0v opened this issue · comments

  1. create run.sh with content:

#!/bin/bash
./test.swift asdf.json

and create test.swift with content

#!/usr/bin/swift sh
print("test", CommandLine.arguments)

  1. exec crontab -e

  2. insert */1 * * * * cd ~/Projects/my-project-name && ./run.sh

  3. exec less /var/mail/my_user_name

See error:
error: unable to invoke subcommand: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-sh (No such file or directory)

If I run ./run.sh then I have printed:
test ["/Users/my_user_name/Library/Developer/swift-sh.cache/test/.build/debug/test", "asdf.json"]

I fixed it.
Change run.sh content with:

#!/bin/bash
/usr/local/bin/swift-sh ./test.swift asdf.json

cron executes without /usr/local/bin in the PATH, so yeah, obviously this would be the result.