Jump to content
Richard Christian

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

Share this post


Link to post
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

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...