vertiginous / pik

Ruby version manager for Windows
830 stars 122 forks source link

can "add" but can't "use" #118

Closed molipha closed 9 years ago

molipha commented 13 years ago

C:\dev\apps\pik>pik list ruby-1.8.7-p334 ruby-1.9.2-p180

C:\dev\apps\pik>pik use 187 Nothing matches:

--- config.yml: "[ruby-]1.8.7-p334": :path: !ruby/object:Pathname path: C:/dev/apps/ruby187/bin :version: | ruby 1.8.7 (2011-02-18 patchlevel 334) [i386-mingw32]

Tried imploding and re-adding without further success.

"[ruby-]1.9.2-p180": :path: !ruby/object:Pathname path: C:/dev/apps/ruby192/bin :version: | ruby 1.9.2p180 (2011-02-18) [i386-mingw32]

s01ipsist commented 12 years ago

pik 0.3.0.pre is not very tolerant on names. The following should work pik use ruby-1.8.7-p334

luislavena commented 12 years ago

Hello,

Pik 0.3.0 no longer supports regexp for the names, that is to match RVM.

You can:

C:\Users\Luis>pik ls
   ruby-1.8.6-p398
   ruby-1.8.7-p352
   ruby-1.9.2-p290
   ruby-1.9.3-dev
   ruby-1.9.4-dev
   jruby-1.6.3

C:\Users\Luis>pik use 1.8.7-p352

C:\Users\Luis>ruby -v
ruby 1.8.7 (2011-06-30 patchlevel 352) [i386-mingw32]
SerbanC commented 12 years ago

Hello,

I'm still having trouble after following your example:

D:\workspace\foo>pik ls => ruby-1.8.7-p352 ruby-1.9.2-p136

D:\workspace\foo>pik use 1.9.2-p136

D:\workspace\foo>ruby -v ruby 1.8.7 (2011-06-30 patchlevel 352) [i386-mingw32]

EDIT: I also tried pik refresh, and using the full name ("ruby-1.9.2-p136")... still not working

s01ipsist commented 12 years ago

There is one other big gotcha with Pik 0.3.0.

(With the default install) C:\pik\pik.bat is what (I think) gets called by "pik use". That batch file requires either %HOME or %PIK_HOME environment variables to be set, on my systems neither variable is by default so "pik use" causes absolutely nothing to happen.

Try echo %PIK_HOME and echo %HOME from the command line. One should report C:\Users\Sam.pik or whatever the directory of your pik installation that contains the rubies is.

I set the %PIK_HOME environment variable and then all was golden...

SerbanC commented 12 years ago

