简体   繁体   中英

Why my pik gem doesn't work on Git Bash, but works nicely on cmd? I'm using windows 7

I installed the pik gem to be able to switch between ruby versions, and it worked nicely at the command prompt, but when I try to do the same at the Git Bash, it doesn't switch the version of ruby, I tried everything. Could anyone help me ? I'm using windows 7.

Pik at the command prompt:

C:\Users\Suporte 2>pik list
  187: ruby 1.8.7 (2013-06-27 patchlevel 374) [i386-mingw32]
* 193: ruby 1.9.3p545 (2014-02-24) [i386-mingw32]

C:\Users\Suporte 2>ruby -v
ruby 1.9.3p545 (2014-02-24) [i386-mingw32]

C:\Users\Suporte 2>pik 187

C:\Users\Suporte 2>ruby -v
ruby 1.8.7 (2013-06-27 patchlevel 374) [i386-mingw32]

C:\Users\Suporte 2>pik list
* 187: ruby 1.8.7 (2013-06-27 patchlevel 374) [i386-mingw32]
  193: ruby 1.9.3p545 (2014-02-24) [i386-mingw32]

The same at Git Bash:

Suporte 2@SUPORTE2 /
$ pik list
  187: ruby 1.8.7 (2013-06-27 patchlevel 374) [i386-mingw32]
* 193: ruby 1.9.3p545 (2014-02-24) [i386-mingw32]

Suporte 2@SUPORTE2 /
$ ruby -v
ruby 1.9.3p545 (2014-02-24) [i386-mingw32]

Suporte 2@SUPORTE2 /
$ pik 187

Suporte 2@SUPORTE2 /
$ ruby -v
ruby 1.9.3p545 (2014-02-24) [i386-mingw32]

Suporte 2@SUPORTE2 /
$ pik list
  187: ruby 1.8.7 (2013-06-27 patchlevel 374) [i386-mingw32]
* 193: ruby 1.9.3p545 (2014-02-24) [i386-mingw32]

This is my PATH :

C:\\pik\\;C:\\RailsInstaller\\Git\\cmd;C:\\RailsInstaller\\Ruby1.9.3\\bin;C:\\Program Files\\Borland\\Delphi7\\Bin;C:\\Program Files\\Borland\\Delphi7\\Projects\\Bpl\\;C:\\Program Files\\NVIDIA Corporation\\PhysX\\Common;C:\\Program Files\\CollabNet;C:\\Program Files\\Embarcadero\\RAD Studio\\9.0\\bin;C:\\Users\\Public\\Documents\\RAD Studio\\9.0\\Bpl;C:\\Program Files\\Embarcadero\\RAD Studio\\9.0\\bin64;C:\\Users\\Public\\Documents\\RAD Studio\\9.0\\Bpl\\Win64;%SystemRoot%\\system32;%SystemRoot%;%SystemRoot%\\System32\\Wbem;%SYSTEMROOT%\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files\\nodejs\\;C:\\Program Files\\Heroku\\bin;C:\\Program Files\\git\\cmd;C:\\pik;C:\\RailsInstaller\\Ruby1.9.3\\bin;C:\\RailsInstaller\\ruby-1.8.7-p374-i386-mingw32\\bin;C:\\Program Files\\Git\\cmd

This is my .bashcr archive at C:\\Users\\Suporte 2:

[[ -s C:/Users/Suporte\ 2/.pik/.pikrc ]] && source C:/Users/Suporte\ 2/.pik/.pikrc

This is my .pikrc archive at C:\\Users\\Suporte 2\\ .pik:

#!/bin/sh
pik_path=/c/pik

function pik  {
  $pik_path/pik_runner.exe pik.sh $@
  [[ -s C:/Users/Suporte\ 2/.pik/pik.sh ]] && source C:/Users/Suporte\ 2/.pik/.pikrc
} 

The why it isn't working I believe is in your path that you pasted.

If you notice in your list of path that I am making an assumption that path comes from inside your git bash shell.

C:\\RailsInstaller\\Git\\cmd;C:\\RailsInstaller\\Ruby1.9.3\\bin

Is the second entry in your path. This means it's always going to be found first and probably the reason that it's not locating the correct ruby version when you attempt switching. You should compare this path to your path in cmd before and after switching your versions. I believe you'll see a difference compared to how it looks when you're using it inside of git bash.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM