Git cannot be used in RStudio but in CMD or Git Bash it works.


#1

I post it on the Github issue before and jmcphers found out the PATH in the rstudioDiagnosticsReport() did not contain Git.
He suggests I ask a help here.

Something I have already done below and taken screenshots on the Github

  1. I set the right path in the global variable in the Windows system.
  2. In the cmd and Git Bash I can use git.

#2

You confirm that git is found on the PATH ? Can you call it from RStudio Terminal ?

What is the issue here exactly after setting the PATH ?


#3

@cderv Hi, the RStudio Terminal told me,

$ git --version
bash: git: command not found

And in the windows system, I have already set the environment variable, here the git directory is in the PATH.

image


#4

@EconKid - You can try setting up the path through RStudio --> Tools --> Global Options --> Git/SVN and then browse to the git.exe and restart RStudio.

Let me know if this helps!

-Heramb


#5

In the RStudio terminal, type echo $PATH and see if that includes the path for Git. If it doesn't, you may have changed the PATH variable after opening RStudio. After they're opened, some applications don't see changes to environment variables.


#6

I check the global options and RStudio has already set the git.

This is the screenshot of my RStudio global options.

However, the RStudio Terminal still cannot find the git.

$ which git
which: no git in (/d/software/R-3.5.1/bin/x64:/c/Windows/System32:/bin:/c/Windows/System32:/bin:/d/software/RStudio_preview/RStudio/bin/msys-
ssh-1000-18)

#7

Hi @nwerth
I find there is no git in the path.

 echo $PATH
/d/software/R-3.5.1/bin/x64:/c/Windows/System32:/bin:/c/Windows/System32:/bin:/d/software/RStudio_preview/RStudio/bin/msys-ssh-1000-18

Except opening windows system to set the global environment variable, any alternatives to add git in the path?


#8

And @nwerth, @heramb, I install the RStudio in directory D:
Is this a possible cause of this problem?


#9

Did you try the settings in RStudio Option that @heramb adviced ?

The setting through windows pane seems correct. Note that it required a reboot of the computer to take effect - I think the variable are loaded into the session when started.

It is like the PATH variable is not taken into account by RStudio. Which version of Rstudio is this ?

As a workaround to get command line in RStudio, you could be able to open a shell from the git pane (not the Rstudio Terminal).

In the Terminal Global option, which terminal did you select ?


#10

Hi @cderv

I follow the @heramb suggestion but it doesn't work for me.

My RStudio Version is here.
rstudioapi::versionInfo()
#> Error: RStudio not running

Created on 2018-11-16 by the reprex package (v0.2.1)

I can use Git in the CMD and Git Bash but not RStuidio Terminal.

And I choose Git Bash as the terminal for RStudio.


#11

@EconKid - These can be very lame steps but do come handy sometimes.

  1. Close your RStudio
  2. Go To Start --> Run and type in %localappdata%/
  3. Locate RStudio-Desktop in this folder and then either rename it if you want to take a look at it or delete it. (These are info files from RStudio. If RStudio doesn't find this in %localappdata%/, it creates a fresh copy.)

While you follow the above steps try also uninstalling and re-installing git-scm. Once you install, restart your machine and then open RStudio and check if git becomes available.

The reason for doing this is sometimes, few of the files either do not get correctly installed or do not get mapped. Its like an unknonw variation in statistical models :slightly_smiling_face:

Let me know if this solves the issue..

Thanks!
Heramb


#12

Unfortunately you can't use reprex with rstudioapi because a reprexed code is run outside without RStudio :slight_smile:
For this kind of answer, a reprex is not needed, you can just tell us the version number. :wink:


#13

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.