rye: First-run experience failure: `rye run hello` after `rye init` + `rye sync` -- results in "ModuleNotFoundError: no module named 'xyz' ..."

Steps to Reproduce

  1. I created a basic project with rye init.
  2. I used the cpython@3.11.7 (but also tried with cpython@3.12.1) – these are the the only two toolchains installed
  3. rye run python works to pull up Python 3.11.7
  4. rye sync works without error
  5. rye run lists hello as a valid run argument
  6. but, rye run hello results in error

Expected Result

I would expect the hello() function to get called, which I imagine would just succeed since the default implementation of that function simply returns a string.

Actual Result

Traceback (most recent call last):
  File "/home/am/repos/xyz/.venv/bin/hello", line 5, in <module>
    from xyz import hello
ModuleNotFoundError: No module named 'xyz'

I should mention that I can “fix” this by doing the following from the root of the project:

cp -R src/xyz .venv/lib/python3.11/site-packages

At that point, rye run hello succeeds and returns:

❯ cp -R src/xyz .venv/lib/python3.11/site-packages/
❯ rye run hello
Hello from xyz!

But obviously I shouldn’t have to manually copy the project source into the .venv directory for rye run to work.

I thought maybe this had something to do with me using pyenv before rye, but I tried the same from a shell where I removed pyenv from the $PATH and also removed it from zsh plugins, and yet, still, rye behaved same way.

Version Info

rye 0.27.0
commit: 0.27.0 (43ee4fce0 2024-02-26)
platform: linux (x86_64)
self-python: cpython@3.12
symlink support: true
uv enabled: true

Stacktrace

RUST_BACKTRACE=1 has no effect on rye run, so I guess it’s not crashing.

About this issue

  • Original URL
  • State: closed
  • Created 4 months ago
  • Reactions: 1
  • Comments: 25 (7 by maintainers)

Most upvoted comments

Yeah this unfortunately is a bug in hatch. I’m still considering whether hatch is a good default build tool choice, and if maybe setuptools would be a better default for now. For now I’m going to close this.