@s01ipsist, thanks but still not working :(

I'm not much of a programmer, I'm actually a front-end guy so I'll just spell out what I tried, maybe there's something I'm doing wrong or skipped:

  1. i set PIK_HOME to C:\pik where pik is installed (but not the rubies, see following steps)
  2. also set HOME to C:\pik -- at this point pik ls returned nothing --
  3. set %PIK_HOME (including the percent sign) to C:\pik -- pik ls returned correctly the two versions, but I noticed your mention of "where the rubies are", so --
  4. set %PIK_HOME to C:\Documents and Settings[My user].pik (this is where the folder "rubies" is)

...after all this, still nothing :(

EDIT: oh, and "echo %PIK_HOME" returns "%PIK_HOME" in all cases?

s01ipsist commented 12 years ago

OK, output is a little different in the standard dos console from the TCC console I was using above. This is what mine reports now (notice that % marks are required on both sides of the environment variable)

Microsoft Windows [Version 6.0.6002]

C:\Users\Sam>echo %PIK_HOME %PIK_HOME

C:\Users\Sam>echo %PIK_HOME% C:\Users\Sam.pik

C:\Users\Sam>echo %HOME% %HOME%

PIK_HOME should be set to the directory where pik_run.bat is located (usually not C:\pik)

You might also need to restart the console session to ensure it gets all the current env vars.

SerbanC commented 12 years ago

Maybe the only combination I didn't think about trying :) It works, thanks a lot! (echo too)

s01ipsist commented 12 years ago

No problem. Hopefully pik 1.0 will provide some feedback if the required env vars aren't set rather than silent failure.

visoft commented 12 years ago

Setting PIK_HOME in the standard windows console worked, but how about the git bash?

luislavena commented 12 years ago

but how about the git bash?

You should be able to add it to ~/.profile (or .bash_profile) as export PIK_HOME=...

visoft commented 12 years ago

I have PIK_HOME set in my profile, and I can confirm it with an echo. No dice.

luislavena commented 12 years ago

@visoft do you have both PIK_HOME exported and pik function defined? I works for me:

Luis@KEORE ~
$ echo $PIK_HOME
C:/Pik

Luis@KEORE ~
$ pik ls
   ruby-1.8.6-p398
   ruby-1.8.6-p398@d21
   ruby-1.8.7-p352
   ruby-1.9.2-p290
=> ruby-1.9.3-dev
   ruby-1.9.4-dev
   jruby-1.6.3
visoft commented 12 years ago

@luislavena, I do. pik use just doesn't do anything.

dwhite@VISOFT-DWHITE02 /d/Development
$ echo $PIK_HOME
C:\Users\dwhite/.pik

dwhite@VISOFT-DWHITE02 /d/Development
$ pik ls
   ruby-1.8.7-p352
=> ruby-1.9.2-p290

dwhite@VISOFT-DWHITE02 /d/Development
$ ruby -v
ruby 1.9.2p290 (2011-07-09) [i386-mingw32]

dwhite@VISOFT-DWHITE02 /d/Development
$ pik use 1.8.7-p352

dwhite@VISOFT-DWHITE02 /d/Development
$ ruby -v
ruby 1.9.2p290 (2011-07-09) [i386-mingw32]

I also tried changing PIK_HOME to not have mixed slashes, but it doesn't make a difference

$ echo $PIK_HOME
C:/Users/dwhite/.pik
luislavena commented 12 years ago

Hmn, works for me:

Luis@KEORE ~
$ echo $PIK_HOME
C:/Pik

Luis@KEORE ~
$ pik ls
   ruby-1.8.6-p398
   ruby-1.8.6-p398@d21
   ruby-1.8.7-p352
   ruby-1.9.2-p290
   ruby-1.9.3-dev
   ruby-1.9.4-dev
   jruby-1.6.3

Luis@KEORE ~
$ pik use 1.8.7-p352

Luis@KEORE ~
$ pik ls
   ruby-1.8.6-p398
   ruby-1.8.6-p398@d21
=> ruby-1.8.7-p352
   ruby-1.9.2-p290
   ruby-1.9.3-dev
   ruby-1.9.4-dev
   jruby-1.6.3

Luis@KEORE ~
$ ruby -v
ruby 1.8.7 (2011-06-30 patchlevel 352) [i386-mingw32]

Can you confirm that pik.sh is in your bash-profile?

$ cat .profile
export PIK_HOME=C:/Pik
[[ -s $HOME_TOOLS/bin/pik.sh ]] && source $HOME_TOOLS/bin/pik.sh
visoft commented 12 years ago

@luislavena - I ended up going back to 0.2.8 for now. I used the gist here: https://gist.github.com/1239600 to setup the configuration and all seems to be working well. I'll move to 0.3.0, but there's no pressing reason right now. I'm sure that my configuration was off somewhere along the line. Anyway, thanks for all of your help.

ubir1 commented 9 years ago

Extremely helpful.. fih

yotamelkaslasy commented 9 years ago

works great after set the user env var to "PIK_HOME" and not "%PIK_HOME%".

you can now add alias to better the workflow: C:\Users\Yotam>pik ls 193: ruby-1.9.3-p545 => 213: ruby-2.1.3-p242

C:\Users\Yotam>ruby -v ruby 2.1.3p242 (2014-09-19 revision 47630) [x64-mingw32]

C:\Users\Yotam>pik use 193 C:\Users\Yotam>ruby -v ruby 1.9.3p545 (2014-02-24) [i386-mingw32]

my config file is at .pik is:


"193: [ruby-]1.9.3-p545": :alias: "193" :path: !ruby/object:Pathname path: C:/dev/Ruby193/bin :version: | ruby 1.9.3p545 (2014-02-24) [i386-mingw32]

"213: [ruby-]2.1.3-p242": :alias: "213" :path: !ruby/object:Pathname path: C:/dev/Ruby21-x64/bin :version: | ruby 2.1.3p242 (2014-09-19 revision 47630) [x64-mingw32]

--- {}

mtozlu commented 9 years ago

I wonder why everyone talks about the solution yet nobody described the solution step by step. Here is what you should do:

  1. Find pik installation and edit pik.bat
  2. Add SET PIK_HOME=C:\Users\user.pik\ (this should be the path that pik_run.bat is in) to second line (below @ECHO OFF)
  3. Save pik.bat and close
  4. Open console, run "pik use ruby-bla-bla" (your ruby version)
  5. Happily execute ruby -v
luislavena commented 9 years ago

@1dot44mb I might recommend moving from Pik and use of Uru:

https://bitbucket.org/jonforums/uru/