Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to use a pathlib.Path instance as a cd argument #681

Closed
wants to merge 3 commits into from
Closed

Allow to use a pathlib.Path instance as a cd argument #681

wants to merge 3 commits into from

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.

None yet

3 participants