Jump to content

Terminal $PATH Variable | Command not found


Recommended Posts

Hello,

 

I am trying to run a terminal command "terminus site:list" but keep getting error when trying to use the Run Script action. I've read in other articles it's because the terminal doesn't load the user profile but I can not figure out how to set the $PATH variable in the workflow to make this command accessible.

 

I installed Terminus using composer so I created an alias in my .bash_profile that is "alias composer='php ~/composer.phar'" . I've also listed the rest of my .bash_profile below for reference.

 

How do I get this to work with Run Script?

How do I get terminal to load the $PATH variable?

 

export PATH="/usr/local/mysql/bin:~/.composer/vendor/bin:$PATH"
alias composer='php ~/composer.phar'

 

Reference Articles:

 

 

 

Thanks,

Rich

Link to comment
23 minutes ago, Richard Christian said:

terminal command

 

"Shell command". A terminal is a graphical program (e.g. Terminal.app or iTerm2) that runs your shell (e.g. bash or zsh).

 

It's an important difference because "Terminal Command" is an Alfred element that runs a command in your terminal app's shell, rather than running it itself.

 

I'm going to assume you do mean "shell command", as you wouldn't be having this issue if you were using Alfred's Terminal Command.

 

23 minutes ago, Richard Christian said:

How do I get this to work with Run Script?

How do I get terminal to load the $PATH variable?

 

As it says in the linked threads, the best solution is use the full path to the program you're trying to run.

 

Alternatively, you can just add these lines at the top of your Run Script (assuming you have Language set to bash or zsh):

export PATH="/usr/local/mysql/bin:~/.composer/vendor/bin:$PATH"
alias composer='php ~/composer.phar'

Finally, you could source your bashrc file in the Run Script action, so all your settings are present.

 

That's generally not a great idea, however, as it's often slow and it may or may not work, depending on your configuration. Alfred runs scripts in non-interactive mode, and many bashrc files are configured to "short-circuit" and not load all your settings (such as aliases) if bash isn't being run interactively.

 

Edited by deanishe
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...