You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何让AppleScript执行fastlane gym命令?

Fixing "command not found" for fastlane in AppleScript

Got it, let's solve this "command not found" error you're hitting with fastlane in your AppleScript. The root issue is that AppleScript's do shell script uses a stripped-down system PATH that doesn't include the directory where fastlane is installed (usually from Homebrew or RubyGems), unlike your regular Terminal shell which has those paths set up.

Here's how to fix it step by step:

1. Find fastlane's full path first

Open your Terminal app and run this command:

which fastlane

This will output something like /usr/local/bin/fastlane (for Intel Macs) or /opt/homebrew/bin/fastlane (for Apple Silicon Macs). Copy that full path—you'll need it for the script.

2. Update your AppleScript with one of these solutions

Option 1: Use the full fastlane path directly

Replace the generic fastlane in your script with the full path you copied. This is straightforward and reliable:

set pathToWorkspace to choose folder with prompt "Select Your Workspace"
do shell script "cd " & pathToWorkspace's POSIX path's quoted form & " && /opt/homebrew/bin/fastlane gym"

(Make sure to swap /opt/homebrew/bin/fastlane with the actual path you got from which fastlane)

Option 2: Add the correct PATH to your shell command

If you prefer not to hardcode the path (in case it changes later), you can explicitly set the PATH in the shell command to include the directory with fastlane:

set pathToWorkspace to choose folder with prompt "Select Your Workspace"
do shell script "export PATH=/opt/homebrew/bin:/usr/local/bin:$PATH && cd " & pathToWorkspace's POSIX path's quoted form & " && fastlane gym"

This adds both Apple Silicon and Intel Homebrew paths to the system's default PATH, so it should find fastlane no matter your Mac type.

Why this works

When you run commands in Terminal, your shell loads configuration files (like .zshrc or .bash_profile) that add custom directories (like Homebrew's bin) to your PATH. But AppleScript's do shell script doesn't load these files by default, so it can't find tools installed outside the default system directories. By either using the full path or explicitly setting the PATH, you're telling the shell exactly where to find fastlane.

内容的提问来源于stack exchange,提问作者PruitIgoe

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 11:02:59