Skip to content

Commit Fail #316

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

Closed
arbues6 opened this issue Nov 18, 2021 · 7 comments
Closed

Commit Fail #316

arbues6 opened this issue Nov 18, 2021 · 7 comments

Comments

@arbues6
Copy link

arbues6 commented Nov 18, 2021

Hi there,

I've been trying to Commit changes to a project through RStudio and I didn't manage to make it work anyhow.
I had similar trouble as #169 , but since the author of that post didn't detail his issue, I wasn't able to reproduce it.

When I commit, I obtain the following error:

style-files..............................................................Failed

  • hook id: style-files
  • exit code: 1

Error in packageVersion("precommit") :
there is no package called ‘precommit’
Execution halted

spell-check..........................................(no files to check)
Skippedlintr....................................................................Failed

  • hook id: lintr
  • exit code: 1

Error in loadNamespace(x) : there is no package called ‘docopt’
Calls: loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted

readme-rmd-rendered..................................(no files to check)
Skippedparsable-R...............................................................Passed
no-browser-statement.....................................................Passed
Check for added large files..............................................Passed
Fix End of Files.........................................................Passed
Don't commit common R artifacts......................(no files to check)Skipped

The precommit and docopt packages are already installed, and the .libPaths() points to the folder where these packages can be found. Besides, as suggested in #221, I created an environment variable of "R_LIBS_USER" that points to the folder returned by .libPaths().
My guess was that there was a directory problem, but I don't know how to fix it (I tried reinstalling R and RStudio from scratch too).

I hope someone can help me, please, thanks a lot! :)

@lorenzwalthert
Copy link
Owner

HI @arbues6, sorry to hear you are having such trouble. Are you using the latest version of the package (remotes::install_github('lorenzwalthert/precommit')) and the latest hook version ($ pre-commit autoupdate)? Also, as described in NEWS.md, recent versions of the hooks don't rely on your global R package library, as {precommit} uses {renv} to create a separate environment with the relevant packages. You mention you are running things from RStudio. Did you try to commit from the terminal, e.g. with $ git commit also?

@aarbues
Copy link

aarbues commented Nov 19, 2021

Hi @lorenzwalthert , thanks for replying so fast.

I am using the latest versions (autoupdate returns two messages of "already up to date").
Running things from the terminal returns the same errors as the original message. Let me know if you need more info to reproduce the error.

As you suggested in the other issue, I ran:

chmod 744 style-files
and then:
./style-files testPreCommit.R

and I obtain:

Styling 1 files:
testPreCommit.R ✔
────────────────────────────────────────
Status Count Legend
✔ 1 File unchanged.
ℹ 0 File changed.
✖ 0 Styling threw an error.
────────────────────────────────────────

Thanks again,

@lorenzwalthert
Copy link
Owner

lorenzwalthert commented Nov 19, 2021

The other issue is no longer relevant for you I think. Please remove .git/pre-commit in your repo and call $ pre-commit prune and then in R precommit::use_precommit(). Does the error persist?

@aarbues
Copy link

aarbues commented Nov 19, 2021

.git/pre-commit doesn't seem to be an existing file.


ls -a
. .git style-files
.. .gitignore testPreCommit.R
.Rhistory .pre-commit-config.yaml
.Rproj.user TestPrecommit.Rproj


However, precommit::use_precommit() works fine.

Besides, it is not possible to prune through pre-commit (pre-commit: error: argument command: invalid choice: 'prune' (choose from 'autoupdate', 'clean', 'hook-impl', 'gc', 'init-templatedir', 'install', 'install-hooks', 'migrate-config', 'run', 'sample-config', 'try-repo', 'uninstall', 'help')).

@lorenzwalthert
Copy link
Owner

lorenzwalthert commented Nov 19, 2021

ok my bad, I mean delete the file .git/hooks/pre-commit and run $ pre-commit clean and then try again with precommit::use_precommit() and then commit.

@aarbues
Copy link

aarbues commented Nov 19, 2021

That did the trick, it works!
Thanks again Lorenz

@lorenzwalthert
Copy link
Owner

👍. I guess the only problem is that I still don’t understand how you ended up like this.

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

No branches or pull requests

3 participants