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

Error writing grammar tables #10

Closed
EWouters opened this issue Feb 7, 2019 · 19 comments
Closed

Error writing grammar tables #10

EWouters opened this issue Feb 7, 2019 · 19 comments

Comments

@EWouters
Copy link

EWouters commented Feb 7, 2019

I get an error upon launching Jupyter Lab with this extension enabled:

[I 10:37:25.686 LabApp] Node v10.8.0

[I 10:37:26.075 LabApp] Build is up to date
Generating grammar tables from C:\Users\%USERNAME%\Anaconda3\lib\site-packages\blib2to3\Grammar.txt
Writing grammar tables to C:\Users\%USERNAME%\AppData\Local\black\black\Cache\18.9b0\Grammar3.7.1.final.0.pickle
Writing failed: [Errno 2] No such file or directory: 'C:\\Users\\%USERNAME%\\AppData\\Local\\black\\black\\Cache\\18.9b0\\Grammar3.7.1.final.0.pickle'
Generating grammar tables from C:\Users\%USERNAME%\Anaconda3\lib\site-packages\blib2to3\PatternGrammar.txt
Writing grammar tables to C:\Users\%USERNAME%\AppData\Local\black\black\Cache\18.9b0\PatternGrammar3.7.1.final.0.pickle
Writing failed: [Errno 2] No such file or directory: 'C:\\Users\\%USERNAME%\\AppData\\Local\\black\\black\\Cache\\18.9b0\\PatternGrammar3.7.1.final.0.pickle'

After manually creating the folder C:\\Users\\%USERNAME%\\AppData\\Local\\black\\black\\Cache\\18.9b0 and relaunching Jupyter lab the error disappears (even though the folder seems to stay empty).

@ryantam626
Copy link
Collaborator

Hey! This seems to be Python in Windows shenanigans, this is something that this package will not aim to fix/workaround, thanks for the heads up though 👍 , shall put it in the readme

@bjtho08
Copy link

bjtho08 commented Jun 3, 2019

@ryantam626 I seem to experience the same issue on Ubuntu 16.04, so it appears to be OS independent.

@ryantam626
Copy link
Collaborator

Did you use your system's python to install jupyterlab or virtualenv/conda?

@ryantam626 ryantam626 reopened this Jun 3, 2019
@bjtho08
Copy link

bjtho08 commented Jun 4, 2019

I actually use pyenv. Could that have something to do with the issue?

@ryantam626
Copy link
Collaborator

Hmm not that familiar with pyenv, but possibly. I think this is because the jupyterlab server is spawned with user that doesn't have privilege to create the cache needed for black. Did it work for you in the end? You could try creating the cache dir youself and chown to you user if not 🤔

@roachsinai
Copy link

Same issue on Manjaro, using virtualenv.

[I 07:45:47.225 LabApp] Build is up to date
Generating grammar tables from /home/roach/.virtualenvs/nn/lib/python3.7/site-packages/blib2to3/Grammar.txt
Writing grammar tables to /home/roach/.cache/black/19.3b0/Grammar3.7.3.final.0.pickle
Writing failed: [Errno 2] No such file or directory: '/home/roach/.cache/black/19.3b0/tmpuxr828wb'
Generating grammar tables from /home/roach/.virtualenvs/nn/lib/python3.7/site-packages/blib2to3/PatternGrammar.txt
Writing grammar tables to /home/roach/.cache/black/19.3b0/PatternGrammar3.7.3.final.0.pickle
Writing failed: [Errno 2] No such file or directory: '/home/roach/.cache/black/19.3b0/tmpc5xlgf9q'

And, there is no black directory under .cache.

@ryantam626
Copy link
Collaborator

Interesting.. What does the directory ownership look like for /home/roach/.cache? And what user did you start jupyterlab with?

@roachsinai
Copy link

hmank ~ » whoami
roach
hmank ~ » la | grep .cache
drwxr-xr-x 53 roach roach 4.0K  7月 30 17:41 .cache

@ryantam626
Copy link
Collaborator

ryantam626 commented Jul 30, 2019

Can't reproduce the error myself unfortunately.. Could you try manually creating the /home/roach/.cache/black/19.3b0 dir and see what happens?

I understand this is a bit shitty but I can't think of why it would not write the pickle in the cache 🤔

@roachsinai
Copy link

No error after I created the directory /home/roach/.cache/black/19.3b0.

[I 19:56:30.440 LabApp] Build is up to date
Generating grammar tables from /home/roach/.virtualenvs/nn/lib/python3.7/site-packages/blib2to3/Grammar.txt
Writing grammar tables to /home/roach/.cache/black/19.3b0/Grammar3.7.3.final.0.pickle
Generating grammar tables from /home/roach/.virtualenvs/nn/lib/python3.7/site-packages/blib2to3/PatternGrammar.txt
Writing grammar tables to /home/roach/.cache/black/19.3b0/PatternGrammar3.7.3.final.0.pickle

And then if I reboot jupyterlab it will not show infos about black.

@ryantam626
Copy link
Collaborator

No error after I created the directory /home/roach/.cache/black/19.3b0.

[I 19:56:30.440 LabApp] Build is up to date
Generating grammar tables from /home/roach/.virtualenvs/nn/lib/python3.7/site-packages/blib2to3/Grammar.txt
Writing grammar tables to /home/roach/.cache/black/19.3b0/Grammar3.7.3.final.0.pickle
Generating grammar tables from /home/roach/.virtualenvs/nn/lib/python3.7/site-packages/blib2to3/PatternGrammar.txt
Writing grammar tables to /home/roach/.cache/black/19.3b0/PatternGrammar3.7.3.final.0.pickle

And then if I reboot jupyterlab it will not show infos about black.

Ah good. I assume it's working as expected now?

@roachsinai
Copy link

Yes, except have to mkdir by myself.

@shreyasgm
Copy link

Had the same issue, manually created .cache/black/19.10b0. The error disappeared but code formatting still wouldn't work with black. I had to move to autopep8 instead.

@jhgoebbert
Copy link

I can confirm, that this bug is present for Linux, too ( #82 ).
As we use JupyterLab in a multi-user environment with >300 user, it would be an somehow ugly workaround to mkdir ~/.cache/black/19.10b/ in everyones $HOME.

@EWouters EWouters changed the title Windows, error writing grammar tables Error writing grammar tables Nov 6, 2019
@AlJohri
Copy link
Contributor

AlJohri commented Jan 8, 2020

Linking root cause: psf/black#1223

@EWouters
Copy link
Author

EWouters commented Feb 4, 2020

Thanks for the fix @AlJohri !

@andreamoro
Copy link

Same here on a Mac OSX with a clean environment and brand new installation of the code formatter.
The directory was not created.

@kavanase
Copy link

Same issue here as @andreamoro with new Mac OS X Catalina.

@jmbenedetto
Copy link

Same here with MacOS BigSur

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants