ragusource Posted March 4, 2014 Share Posted March 4, 2014 Hi Guys, I am having an issue with the following bash script: cd /Volumes/Development/RAGUSOURCE/highlander IFS=', ' read -a args <<< '{query}' case ${args[0]} in status) echo `vagrant status` ;; up) echo `vagrant up` ;; *) echo 'Usage highlander {status|up|halt|ssh}' exit 1 ;; esac The commands run fine via the terminal, but not in a workflow. Link to comment
vitor Posted March 4, 2014 Share Posted March 4, 2014 Where is vagrant located? Alfred does not read your shell’s startup files, which is likely the problem. Either set your PATH on top of the script in Alfred, or use vagrant’s full path. Does it work? Link to comment
rice.shawn Posted March 4, 2014 Share Posted March 4, 2014 As a tip: if you need to find the full path to the "vagrant" binary, just type "which vagrant" in the terminal, and then use that path via Vitor's solution. Link to comment
ragusource Posted March 6, 2014 Author Share Posted March 6, 2014 The full path to vagrant is: /usr/bin/vagrant I tried the following: PATH=/usr/local/opt/ruby/bin:/usr/local/sbin:/usr/local/bin:/Users/rrajaratnam/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin cd /Volumes/Development/INTOFILM/highlander IFS=' ' read -a args <<< '{query}' case ${args[0]} in status) vagrant status ;; up) vagrant up ;; halt) vagrant halt ;; *) echo 'Usage highlander {status|up|halt}' exit 1 ;; esac That did not work, so I tried this: cd /Volumes/Development/INTOFILM/highlander IFS=' ' read -a args <<< '{query}' case ${args[0]} in status) /usr/bin/vagrant status ;; up) /usr/bin/vagrant up ;; halt) /usr/bin/vagrant halt ;; *) echo 'Usage highlander {status|up|halt}' exit 1 ;; esac That doesn't work either. Link to comment
rice.shawn Posted March 7, 2014 Share Posted March 7, 2014 The only possibility that I can think of right now is that Vagrant wants TTY in order to function. I've run into this problem before when working with certain cron jobs (and I just had to fake the TTY to make those work), and it's not one that is intuitive at all. But, my guess did turn up something: it does seem that some people have run into problems with Vagrant and TTY. Check this Github issue thread. It looks like there are possible solutions there. If that doesn't work, then could you try piping all the output to a log file and seeing which errors it throws? Link to comment
ragusource Posted March 7, 2014 Author Share Posted March 7, 2014 Hey Shawn, I updated my workflow to look like this: cd /Volumes/Development/INTOFILM/highlander IFS=' ' read -a args <<< '{query}' case ${args[0]} in status) /usr/bin/vagrant status > /var/tmp/highlander-status.log ;; up) /usr/bin/vagrant up > /var/tmp/highlander-up.log ;; halt) /usr/bin/vagrant halt > /var/tmp/highlander-halt.log ;; *) echo 'Usage highlander {status|up|halt}' exit 1 ;; esac However there is nothing in the logs that get generated, it's as if the command doesn't run at all. Link to comment
rice.shawn Posted March 7, 2014 Share Posted March 7, 2014 I'd say look more into the TTY stuff. When I was having problems with that, the logs were empty as well. Basically, when that sort of error happens, the command tries to load the necessary (or what it thinks are) necessary parameters for an interactive shell, but, when it doesn't, then the failure happens before the command can output an error. Sometimes it works that way; sometimes it doesn't. Let me know if you have any luck implementing some of the solutions mentioned on the Github issue page; it looks like some of the people who updated it have some pretty clever workarounds as, well, this sort of annoying thing needs a pretty clever workaround. For my purposes with the cron job, I had to have * * * * * /usr/bin/env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin COLUMNS=72 <COMMAND> in order to make the cron job work, so the screwy thing was that I had to tell the command to pretend that we had an interactive shell with a set number of columns (why would that matter? Apparently it does). But it looks like there are other more vagrant-specific solutions in that thread. Link to comment
ragusource Posted March 7, 2014 Author Share Posted March 7, 2014 Hey Shawn, I managed to get this to work. My issue was that I customised the vagrant dotfile path in my setup and when the script was running it couldn't find the dot path and was doing nothing. The following works for me: # Set env variables needed for vagrant export VAGRANT_DEFAULT_PROVIDER=vmware_fusion export VAGRANT_DOTFILE_PATH=/Users/rrajaratnam/.vagrant cd /Volumes/Development/INTOFILM/highlander IFS=' ' read -a args <<< '{query}' if [ ${args[0]} == "status" ] then /usr/bin/vagrant status fi Link to comment
rice.shawn Posted March 8, 2014 Share Posted March 8, 2014 Awesome. That makes sense because it's something that Terminal (or iTerm) would read when you launched a window, but Alfred doesn't do that. I'm glad you didn't have to mess with the TTY stuff. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now