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

uv pip compile sometimes outputs ansi escapes in file #2017

Closed
bluss opened this issue Feb 27, 2024 · 2 comments · Fixed by #2018
Closed

uv pip compile sometimes outputs ansi escapes in file #2017

bluss opened this issue Feb 27, 2024 · 2 comments · Fixed by #2018
Assignees
Labels
bug Something isn't working cli Related to the command line interface

Comments

@bluss
Copy link
Contributor

bluss commented Feb 27, 2024

Experienced behaviour: Can't call "rye add" or "rye sync" when uv is enabled in rye, from a jupyterlab python kernel command line.

I think this could be a bug in uv, that's why I'm reporting it here. This is how I reproduce it:

  1. Using jupyterlab (v3.6 or v4.1 both show this problem), create a new notebook in a new directory.
  2. Write 'numpy>=1.2' to 'requirements.txt'
  3. Run !uv pip compile -o "outputfile" "requirements.txt" in a python notebook
  4. Bug: outputfile contains ansi escapes in the lockfile output.

For some reason this happens in the notebook environment but not in a regular terminal. The original bug in rye seems to be related to this - it also gets this behaviour when called from a notebook. Rye could work around it using --no-color, but it might be something that can be fixed in uv.

When using rye in the notebook the output looks something like this:

!rye add numpy
Added numpy>=1.26.4 as regular dependency
Reusing already existing virtualenv
Generating production lockfile: /.../newjupyterlabproject/requirements.lock
error: Unexpected '�', expected '-c', '-e', '-r' or the start of a requirement in `/tmp/.tmpXbPWlj/requirements.txt` at position 221
error: could not write production lockfile for project

Caused by:
    failed to generate lockfile

uv 0.1.11
Linux

@trag1c
Copy link
Contributor

trag1c commented Feb 27, 2024

It also affects VSCode notebooks 👍

@charliermarsh charliermarsh added the bug Something isn't working label Feb 27, 2024
@charliermarsh
Copy link
Member

Thanks!

@charliermarsh charliermarsh added the cli Related to the command line interface label Feb 27, 2024
@konstin konstin self-assigned this Feb 27, 2024
konstin added a commit that referenced this issue Feb 27, 2024
Always strip color codes when we're writing to a file.

I don't really know how to test this.

Fixes #2017
konstin added a commit that referenced this issue Feb 27, 2024
Always strip color codes when we're writing to a file.

I don't really know how to test this.

Fixes #2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cli Related to the command line interface
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants