-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
Using system2()
to call git on Windows leads to issue
#24
Comments
Perhaps temporarily changing env = xfun::set_envvar(c(HOME = Sys.getenv('USERPROFILE'))
on.exit(xfun::set_envvar(env)) I don't know why R adds |
I'll try that. But this is a another specificity of Windows where I remember a discussion on this, but I can't find it yet. I know this is really painful. Basically > Sys.getenv("R_USER")
[1] "C:\\Users\\chris\\Documents"
> Sys.getenv("HOME")
[1] "C:\\Users\\chris\\Documents" https://cran.r-project.org/bin/windows/base/rw-FAQ.html#What-are-HOME-and-working-directories_003f This is how the default is set. I can probably modify that as you suggest |
That's interesting. I have never realized this difference until today. Anyway, |
Oh yeah I know it was a quick wrapper untested :) You just happen to have a teammate using Windows 😅 That is to avoid this differences between OS that something tools using other generic lib are safer (like gert or git2r) as not using the CLI tool. Also that is to make things on the same level for all OS that fs has been done I think (in fs, I'll make the adaptation so that I can use the tooling for our team. I don't think this will be widely use by others so we'll continue adapt as needed I guess. |
I have pushed a fix in yihui/xfun@7e511f6 > system2('git', c('config', 'user.name'), stdout = TRUE)
character(0)
attr(,"status")
[1] 1
Warning message:
In system2("git", c("config", "user.name"), stdout = TRUE) :
running command '"git" config user.name' had status 1
> xfun:::git(c('config', 'user.name'))
Christophe Dervieux
So that should prevent error for me from now on. |
Thanks! |
I think this is a limitation of using command line tool to deal with git instead of packages like gert
xfun::crandalf_check()
will run commandgit()
which is basicallysystem2('git', ...)
.Unfortunately, on Windows this lead to issues.
For example:
However, I am set up
I think this is because of the working directory
~
not being the same while I run git in terminal or run it through R command to call system tool.When using
system2()
, it will look for global config file inC:/Users/chris/Documents/.gitconfig
, whereas the file is inC:/Users/chris/.gitconfig
which is where command line Git use. This is probably because of R - IDK.Using special tool like gert or git2r does not have this issues, because they use a lib (C or C++ probably) and it does not have this issue.
Anyway, opening this issue so that this limitation is documented. I'll find a workaround or use Linux, until I find a solution to this if any.
The text was updated successfully, but these errors were encountered: