facebook / pyre-check

Performant type-checking for python.

Home Page:https://pyre-check.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Internal crash: Raised in src/string.ml

hubyrod opened this issue · comments

Pyre Bug

Bug description
I hit the following error.

ƛ Raised at Base__String.index_from_exn_internal in file "src/string.ml", line 83, characters 7-22
ƛ Called from Base__String.lsplit2_exn.lsplit2_exn in file "src/string.ml", line 590, characters 14-54
ƛ Called from Base__String.lsplit2 in file "src/string.ml", line 608, characters 11-33

Reproduction steps
my .pyre_configuration file content:

{
  "site_package_search_strategy": "all",
  "source_directories": [
    "."
  ]
}

Expected behavior
Give a clear and concise description of what you expected to happen.

Logs

pyre_rage.log

Additional context
Note that it works with the following configuration:

{
  "site_package_search_strategy": "pep561",
  "source_directories": [
    "apps",
    "shared"
  ],
  "search_path": [
    "."
  ]
}

But it won't find any package I import in the project.
So i tried and added a path in search_path and it fails with the following configuration

{
  "site_package_search_strategy": "pep561",
  "source_directories": [
    "apps",
    "shared"
  ],
  "search_path": [
    ".", ".venv/lib/python3.11/site-packages"
  ]
}

My poetry env:

poetry env info

Virtualenv
Python:         3.11.3
Implementation: CPython
Path:           /Users/<my_alias>/dev/project-with-pyre/.venv
Executable:     /Users/<my_alias>/dev/project-with-pyre/.venv/bin/python
Valid:          True

System
Platform:   darwin
OS:         posix
Python:     3.11.3
Path:       /Users/<my_alias>/.pyenv/versions/3.11.3
Executable: /Users/<my_alias>/.pyenv/versions/3.11.3/bin/python3.11

Hey @hubyrod, thanks for letting us know about this. I'm not able to get too much from your error logs, so I'm going to try to reproduce it locally. When it fails with the last configuration you gave (search_path: [".", ".venv/lib/python3.11/site-packages"]), does it give you the same error?

hey @connernilsen
Sorry for the late reply. yes it does give me the same error.

Try setting your Pyre configuration to this and see if that helps:

{
  "site_package_search_strategy": "pep561",
  "source_directories": [
    "apps",
    "shared"
  ],
  "search_path": [
    ".venv/lib/python3.11/site-packages"
  ]
}

(so remove the "." search path). It's similar to the second configuration, but I'm hoping the difference in search path might be what's going wrong there.

I haven't been able to reproduce this myself on a couple of different machines, so if that's still not working, maybe try installing pyre-check-nightly (or building Pyre from source). I just checked and it seems that we haven't updated open source Pyre in a while, so it's possible it is a bug that we fixed a while ago that newer versions won't have.

That'd be great ! :)
have you plan to update open source soon ?
(in the meantime I'm going to give a try to the git version, I'll keep you posted)

To be fully honest, I work on python codebase big enough to make some other typechecker a pain because of slowness, and if Pyre could work it'd be awesome :)

(also, I have a few other issues like with sqlachemy for instance, so you know)

I'm working on publishing a new version now. It might take a day or two to get all the permissions needed, so let me know how your attempt works in the meantime.

Also, I'm glad to hear we can help out with your codebase!

hi @connernilsen

I am following these instructions: https://pyre-check.org/docs/installation/
But I'm hitting errors, unfortunately.
After what seems to be a smooth install, here are the last 4 lines before the shell prompt:

[2023-10-16 21:48:52,356] [INFO] ['make', 'dev']
abort: no repository found in '/Users/<my_alias>/dev/pyre-check/source' (.hg not found)
[2023-10-16 21:48:53,885] [INFO] ['make', 'test']
abort: no repository found in '/Users/<my_alias>/dev/pyre-check/source' (.hg not found)

Then, after entering the source directory I can run

make
make test

and beside having this warning, it looks fine.

So i open the directory with the codebase I'm working on and set it up to have the following:

$ alias | grep pyre
pyre='PYTHONPATH="~/dev/pyre-check/..:$PYTHONPATH" python -m pyre-check.client.pyre'

and

$ env | grep PYRE
PYRE_BINARY=/Users/<my_alias>/dev/pyre-check/source/_build/default/main.exe

for the following:

$ which pyre
pyre: aliased to PYTHONPATH="~/dev/pyre-check/..:$PYTHONPATH" python -m pyre-check.client.pyre

But calling pyre will only get me the following error:
/Users/<my_alias>/dev/alan-backend/.venv/bin/python: Error while finding module specification for 'pyre-check.client.pyre' (ModuleNotFoundError: No module named 'pyre-check')

Sorry if this is a naive error, easy to fix, but I am now blocked.

Also, have you managed to make release ?

Anyway, thank you for your patience ^^

Hey @hubyrod, I've had some team members that were trying to do a release last week, but we've been running into permissions issues. I think they've been sorted out, so they're expecting for the release to go out tomorrow.

As for the module not found issue, are you sourcing your venv after setting the PYTHONPATH?

Okay @hubyrod, I just finished a release (0.9.19)! Try that out and see if it helps.

That's great, and it seems indeed to be solved. Let's close this issue.

@connernilsen thank you again for your help !

No problem @hubyrod, glad we were able to fix it!