Jump to content

Unable to Execute CLI Application with user variable


Recommended Posts

Hi Team!

 

I have a workflow I've made that passes alfred arguments to a CLI application and executes it using the "External Script" option for ZSH, as argv, like so:

command -q ${query}

 

This no longer works on the latest pre-release (5.1.2) and quit working (no changes), so I have reached out to support. I found that it does work if I replace with the full path, i.e. 
/users/user.name/.bin/command -q ${query}

 

However, that path will be different depending on the user, so it's not ideal. However, using "~/.bin/command -q" does not work and returns a "Command not found"

 

What is the best way of handling this? All of the above work successfully from the CLI directly. 

Link to comment
31 minutes ago, Stacks said:

I found that it does work if I replace with the full path, i.e. 
/users/user.name/.bin/command -q ${query}


Indeed. This is the correct approach.

 

31 minutes ago, Stacks said:

However, that path will be different depending on the user

 

Instead of /Users/username, do ${HOME} which works the same but will be relative to the user.

 

Alternatively, do source ~/.zshenv beforehand as that’s bound to be the difference (see Alfred release notes).

 

To understand more, see Understanding the Scripting Environment.

Link to comment

Thank you for sharing that link - I searched all across the Alfred docs and hadn't see it.

Also thanks for mentioning $HOME - I didn't see that in the list of Alfred vars when I exported an initial list, so wasn't sure if one existed.

 

Adding an "export PATH=" to the top of the script resolved the issue, and appears to handle the ~ correctly.

 

 

Link to comment

@Stacks in the current 5.1.2 pre-release, I added the --no-rcs flag when selecting the /bin/zsh script language in a Script Filter or Run Script. This change is to prevent something in a .zshenv file from breaking the expected output in a script.

 

10 hours ago, Stacks said:

Can you point me towards what specific release notes you are mentioning?

 

This is mentioned here: https://www.alfredapp.com/changelog/ but not yet expanded upon as we are still in the pre-release. If this change sticks through to the 5.1.2 general release, we will create a KB article to detail this change.

 

Having said that, this change should not affect your workflow if you're using External Script as the script language.

 

Would it be possible to share the workflow so we could take a look at why you're seeing a difference? Are you using a .zshenv file, if so, could we see the contents?

 

Cheers,

Andrew

Link to comment

Thanks for clarifying - I am using "Run Script" with /bin/zsh & input as argv, and the zshenv file includes the import path of the rust executables ("$HOME/.cargo/env") so that would explain why it doesn't work after migrating (and why adding "export PATH=$PATH:~/.cargo/bin/" allows it to work again)

 

I'll see if I can migrate to an external script and test.

Edited by Stacks
Link to comment
  • 3 weeks later...
On 6/29/2023 at 7:11 AM, Andrew said:

@Stacks in the current 5.1.2 pre-release, I added the --no-rcs flag when selecting the /bin/zsh script language in a Script Filter or Run Script. This change is to prevent something in a .zshenv file from breaking the expected output in a script.

 

 

This is mentioned here: https://www.alfredapp.com/changelog/ but not yet expanded upon as we are still in the pre-release. If this change sticks through to the 5.1.2 general release, we will create a KB article to detail this change.

 

Having said that, this change should not affect your workflow if you're using External Script as the script language.

 

Would it be possible to share the workflow so we could take a look at why you're seeing a difference? Are you using a .zshenv file, if so, could we see the contents?

 

Cheers,

Andrew

 

This is a cool feature. I'll be updating my workflows with this as soon as 5.1.2 gets stable.

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...