question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Local commands unsupported in fabric >=2?

See original GitHub issue

Do you have a local example?

Is local support totally unsupported since version 1 fabric? There’s no good docs by example, and the methods / support is non-existent now.

fab -f fabfile.py  log_local
No idea what 'log_local' is!

python

from fabric import Connection
from invoke import task, Exit
from invocations.console import confirm

# pip install invocations

@task
def log_local(c):
    """[Run ls -la on localhost]

    Arguments:
        c {[Connection]} -- [Explicit initial context argument, whose value will be a Connection object at runtime.]
    """
    c.local('ls -la')

This was following example here https://github.com/fabric/fabric/issues/1747

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:8

github_iconTop GitHub Comments

3reactions
christian-intra2netcommented, Sep 27, 2019

You can ensure c is always a fabric Connection by giving a default host name to task():

@task(host='localhost')
def test(c):
    c.local('hostname')
    c.run('hostname')

But I also wonder why the author chose this behaviour (changing the type of c depending on host value). I would much prefer if c was always a fabric Connection, with c.local == c.run if no host is given.

1reaction
JamesRammcommented, Jan 15, 2019

Hey @jondkelley @thrownblown

tldr; use run instead of local and don’t specify the --hosts flag

local commands are supported but now there is no difference between run and local. If you don’t specify --hosts, then the Connection object falls back to being a regular Context object from invoke, and run works locally

Try this fabfile:


@task
def test(c):
  print(c)
  c.run("echo HELLO")

Running fab test will print ‘HELLO’, plus c, which will be a Context object.

Running fab --hosts=<host connection string> test will print ‘HELLO’ plus c which will be a Connection object

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developers - Local commands unsupported in fabric >=2? -
Is local support totally unsupported since version 1 fabric? There's no good docs by example, and the methods / support is non-existent now....
Read more >
Hyperledger Fabric Local Fabric binary version does not ...
Hi.. I am trying to upgrade Hyperledger Fabric. To do this, i ran the following commands: ./byfn.sh down git fetch origin git checkout ......
Read more >
error while deploying bna file to local hyperledger fabric
I have installed all the tools as required and mentioned on hyperledger.github.io/composer/installing/development-tools.html with the correct ...
Read more >
Error - Creating Channel - fabric@lists.hyperledger.org
Command used : /home/hduser/fabric-tools/bin/configtxgen -profile ... 002 Error reading configuration: Unsupported Config Type "" 2018-02-12 ...
Read more >
Cisco DCNM LAN Fabric Configuration Guide, Release 11.4(1)
Post DCNM 11.4(1) Upgrade for VXLAN BGP EVPN, External, and MSD Fabrics; Changing ISIS Configuration from Level 1 to Level 2; Configuration ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found