-
-
Notifications
You must be signed in to change notification settings - Fork 802
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
Rscript not found in Windows #2599
Comments
probably just needs a call to pre-commit/pre_commit/languages/r.py Line 66 in 1f59f4c
|
Great issue description and investigation @SInginc. Indeed this might be the same as lorenzwalthert/precommit#441, except that in addition to not finding the executable because of a lacking suffix, there might have been another issue with
Me and the OP did not take the time to create such a good reprex and description, also because I was not sure it was even reproducible on other people's machines. Now it seems this is the case. Also, how is this not caught with tests? I am trying to expand integration tests in lorenzwalthert/precommit where I run end to end with @SInginc Do you want to make a PR or should I? |
Thank you! @lorenzwalthert Yes, please make a PR because I am still getting familiar with how to use Github... |
search you tried in the issue tracker
Rscript not found
describe your issue
Hi,
I was adding hook for R language in pre-commit for the first time. And pre-commit throw me an error as
Because I was using hooks from lorenzwalthert/precommit, I found a similar issue was raised(lorenzwalthert/precommit#441). But it looks like this issue is not related to the hooks and it is related to the R language support of pre-commit.
The error was raised in
cmd_output_b
ofpre_commit\util.py
, which was called byinstall_environment
ofpre_commit/languages/r.py
like.The
_rscrip_exec()
will returnC:\path\to\R\R-4.0.5\bin\Rscript
in my case because $R_HOME is well set.When
C:\path\to\R\R-4.0.5\bin\Rscript
was passed toparse_shebang.normalize_cmd
, and this function usesnormexe
to examine whetherexe
is executable.And it seems that
C:\path\to\R\R-4.0.5\bin\Rscript
didn't passnormexe
's test and the code flowed into:normexe
checksexe
's executability basing on two conditions:os.sep not in orig and (not os.altsep or os.altsep not in orig)
not os.path.isfile(orig)
Since
os.sep
is inC:\path\to\R\R-4.0.5\bin\Rscript
,orig
will flow intonot os.path.isfile(orig)
. Andos.path.isfile(orig)
isFalse
, because in Windows, the actual file is likeC:\path\to\R\R-4.0.5\bin\Rscript.exe
.I am wondering, to fix this issue on Windows, can we do an OS check in
_rscrip_exec()
and return/path/to/bin/Rscript.exe
when the User is using Windows?Thank you!
pre-commit --version
pre-commit 2.20.0
.pre-commit-config.yaml
~/.cache/pre-commit/pre-commit.log (if present)
version information
error information
The text was updated successfully, but these errors were encountered: