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

[BUG] check-license failing sometimes #2528

Closed
artemiogr97 opened this issue May 5, 2024 · 6 comments
Closed

[BUG] check-license failing sometimes #2528

artemiogr97 opened this issue May 5, 2024 · 6 comments
Labels
bug Something isn't working mojo-repo Tag all issues with this label mojo-stdlib Tag for issues related to standard library

Comments

@artemiogr97
Copy link
Contributor

artemiogr97 commented May 5, 2024

Bug description

The pre-commit hook for license checking is failing sometimes.
I had not been able to understand when it happens, from the log it seems like my stdlib.mojopkg is not found but running an script in the same terminal by doing mojo path/to/my/script works (and the stdlib in my build directory is used).

Steps to reproduce

just do git commit, I get the following log:

[INFO] Stashing unstaged files to /home/temo/.cache/pre-commit/patch1714911965-57965.
mojo-format..............................................................Passed
check-docstrings.........................................................Passed
check-license............................................................Failed
- hook id: check-license
- exit code: 1

/home/temo/repos/mojo/build/stdlib.mojopkg:0:0: error: attempting to skip 4 bytes when only 0 remain
/home/temo/repos/mojo/stdlib/scripts/check-licenses.mojo:14:1: error: unable to load package '/home/temo/repos/mojo/build/stdlib.mojopkg'
import sys
^
/home/temo/repos/mojo/stdlib/scripts/check-licenses.mojo:14:8: error: unable to locate module 'sys'
import sys
       ^
/home/temo/repos/mojo/stdlib/scripts/check-licenses.mojo:15:6: error: unable to locate module 'pathlib'
from pathlib import Path
     ^
/home/temo/repos/mojo/stdlib/scripts/check-licenses.mojo:19:17: error: use of unknown declaration 'String'
alias LICENSE = String(
                ^~~~~~
/home/temo/repos/mojo/stdlib/scripts/check-licenses.mojo:27:11: error: could not find an 'object' type
def main():
          ^
/home/temo/repos/mojo/stdlib/scripts/check-licenses.mojo:27:11: error: could not find an 'Error' type
def main():
          ^
/home/temo/repos/mojo/stdlib/scripts/check-licenses.mojo:27:5: error: could not find an 'object' type
def main():
    ^
/home/temo/repos/mojo/stdlib/scripts/check-licenses.mojo:27:5: error: unable to locate module 'builtin'
def main():
    ^
/home/temo/repos/mojo/stdlib/scripts/check-licenses.mojo:28:1: error: 
    target_paths = sys.argv()
^
/home/temo/.modular/pkg/packages.modular.com_nightly_mojo/bin/mojo: error: failed to parse the provided Mojo source module

System information

- What OS did you do install Mojo on ?
WSL ubuntu 22.04.4 in windows 11
- Provide version information for Mojo by pasting the output of `mojo -v`
mojo 2024.5.323 (1d9276ea)
- Provide Modular CLI version by pasting the output of `modular -v`
modular 0.7.2 (d0adc668)
@artemiogr97 artemiogr97 added bug Something isn't working mojo-repo Tag all issues with this label labels May 5, 2024
@artemiogr97
Copy link
Contributor Author

@gabrieldemarmiesse any ideas? maybe using a python hook would be a workaround for now?

@gabrieldemarmiesse
Copy link
Contributor

Mhhh indeed that's hard to know what was going on. My guess is that at that time, either the stdlib.mojopkg wasn't build yet, or the environment variable setting the path to the stdlib.mojopkg wasn't set correctly. I must admit it's hard to find out what exactly happened without being able to reproduce

@artemiogr97
Copy link
Contributor Author

yep that was my guess too, but I ran both commands in the same terminal one after the other (I tried git commit and then mojo path/to/my/script and also mojo path/to/my/script and then git commit, in both cases git commit failed but the other command succeeded), it's really weird

@artemiogr97
Copy link
Contributor Author

I found the issue, I did what is mentioned in development.md:

### Bonus tip: fast feedback loop
If you like a fast feedback loop, try installing the file watcher `entr`, which
you can get with `sudo apt install entr` on Linux, or `brew install entr` on
macOS. Now run:
```bash
export MODULAR_MOJO_NIGHTLY_IMPORT_PATH=../build
ls **/*.mojo | entr sh -c "./scripts/build-stdlib.sh && mojo main.mojo"
```
Now, every time you save a Mojo file, it packages the standard library and
runs `main.mojo`.

Every time I commit entr tries to compile so the pre-commit is ran while compiling stdlib, so maybe it is worth adding a comment in the doc @gabrieldemarmiesse ?

@gabrieldemarmiesse
Copy link
Contributor

Nice one! Indeed, that makes sense that it didn't work. Yes feel free to open a PR with a comment in the guide

@ematejska ematejska added mojo-repo Tag all issues with this label and removed mojo-repo Tag all issues with this label labels May 6, 2024
@ematejska
Copy link
Collaborator

Thanks for this issue!

@ematejska ematejska added the mojo-stdlib Tag for issues related to standard library label May 7, 2024 — with Linear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mojo-repo Tag all issues with this label mojo-stdlib Tag for issues related to standard library
Projects
None yet
Development

No branches or pull requests

3 participants