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

Working directory unexpectedly set to wherever noxfile.py is. #469

Closed
bcassell opened this issue Jul 21, 2021 · 5 comments · Fixed by #472
Closed

Working directory unexpectedly set to wherever noxfile.py is. #469

bcassell opened this issue Jul 21, 2021 · 5 comments · Fixed by #472

Comments

@bcassell
Copy link

Describe the bug
Trying to invoke nox from a different folder using the --noxfile flag sets the current working directory to where the noxfile lives. This makes reusing a noxfile across multiple projects in a monorepo very difficult, since I can't find a good way to set the current working directory to where nox was called from. Even passing '.' as a posarg will end up being interpreted as the directory where the noxfile lives

Expected behavior
Either the cwd stays as wherever nox is called from, or we have some command line arg for what to treat as the cwd. If this feature already exists and I've missed it, or there are some other recommendations for how to use a single nox file across multiple projects, please let me know!

@theacodes
Copy link
Collaborator

theacodes commented Jul 21, 2021

This is very much intentional behavior and it's to let noxfiles care less about how it was executed - specifically, so it can make assumptions about where it's working from so it can read, edit, import, etc files as expected.

I think we could make the original cwd available as a property of the session, though. The chdir happens here.

@bcassell
Copy link
Author

Available as a session property would be perfect.

@DiddiLeija
Copy link
Collaborator

Hello @theacodes. I'm interested on this issue, if no one is working on it. Can you please tell me what do I have to do (I'm a bit new to the concept)?

@theacodes
Copy link
Collaborator

@DiddiLeija you could store the original cwd in global_config and then allow the session to access that. The code starts here: https://github.com/theacodes/nox/blob/8ee3ebed052ed7eeef0151a424929039dd479b94/nox/tasks.py#L64

@DiddiLeija
Copy link
Collaborator

Got it. I will open a PR on the next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants