Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6820937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:29:07+00:00 2026-05-26T21:29:07+00:00

In Fabric, when I try to use any alias’ or functions from my .bash_profile

  • 0

In Fabric, when I try to use any alias’ or functions from my .bash_profile file, they are not recognized. For instance my .bash_profile contains alias c='workon django-canada', so when I type c in iTerm or Terminal, workon django-canada is executed.

My fabfile.py contains

def test():
    local('c')

But when I try fab test it throws this at me:
[localhost] local: c

/bin/sh: c: command not found

Fatal error: local() encountered an error (return code 127) while executing 'c'

Aborting.

Other Fabric functions work fine. Do I have to specify my bash profile somewhere in fabric?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T21:29:08+00:00Added an answer on May 26, 2026 at 9:29 pm

    EDIT – As it turns out, this was fixed in Fabric 1.4.4. From the changelog:

    [Feature] #725: Updated local to allow override of which local shell is used. Thanks to Mustafa Khattab.

    So the original question would be fixed like this:

    def test():
        local('c', shell='/bin/bash')
    

    I’ve left my original answer below, which only relates to Fabric version < 1.4.4.


    Because local doesn’t use bash. You can see it clearly in your output

    /bin/sh: c: command not found
    

    See? It’s using /bin/sh instead of /bin/bash. This is because Fabric’s local command behaves a little differently internally than run. The local command is essentially a wrapper around the subprocess.Popen python class.

    http://docs.python.org/library/subprocess.html#popen-constuctor

    And here’s your problem. Popen defaults to /bin/sh. It’s possible to specify a different shell if you are calling the Popen constructor yourself, but you’re using it through Fabric. And unfortunately for you, Fabric gives you no means to pass in a shell, like /bin/bash.

    Sorry that doesn’t offer you a solution, but it should answer your question.

    EDIT

    Here is the code in question, pulled directly from fabric’s local function defined in the operations.py file:

    p = subprocess.Popen(cmd_arg, shell=True, stdout=out_stream,
        stderr=err_stream)
    (stdout, stderr) = p.communicate()
    

    As you can see, it does NOT pass in anything for the executable keyword. This causes it to use the default, which is /bin/sh. If it used bash, it’d look like this:

    p = subprocess.Popen(cmd_arg, shell=True, stdout=out_stream,
        stderr=err_stream, executable="/bin/bash")
    (stdout, stderr) = p.communicate()
    

    But it doesn’t. Which is why they say the following in the documentation for local:

    local is simply a convenience wrapper around the use of the builtin Python subprocess module with shell=True activated. If you need to do anything special, consider using the subprocess module directly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I try to use fabric, it gives me a remote shell after I
Fabric displays Disconnecting from username@server... done. for almost 2 minutes prior to showing a
I need to use Fabric to do some operations in a website that use
I use overlay image on my Fabric.js and it is added like this: canvas.setOverlayImage('image.png',
I'm attempting to use fabric for the first time and I really like it
How can I pass a parameter to a fabric task when calling fab from
Where do I go to configure the Windows Azure Dev Fabric to use SQL
Consider this simple fabric file: def wrapper(): f1() f2() @hosts([host1]) def f1(): run('ls') @hosts([host2])
I'm trying to use the Fabric 0.1.1 deploy tool ( http://docs.fabfile.org/ ) on Windows
I have the following fabfile.py: from fabric.api import env, run host1 = '192.168.200.181' host2

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.