Jump to content

Load the user's shell?


Recommended Posts

I'm working on a shell script that needs to execute some commands installed with homebrew. It's not working, because the path is different in the shell Alfred uses. For instance, if I do "which ruby" in my own shell I get a path to the Ruby version I've installed with homebrew, but if I do the same with my script I get "/usr/bin/ruby" which is the system default.

 

 

How do I get access to the same shell as the default one, the one where homebrew is available? I've tried sourcing .bash_profile but that doesn't help.

Link to comment

I had a similar problem with PHP where I wanted to run different MAMP versions.

As you have found, the path used by Alfred is not affected by your profile.

I ended up copying the built in /usr/bin/php to /usr/bin/php.osx and creating a symlink from /usr/bin/php to whatever PHP version I wanted to run.

It was tedious to change the symlink to a different PHP version so I created a workflow to make things easier (PHP Version).

An alternative may be to use the full path to the version you want to run.

I'd be interested to learn of a more simple way of doing this.

Edited by bscott
Link to comment

I'm working on a shell script that needs to execute some commands installed with homebrew. It's not working, because the path is different in the shell Alfred uses. For instance, if I do "which ruby" in my own shell I get a path to the Ruby version I've installed with homebrew, but if I do the same with my script I get "/usr/bin/ruby" which is the system default.

 

 

How do I get access to the same shell as the default one, the one where homebrew is available? I've tried sourcing .bash_profile but that doesn't help.

If you're just running it on your own system, then you can adjust the PATH setting in /etc/launchd.conf to have it seen by GUI apps. touch launchd.conf, then add export PATH /paste/in/your/path/settings. But you shouldn't require a user to do that, so you should probably just invoke Ruby with the full path in your script. (Though I'd also say that you probably shouldn't require a user to install a brew version of Ruby.)

Link to comment

If you're just running it on your own system, then you can adjust the PATH setting in /etc/launchd.conf to have it seen by GUI apps. touch launchd.conf, then add export PATH /paste/in/your/path/settings. But you shouldn't require a user to do that, so you should probably just invoke Ruby with the full path in your script. (Though I'd also say that you probably shouldn't require a user to install a brew version of Ruby.)

Ruby was just an example :) I was actually working on a workflow to control the settings of a homebrew package, but it looks like that won't be possible.

Link to comment

Ruby was just an example :) I was actually working on a workflow to control the settings of a homebrew package, but it looks like that won't be possible.

Gotcha; I assumed you were using a custom version of Ruby to execute your workflow, which I tend to consider bad form. Sorry!

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