简体   繁体   English

为什么我的pik gem在Git Bash上不起作用,但在cmd上能很好地工作? 我正在使用Windows 7

[英]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. 我安装了pik gem以便能够在红宝石版本之间进行切换,并且在命令提示符下效果很好,但是当我尝试在Git Bash上执行相同操作时,它并没有切换红宝石的版本,所以我尝试了一切。 Could anyone help me ? 有人可以帮我吗? I'm using windows 7. 我正在使用Windows 7。

Pik at the command prompt: 在命令提示符下显示Pik:

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: 在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 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: 这是我的.bashcr存档,位于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: 这是我的.pikrc存档,位于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. 如果您在路径列表中注意到我正在假设该路径来自您的git bash shell内部。

C:\\RailsInstaller\\Git\\cmd;C:\\RailsInstaller\\Ruby1.9.3\\bin C:\\ RailsInstaller \\ GIT中\\ CMD; C:\\ RailsInstaller \\ Ruby1.9.3 \\仓

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. 在切换版本之前和之后,您应该将此路径与cmd中的路径进行比较。 I believe you'll see a difference compared to how it looks when you're using it inside of git bash. 我相信,与在git bash中使用它的外观相比,您会看到不同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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