astral-sh / rye

a Hassle-Free Python Experience
https://rye.astral.sh
MIT License
13.88k stars 467 forks source link

when execute the `rye sync` command, error `could not write production lockfile for project` occured #1048

Open hero opened 7 months ago

hero commented 7 months ago

Steps to Reproduce

I did the following steps:

# Step 1
# Refer to the official documentation to create a runnable project
# https://rye-up.com/guide/basics/#executable-projects
$ rye init --script hello-rye
success: Initialized project in ~\Desktop\hello-rye

# Step 2
# Fix the Python version
$ rye pin 3.12
pinned 3.12.2 in ~\Desktop\hello-rye\.python-version

# Step 3
# First Sync
$ rye sync
Initializing new virtualenv in ~\Desktop\hello-rye\.venv
Python version: cpython@3.12.2
Generating production lockfile: ~\Desktop\hello-rye\requirements.lock
error: could not write production lockfile for project

Caused by:
    0: unable to run pip-compile
    1: 系统找不到指定的文件。 (os error 2)

Expected Result

After first rye sync, I could run the command:

$ rye run hello-rye

Actual Result

Reusing already existing virtualenv
Generating production lockfile: C:\Users\wuking\Desktop\hello-rye\requirements.lock
error: could not write production lockfile for project

Caused by:
    0: unable to run pip-compile
    1: 系统找不到指定的文件。 (os error 2)

Version Info

 $ rye --version
rye 0.33.0
commit: 0.33.0 (58523f69f 2024-04-24)
platform: windows (x86_64)
self-python: cpython@3.12.2
symlink support: true
uv enabled: false

Stacktrace

$ $env:RUST_BACKTRACE=1
$ rye sync
Reusing already existing virtualenv
Generating production lockfile: C:\Users\wuking\Desktop\hello-rye\requirements.lock
error: could not write production lockfile for project

Caused by:
    0: unable to run pip-compile
    1: 系统找不到指定的文件。 (os error 2)

Stack backtrace:
   0: <unknown>
   1: <unknown>
   2: <unknown>
   3: <unknown>
   4: <unknown>
   5: <unknown>
   6: <unknown>
   7: <unknown>
   8: <unknown>
   9: <unknown>
  10: <unknown>
  11: <unknown>
  12: <unknown>
  13: <unknown>
  14: <unknown>
  15: BaseThreadInitThunk
  16: RtlUserThreadStart
hero commented 7 months ago

And if I pin the Python version to 3.10, rye sync worked as expected.

$ rye sync
Python version mismatch (found cpython@3.12.2, expected cpython@3.10.14), recreating.
Initializing new virtualenv in ~\Desktop\hello-rye\.venv
Python version: cpython@3.10.14
Generating production lockfile: ~\Desktop\hello-rye\requirements.lock
Generating dev lockfile: ~\Desktop\hello-rye\requirements-dev.lock
Installing dependencies
Looking in indexes: https://pypi.org/simple/
Obtaining file:///. (from -r ~\AppData\Local\Temp\tmpzl6nlh_p (line 1))
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... done
  Installing backend dependencies ... done
  Preparing editable metadata (pyproject.toml) ... done
Building wheels for collected packages: hello-rye
  Building editable for hello-rye (pyproject.toml) ... done
  Created wheel for hello-rye: filename=hello_rye-0.1.0-py3-none-any.whl size=1296 sha256=fbb441ad15cc3e681cdde1464b0cacdc1784f709deddb62a11384c43e1e3b922
  Stored in directory: ~\AppData\Local\Temp\pip-ephem-wheel-cache-9ek95v9e\wheels\78\12\b9\db4c72ae1aebdfd866f484b59eb7b39f206b7d7d1080ae28b1
Successfully built hello-rye
Installing collected packages: hello-rye
Successfully installed hello-rye-0.1.0
Done!

The Python 3.12 was installed automatically when I install the rye, and Python 3.10 was the one I fetched manually.

hero commented 7 months ago

Also I've test the same actions in WSL2, rye works as expected.