{"id":8145,"library":"fabric3","title":"Fabric3","description":"Fabric3 is a Python library and command-line tool designed for remote execution and deployment over SSH, forked from the original Fabric 1.x to provide compatibility with Python 3.4+. While it achieved Python 3 support, the official Fabric project (versions 2.x and above, and eventually 1.15.0) subsequently gained Python 3 compatibility and a redesigned API, rendering Fabric3 obsolete. It is now considered an unauthorized and deprecated fork.","status":"deprecated","version":"1.14.post1","language":"en","source_language":"en","source_url":"https://github.com/mathiasertl/fabric/","tags":["deployment","ssh","remote execution","automation","python2","python3","deprecated"],"install":[{"cmd":"pip install fabric3","lang":"bash","label":"Install Fabric3"}],"dependencies":[{"reason":"SSH protocol implementation; requires >=1.17.0 for Python 3 compatibility.","package":"paramiko","optional":false},{"reason":"Compatibility layer for Python 2 and 3.","package":"six","optional":false}],"imports":[{"note":"Primary function for executing remote shell commands.","symbol":"run","correct":"from fabric.api import run"},{"note":"Global dictionary for Fabric's environment settings (Fabric 1.x style).","symbol":"env","correct":"from fabric.api import env"},{"note":"Function for executing local shell commands.","symbol":"local","correct":"from fabric.api import local"},{"note":"Context manager for changing remote directory.","symbol":"cd","correct":"from fabric.api import cd"},{"note":"Function for executing remote commands with superuser privileges.","symbol":"sudo","correct":"from fabric.api import sudo"},{"note":"Function for uploading files to remote hosts.","symbol":"put","correct":"from fabric.api import put"},{"note":"Function for downloading files from remote hosts.","symbol":"get","correct":"from fabric.api import get"}],"quickstart":{"code":"# fabfile.py\nfrom fabric.api import run, env, sudo, put\n\n# Configure hosts (replace with actual SSH connection details)\nenv.hosts = ['user@your_remote_host_ip']\nenv.password = 'your_ssh_password' # Or use SSH agent/key\nenv.warn_only = True # Don't abort on non-zero exit codes\n\ndef deploy():\n    print(f\"Deploying to {env.host_string}...\")\n    # Example: Update package lists and install nginx\n    sudo('apt-get update && apt-get install -y nginx')\n    run('service nginx start')\n    print(\"Nginx installed and started.\")\n\n    # Example: Upload a local file\n    local_path = '/tmp/test_file.txt'\n    remote_path = '/tmp/remote_test.txt'\n    with open(local_path, 'w') as f:\n        f.write('Hello from Fabric3!')\n    put(local_path, remote_path)\n    run(f'cat {remote_path}')\n    print(\"File uploaded and content verified.\")\n\n# To run this from your terminal:\n# fab deploy\n","lang":"python","description":"Create a file named `fabfile.py`. Define functions which will be executed as tasks. The `env` object is used for global configuration such as hosts and credentials. Tasks are executed from the command line using the `fab` command, e.g., `fab deploy`."},"warnings":[{"fix":"Migrate your codebase to the official Fabric library (pip install fabric). Be aware that Fabric 2.x+ introduces breaking API changes (e.g., uses Connection objects instead of global 'env' state).","message":"Fabric3 is an unauthorized and deprecated fork of Fabric 1.x. The official Fabric library (versions 2.x and above) now natively supports Python 3 and has a significantly different, more modern API. Continued use of Fabric3 is strongly discouraged.","severity":"breaking","affected_versions":"All Fabric3 versions"},{"fix":"Transition to the official `fabric` package. For co-existence with Fabric 1.x, the official `fabric2` PyPI package provides Fabric 2.x+ under a distinct name. Users are encouraged to fully migrate to Fabric 2.x+ to avoid future compatibility issues.","message":"The primary maintainers of the original Fabric project explicitly state that they do not control the `fabric3` PyPI entry and there will be no official `fabric3` or `fabric4` releases. The 1.x branch of mainline Fabric itself gained Python 3 support in version 1.15.0.","severity":"deprecated","affected_versions":"All Fabric3 versions"},{"fix":"When migrating to Fabric 2.x+, refactor code to use `Connection` instances for managing host-specific configurations and operations. This provides better isolation and thread-safety.","message":"Fabric 1.x (and thus Fabric3) relies heavily on a global `env` object for configuration, which can lead to issues in concurrent or complex environments. Fabric 2.x+ uses explicit `Connection` objects.","severity":"gotcha","affected_versions":"All Fabric3 versions"},{"fix":"Replace `fabric.utils.RingBuffer` with `collections.deque` from Python's standard library.","message":"The `fabric.utils.RingBuffer` utility was removed in Fabric 1.x and should not be used. It was commonly replaced by `collections.deque`.","severity":"gotcha","affected_versions":"Fabric3 1.14.post1 and later (inherited from Fabric 1.x changes)"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure Fabric3 is installed for your current Python interpreter (`pip show fabric3`). Verify that the Python Scripts directory (e.g., ~/.local/bin on Linux, or C:\\Python\\Scripts on Windows) is included in your system's PATH. If using virtual environments, activate the environment before running `fab`.","cause":"Fabric3's command-line tool 'fab' is not in your system's PATH, or Fabric3 was not installed correctly for your active Python environment.","error":"Command 'fab' not found"},{"fix":"If you intend to use Fabric3, ensure it's installed (`pip install fabric3`). If you are migrating to the official Fabric 2.x+, the main import is `from fabric import Connection, task` and `fabric.api` no longer exists.","cause":"Fabric3 is either not installed, or you are trying to import `fabric.api` in an environment where the official `fabric` library (2.x+) is installed, which changed its import paths.","error":"ImportError: No module named 'fabric.api'"},{"fix":"Ensure your local and remote environments are configured to use UTF-8. For example, set `LANG=en_US.UTF-8` and `LC_ALL=en_US.UTF-8` in your shell environments. Fabric3 (and Fabric 1.15.0) addressed some `UnicodeDecodeError` issues, but environment misconfiguration can still cause problems.","cause":"This often occurs when remote output or file content contains non-ASCII characters and the terminal or Python environment defaults to an 'ascii' encoding.","error":"UnicodeDecodeError: 'ascii' codec can't decode byte 0x__ in position __: ordinal not in range(128)"}]}