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

Wrong starting directory when noxfile.py is a symlink #828

Open
rsyring opened this issue May 16, 2024 · 5 comments · May be fixed by #829
Open

Wrong starting directory when noxfile.py is a symlink #828

rsyring opened this issue May 16, 2024 · 5 comments · May be fixed by #829

Comments

@rsyring
Copy link

rsyring commented May 16, 2024

I have a project where I want the noxfille to be a symlink to a different shared file. When I do this, it throws off the paths b/c nox follows the symlink and starts in that directory instead of starting in the directory where the symlink is.

 ❯ ls -l noxfile.py 
lrwxrwxrwx 1 rsyring rsyring 21 May 15 23:09 noxfile.py -> ./template/noxfile.py

 ❯ nox -s cwd
nox > Running session cwd
nox > Creating virtual environment (uv) using python3 in .nox/cwd
cwd is: /home/rsyring/projects/copier-py-package/template

Was this an intentional design decision? If not, how about starting where the symlink is instead (i.e. don't follow it)?

Thanks for your work on this project and consideration.

@cjolowicz
Copy link
Collaborator

Thanks, PR welcome. Take a look in load_nox_module in tasks.py.

@henryiii
Copy link
Collaborator

That happens here:

global_config.noxfile = os.path.realpath(

The one below is fine (takes the global path of the dir), maybe it should just use that and reassemble the name.

@henryiii henryiii linked a pull request May 19, 2024 that will close this issue
@jamesharris-garmin
Copy link

I actually use this behavior with the repo tool to symlink a nox-file into the root of of my repo client clone directory and expect that the sessions I reference occur in a sub directory. It probably isn't a huge deal if you modify this behavior (I can also make it symlink the folders/change the paths.) but I thought I should note that there is someone out here who uses this behavior.

@henryiii
Copy link
Collaborator

henryiii commented Oct 7, 2024

What I'm thinking we can provide a .noxfiledir attribute (or similar name) that gives the original directory to the noxfile. For most users, this might just be handy to have (say if they've cd'd in their session), but for the case where the noxfile is a symlink, it would be the original noxfile dir, while the working directory would be the symlink dir.

@henryiii
Copy link
Collaborator

henryiii commented Oct 7, 2024

(Or would it make sense to have a .noxfile attribute, and let the user compute dirs with it? We already have sessions.global_config.noxfile, maybe we could ensure that was unresolved?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

4 participants