diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d98c37a34..6ad4fffd95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ _Unreleased_ - Always create `.gitignore` file in `rye init`. #919 +- Invoke Rye scripts from the project root. #932 + ## 0.31.0 diff --git a/docs/guide/pyproject.md b/docs/guide/pyproject.md index 34db616b37..ae6a3a3ad4 100644 --- a/docs/guide/pyproject.md +++ b/docs/guide/pyproject.md @@ -127,6 +127,8 @@ with different keys with the most important key being `cmd` which holds the comm However if only `cmd` is set, then the object is optional. `cmd` itself can either be set to a string or an array of arguments. +Scripts are invoked from the root of the project (where the `pyproject.toml` is located). + ```toml [tool.rye.scripts] # These three options are equivalent: diff --git a/rye/src/cli/run.rs b/rye/src/cli/run.rs index 7db917d72b..dd94f1fa1d 100644 --- a/rye/src/cli/run.rs +++ b/rye/src/cli/run.rs @@ -138,6 +138,7 @@ fn invoke_script( let mut cmd = Command::new(&args[0]); cmd.args(&args[1..]); cmd.env("VIRTUAL_ENV", &*pyproject.venv_path()); + cmd.current_dir(pyproject.root_path()); if let Some(path) = env::var_os("PATH") { let mut paths = split_paths(&path).collect::>(); paths.insert(0, venv_bin.into());