-
-
Notifications
You must be signed in to change notification settings - Fork 50
Getting "permission denied" when trying to commit after setting up precommit hooks #221
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
Comments
Thanks for your report. What was the installation method you chose and from where did you execute it? Note that for A potential (other) problem is that this is a python 2.x version, and pre-commit does not support it anymore. Edit: The problem should be resolved by upgrading the hooks, which are now of |
I used the reticulate::install_miniconda()
precommit::install_precommit() I tried installing the most recent python 3.x version and reinstalling miniconda and precommit and now I seem to get a different error log:
(the last line means "couldn't find the specified module") |
ok. That is surprising.
I don't suggest doing that. The above installation commands should handle the python version. Your new error looks like pre-commit/pre-commit#1329. Also, are you using the most recent |
Great, it worked with (P.S. Just to make it clear, I was in fact using the most recent |
Perhaps I have closed too early... I tried testing the hooks and I have received a couple
Ever seen this before? |
Did you try in a fresh terminal session? Also, is it git bash or in RStudio? |
I initially tried with Git Bash and got those errors. Trying with RStudio makes the Rscript error go away, but the bash problem still persists and I get a warning due to the package encoding (not sure, but not pre-commit related lol):
Trying again with Git Bash, after adding R/bin to the system PATH variable:
I must say that |
|
Ok, but it is expected to by at |
Try |
I have it installed already. I managed to solve the problem by adding a environment variable called (btw, I noticed that
|
Sounds like a hack but if it works ... xD
Yes. All hooks of the pre-commit framework work like this. That way, you can inspect the diff first. For the bash executable, you can for example create an alias or similar to make it work. Do you really want this hook? If not, just deactivate it. Sorry I can't provide more guidance but you seem to be the first person to have this issue. |
No worries, I'll make a local copy with the updated shebang. I imagine that fixing something that is broken for a single person may very well be a hassle. If someone else faces this same problem in the future, though, I think this Stack Exchange thread might help (I don't really have any experience with shell scripting, but it seems that the topic discussed address this problem). Cheers, and thank you again! |
Not sure you can make a local copy to fix the shebang. Because pre-commit will still use this GitHub repo to run the hooks. I saw this post before, maybe we should use this approach. We use it with other books already it seems. Because if all people in windows have this problem, it might be worth fixing. |
Also, I am surprised because even usethis' pre-commit hook for the README uses this approach with https://github.com/r-lib/usethis/blob/master/inst/templates/readme-rmd-pre-commit.sh |
Hmm I see. I initially thought about doing something similar as you do in the
Yeah, I'm not sure to what extent this error I'm getting is Windows-related or just myself-related lol |
Ok. Yes, you can do a local hook. Just make sure your script has the permission to be executed (try |
Just a quick update, I ended up creating a repo with the hooks with updated shebang and I refer to this repo in the config.yaml. It works like a charm :) I figured out it would be better than to include them in a Here is the link to the repo, I made sure to give credits to you. Here's a reproducible code to use the hooks, in case you ever decide to test it or anyone stumbles across the same problems I did (mod stands for modified): repos:
- repo: https://github.com/dhersz/dhmisc
rev: v0.0.0.9005
hooks:
- id: mod-codemeta-description-updated
- id: mod-readme-rmd-rendered Again, thank you very much! Cheers |
We'll rewrite this in R at some point since it will be required to make hooks work on CI/CD as outlined in #282. |
@dhersz these path problems should be resolved with the latest version of {precommit}, because R is now a supported language in pre-commit. Can you try it? You need to update all components as described in the README.md. Well wait until #350 is merged and released, then it should also work for the code meta hook. |
Done. |
Hi!
I followed the instructions on how to install and use the package as listed in the readme, but I have not been able to commit after setting up
.pre-commit-config.yaml
.I just want to use two specific hooks,
readme-rmd-rendered
andcodemeta-description-updated
, so this is how my.pre-commit-config.yaml
looks like:Then I tried to commit these changes (just precommit-related) and I'm getting this error message:
The hooks actions should not be a problem here, because both
README.md
andcodemeta.json
are more recent thanREADME.Rmd
andDESCRIPTION
.I usually commit through Git Bash, so I figured out it might be something with it. Then I tried committing through RStudio, but I stumbled upon the same error.
I finally had to disable precommit using
precommit::uninstall_precommit("repo")
, which allowed me to commit back again. I haven't uninstalled it user-wise, but I tried committing in a non-R related repo and it seemed to work fine.Not sure if I have messed up when setting the pre-commit-hooks yaml up, but I could not go past this error.
Some session info:
The text was updated successfully, but these errors were encountered: