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

fix(src/path_env.rs): Issue 2504: Fix for JoinPathsError #2511

Merged
merged 4 commits into from
Aug 27, 2024

Conversation

mcallaway
Copy link
Contributor

The original submitter of Issue 2504 triggered the JoinPathsError when adding a python env in the [env] section:

_.python.venv = { path = ".venv", create = true } # create the venv if it doesn't exist

I noticed the same error independently when using the poetry plugin and attempting to run [tasks]. Consider the following .mise.toml file that works fine:

[tools]
[tools.poetry]
version = 'latest'
pyproject = 'pyproject.toml'

[tools.python]
version = '3.11'
# Note this is commented out
#virtualenv = '.venv'

[tasks.foo]
run = "echo foo"

Running the foo task works:

❯ mise r foo
[foo] $ echo foo
foo

But now if I activate that virtualenv config line:

[tools]
[tools.poetry]
version = 'latest'
pyproject = 'pyproject.toml'

[tools.python]
version = '3.11'
virtualenv = '.venv'

[tasks.foo]
run = "echo foo"

Now running the task triggers the same JoinPathsErr:

❯ mise r foo
The application panicked (crashed).
Message:  called `Result::unwrap()` on an `Err` value: JoinPathsError { inner: JoinPathsError }
Location: src/path_env.rs:50

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.

In exploring the bug I observed that path_env.add() was being called with two copies of the .venv directory concatenated with a colon ":". So my fix is to update the add() function to check for this, split the path argument on ":" and add each element.

My proposed fix is in ./src/path_env.rs

…cause we're calling path_env.add() with a string containing a colon, meaning we're adding multiple path elements in the same call.
…ining a colon (:). First split, then add each element.
@mcallaway mcallaway changed the title Issue 2504: Fix for JoinPathsError fix(src/path_env.rs): Issue 2504: Fix for JoinPathsError Aug 27, 2024
@mcallaway
Copy link
Contributor Author

This PR addresses #2504

src/path_env.rs Outdated Show resolved Hide resolved
src/path_env.rs Show resolved Hide resolved
src/path_env.rs Outdated Show resolved Hide resolved
@jdx
Copy link
Owner

jdx commented Aug 27, 2024

Some minor feedback but this seems like a solid patch!

@jdx jdx merged commit 270adb8 into jdx:main Aug 27, 2024
10 checks passed
@mcallaway mcallaway deleted the issue_2504_joinpathserror branch August 28, 2024 00:51
triarius pushed a commit to triarius/mise that referenced this pull request Sep 18, 2024
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.

2 participants