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 passing cwd in tool.rye.scripts #930

Open
jd-solanki opened this issue Mar 23, 2024 · 2 comments · May be fixed by #932
Open

✨ Allow passing cwd in tool.rye.scripts #930

jd-solanki opened this issue Mar 23, 2024 · 2 comments · May be fixed by #932

Comments

@jd-solanki
Copy link

Hi 👋🏻

I'm using tool.rye.scripts for running django server from root of the project and it looks like below:

[tool.rye.scripts]
dev = "python src/django_marketplace/manage.py runserver"

Problem

If I'm already inside src dir and run rye run dev then it gives error due to incorrect dir I'm in.

Solution

Provide cwd option so we can run rye scripts from anywhere in the project

dev = { cmd = "python manage.py runserver", cwd: "src/django_marketplace" }

Another benefit can be cmd option will be much cleaner.

@j178
Copy link
Contributor

j178 commented Mar 23, 2024

I checked PDM and pipenv, neither support setting cwd. We might just need to set the cwd to the project root.

UPDATE: PDM is going to add a working_dir option in the next version: pdm-project/pdm#2694

j178 added a commit to j178/rye that referenced this issue Mar 23, 2024
@j178 j178 linked a pull request Mar 23, 2024 that will close this issue
@j178
Copy link
Contributor

j178 commented Mar 23, 2024

And npm run:

Scripts are run from the root of the package folder, regardless of what the current working directory is when npm run is called. If you want your script to use different behavior based on what subdirectory you're in, you can use the INIT_CWD environment variable, which holds the full path you were in when you ran npm run.

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 a pull request may close this issue.

2 participants