Skip to content

Conversation

@mariocesar
Copy link

@mariocesar mariocesar commented Nov 22, 2019

from pathlib import Path

basedir = Path(__file__).parent.resolve()

@task
def deploy(ctx):
    with ctx.cd(basedir):
        ctx.run("ls -al")

Will fail with

File "/python/lib/python3.7/site-packages/invoke/context.py", line 94, in run
    return self._run(runner, command, **kwargs)
  File "/python/lib/python3.7/site-packages/invoke/context.py", line 100, in _run
    command = self._prefix_commands(command)
  File "/python/lib/python3.7/site-packages/invoke/context.py", line 242, in _prefix_commands
    current_directory = self.cwd
  File "/python/lib/python3.7/site-packages/invoke/config.py", line 123, in __getattr__
    raise AttributeError(err)
AttributeError: No attribute or config key found for 'cwd'

This is due that when getting the cwd value it expects to have an string type value.

By converting any cd argument to an string, it now supports to use pathlib.Path instances.

@mariocesar mariocesar marked this pull request as ready for review November 22, 2019 15:02
@russkel
Copy link

russkel commented Jan 11, 2020

Relevant issue #454

@bitprophet
Copy link
Member

Rolling into #607

@bitprophet bitprophet closed this Dec 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants