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

Writing failed: [Errno 2] No such file or directory: '/home/user/.cache/black/21.11b1/tmpb3yqz52h' #2681

Closed
avatar-lavventura opened this issue Dec 7, 2021 · 4 comments · Fixed by #3193
Labels
T: enhancement New feature or request

Comments

@avatar-lavventura
Copy link

avatar-lavventura commented Dec 7, 2021

When I update black, or have a clean install I keep seeing following message:

load_grammar()] Generating grammar tables from /home/alper/venv/lib/python3.8/site-packages/blib2to3/Grammar.txt
load_grammar()] Writing grammar tables to /home/alper/.cache/black/21.11b1/Grammar3.8.10.final.0.pickle
load_grammar()] Writing failed: [Errno 2] No such file or directory: '/home/alper/.cache/black/21.11b1/tmpnwk07_xq'
load_grammar()] Generating grammar tables from /home/alper/venv/lib/python3.8/site-packages/blib2to3/PatternGrammar.txt
load_grammar()] Writing grammar tables to /home/alper/.cache/black/21.11b1/PatternGrammar3.8.10.final.0.pickle
load_grammar()] Writing failed: [Errno 2] No such file or directory: '/home/alper/.cache/black/21.11b1/tmpb3yqz52h'

I always have to do: mkdir /home/user/.cache/black/21.11b1, where could it be done automatically by the black?

How can I prevent this error from showing up? Would it be possible to for black to force create /home/user/.cache/black/21.* folders after each upgrade?

@michaelaye
Copy link

black should be allowed to do what it needs to do inside its own .cache/black folder, right?

@avatar-lavventura
Copy link
Author

avatar-lavventura commented Mar 16, 2022

@michaelaye Hm I believe black should be allowed to create files inside .cache/black folder. I think the problem was cache grammar tables are tried to be generated before the 21.11b1 folder is created, which was causing the error messages.

I think this is resolved with the mentioned commit.

@michaelaye
Copy link

Well #2702 was closed with the comment that the issue would not be picked up for a while, so it’s not resolved, it seems.

@avatar-lavventura
Copy link
Author

avatar-lavventura commented Mar 16, 2022

Ah you are right, I misread it, seems like PR is not resolved :-(

During the installation of black I tried to come up with this simple hack but the origin of the problem remains.

sudo chown $(logname) -R $HOME/.cache/black
black_version=$(pip freeze | grep black | sed 's|black==||g')
if [ "$black_version" != "" ]; then
    rm -rf $HOME/.cache/black/*
    mkdir -p $HOME/.cache/black/$black_version
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: enhancement New feature or request
Projects
None yet
2 participants