0

I am trying to execute sass --update via PHP shell_exec() function and get an error:

H:\SERVER\htdocs\path\to\project>sass --style compressed --update sass\:deployment\css\ 'sass' is not recognized as an internal or external command, operable program or batch file. 

If I run the same command from the cmd manually - it works fine. The current folder is correct - checked with the getcwd()

1 Answer 1

1

When you run the command sass in a shell, your computer has to find the executable program called sass somewhere on your computer. To do this, it looks through a series of folders called your PATH. Your PHP server is most likely running with a different PATH than your command prompt, and as such, is not able to find the executable.

To fix this: From your command prompt, where sass DOES work, run this command: which sass (on Windows, instead use where sass)

That will tell you the exact location of sass (for example, it might be /usr/bin/sass or something like that). Once you have that value, replace "sass" in your PHP code with that entire location.

Sign up to request clarification or add additional context in comments.

3 Comments

Err, is the command just 'which sass'? "'which' is not recognized as an internal or external command, operable program or batch file."
Oh huh, I guess on Windows you have to use "where" instead. stackoverflow.com/questions/304319/…
Yes, that's it! It gave me the Path :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.