JQ not recognized by AppleScript

I have a daily journal I create in Devonthink3 with BTT, and as part of the note creation, I have it add that day’s weather and the forecast. I ran this fine for about 90 days, but had to wipe the computer and reload the OS, so I’ve apparently missed something along the way. Now when I run the script, it throws Failed to parse weather data: sh:jq: command not found

I’ve installed JSON Helper and of course jq, but I’ve missed something. I’ve added the weather portion of the larger script below.

-- Fetch and format weather data
on getWeather()
	set weatherAPIURL to "http://api.weatherapi.com/v1/forecast.json?key=86a511ece53749c88e9205427250301&q=Detroit&days=1&aqi=no&alerts=no"
	try
		set weatherData to do shell script "curl -s " & quoted form of weatherAPIURL
	on error errMsg
		display dialog "Failed to fetch weather data: " & errMsg
		return ""
	end try
	
	try
		set currentTempFt to do shell script "echo " & quoted form of weatherData & " | jq -r '.current.temp_f'"
		set currentCondition to do shell script "echo " & quoted form of weatherData & " | jq -r '.current.condition.text'"
		set currentWindMph to do shell script "echo " & quoted form of weatherData & " | jq -r '.current.wind_mph'"
		set currentWindDir to do shell script "echo " & quoted form of weatherData & " | jq -r '.current.wind_dir'"
		set currentHumidity to do shell script "echo " & quoted form of weatherData & " | jq -r '.current.humidity'"
		set feelslikeF to do shell script "echo " & quoted form of weatherData & " | jq -r '.current.feelslike_f'"
		set forecastCondition to do shell script "echo " & quoted form of weatherData & " | jq -r '.forecast.forecastday[0].day.condition.text'"
		set forecastMaxTempF to do shell script "echo " & quoted form of weatherData & " | jq -r '.forecast.forecastday[0].day.maxtemp_f'"
		set forecastMinTempF to do shell script "echo " & quoted form of weatherData & " | jq -r '.forecast.forecastday[0].day.mintemp_f'"
		set forecastAvgHumidity to do shell script "echo " & quoted form of weatherData & " | jq -r '.forecast.forecastday[0].day.avghumidity'"
		set forecastUV to do shell script "echo " & quoted form of weatherData & " | jq -r '.forecast.forecastday[0].day.uv'"
		set astroSunrise to do shell script "echo " & quoted form of weatherData & " | jq -r '.forecast.forecastday[0].astro.sunrise'"
		set astroSunsetAt to do shell script "echo " & quoted form of weatherData & " | jq -r '.forecast.forecastday[0].astro.sunset'"
		
		set formattedDate to short date string of (current date)
		set formattedTime to time string of (current date)
		
		set output to formattedDate & " " & formattedTime & return & ¬
			"Currently, it's " & currentTempFt & "º, and " & currentCondition & " outside, the wind is " & currentWindMph & " mph from the " & currentWindDir & " and the Humidity is " & currentHumidity & "%. " & ¬
			"Currently, it feels like " & feelslikeF & "º. Today's forecast calls for " & forecastCondition & ", with a high of " & forecastMaxTempF & " ºF and a low of " & forecastMinTempF & " º, today's humidity will be " & forecastAvgHumidity & "%, with a UV index of " & forecastUV & ". " & ¬
			"Sunrise is at " & astroSunrise & " this morning, and Sunset will be at " & astroSunsetAt & " this evening."
		
		return output
	on error errMsg
		display dialog "Failed to parse weather data: " & errMsg
		return ""
	end try
end getWeather

One quick way to fix this is to put the full path to jq.

Or you can prepend your command with PATH=$PATH:/opt/homebrew/bin if you are using HomeBrew.

Replace the path with the location of your jq if it is in a different place.

I’m still relatively new to AppleScript, which command should I prepend?

EDIT
Nvm, I found the solution, thank you!


-- Fetch and format weather data
on getWeather()
	set weatherAPIURL to "http://api.weatherapi.com/v1/forecast.json?key=86a511ece53749c88e9205427250301&q=Detroit&days=1&aqi=no&alerts=no"
	try
		set weatherData to do shell script "export PATH=$PATH:/usr/local/bin; curl -s " & quoted form of weatherAPIURL
	on error errMsg
		display dialog "Failed to fetch weather data: " & errMsg
		return ""
	end try
	
	try
		set currentTempFt to do shell script " export PATH=$PATH:/usr/local/bin; echo  " & quoted form of weatherData & " | jq -r '.current.temp_f'"
		set currentCondition to do shell script " export PATH=$PATH:/usr/local/bin; echo  " & quoted form of weatherData & " | jq -r '.current.condition.text'"
		set currentWindMph to do shell script " export PATH=$PATH:/usr/local/bin; echo  " & quoted form of weatherData & " | jq -r '.current.wind_mph'"
		set currentWindDir to do shell script " export PATH=$PATH:/usr/local/bin; echo  " & quoted form of weatherData & " | jq -r '.current.wind_dir'"
		set currentHumidity to do shell script " export PATH=$PATH:/usr/local/bin; echo  " & quoted form of weatherData & " | jq -r '.current.humidity'"
		set feelslikeF to do shell script " export PATH=$PATH:/usr/local/bin; echo  " & quoted form of weatherData & " | jq -r '.current.feelslike_f'"
		set forecastCondition to do shell script " export PATH=$PATH:/usr/local/bin; echo  " & quoted form of weatherData & " | jq -r '.forecast.forecastday[0].day.condition.text'"
		set forecastMaxTempF to do shell script " export PATH=$PATH:/usr/local/bin; echo  " & quoted form of weatherData & " | jq -r '.forecast.forecastday[0].day.maxtemp_f'"
		set forecastMinTempF to do shell script " export PATH=$PATH:/usr/local/bin; echo  " & quoted form of weatherData & " | jq -r '.forecast.forecastday[0].day.mintemp_f'"
		set forecastAvgHumidity to do shell script " export PATH=$PATH:/usr/local/bin; echo  " & quoted form of weatherData & " | jq -r '.forecast.forecastday[0].day.avghumidity'"
		set forecastUV to do shell script " export PATH=$PATH:/usr/local/bin; echo  " & quoted form of weatherData & " | jq -r '.forecast.forecastday[0].day.uv'"
		set astroSunrise to do shell script " export PATH=$PATH:/usr/local/bin; echo  " & quoted form of weatherData & " | jq -r '.forecast.forecastday[0].astro.sunrise'"
		set astroSunsetAt to do shell script " export PATH=$PATH:/usr/local/bin; echo  " & quoted form of weatherData & " | jq -r '.forecast.forecastday[0].astro.sunset'"
		
		set formattedDate to short date string of (current date)
		set formattedTime to time string of (current date)
		
		set output to formattedDate & " " & formattedTime & return & ¬
			"Currently, it's " & currentTempFt & "º, and " & currentCondition & " outside, the wind is " & currentWindMph & " mph from the " & currentWindDir & " and the Humidity is " & currentHumidity & "%. " & ¬
			"Currently, it feels like " & feelslikeF & "º. Today's forecast calls for " & forecastCondition & ", with a high of " & forecastMaxTempF & " ºF and a low of " & forecastMinTempF & " º, today's humidity will be " & forecastAvgHumidity & "%, with a UV index of " & forecastUV & ". " & ¬
			"Sunrise is at " & astroSunrise & " this morning, and Sunset will be at " & astroSunsetAt & " this evening."
		
		return output
	on error errMsg
		display dialog "Failed to parse weather data: " & errMsg
		return ""
	end try
end getWeather