pik
Ruby version manager for Windows
It goes like this (note that I enabled echo in pik.bat). All latest release versions downloaded today (though there may be some collisions with old software not properly uninstalled)
F:\ruby\pik>pik.bat
F:\ruby\pik>"F:\ruby\pik\pik_runner.exe" "F:\ruby\pik\pik.bat"
There was an error.
Error: can't dup NilClass
in: pathname.rb:205:in dup'
in: pathname.rb:205:in
initialize'
in: pik/commands/add_command.rb:17:in new'
in: pik/commands/add_command.rb:17:in
add'
in: pik/commands/add_command.rb:13:in `execute'
in: pik_runner:27
Source: (StackOverflow)
I'm trying to set up pik on my windows machine. In the .pikrc file, there's these lines of code:
pik_path=/c/Program files/pik
function pik {
$pik_path/pik_runner.exe pik.sh $@
[[ -s $USERPROFILE/.pik/pik.sh ]] && source $USERPROFILE/.pik/pik.sh
}
Apparently, the git bash can't deal with the space between Program and files.
How can I resolve this?
When starting git:
sh.exe": files/pik: No such file or directory
Source: (StackOverflow)
I have a Windows server that runs multiple Ruby apps, some requiring different Ruby versions. For managing Ruby versions we use the "PIK" Ruby version manager.
For an app we use Windows Services + SrvAny + Thin to run it. Screenshot of config:

However, I can't find any documentation on how to change the Ruby version for this specific Windows service. Right now, it just picks the one in the PATH env variable.
Is there a way to change ruby version using pik with Windows system services?
Source: (StackOverflow)
The problem in short
I'm on Windows and am getting the following error when running gem install json —platform=ruby
:
The system cannot find the path specified.
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
The system cannot find the path specified.
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
C:/Ruby193/bin/ruby.exe extconf.rb
creating Makefile
Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1 for inspection.
Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
Background and some Investigations
So first off, I'm not a Windows person so this is a brave new world for me. Having inherited a laptop from work that had a mad collection of libraries spread all over it I've managed to remove all previous installations of ruby and the Devkit and then installed the following:
- Ruby 1.9.3p484 with Ruby Installer into
C:/Ruby193
- Ruby 2.0.0p353 with Ruby Installer into
C:/Ruby200
- Devkit
DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe
(for ruby 1x) extracted into C:/Ruby193-devkit
- Devkit
DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe
(32-bit for ruby 2x) extracted into C:/Ruby200-devkit-x32
.
I then installed Pik 0.2.8 as a gem and ran pik_install
into a new directory C:/bin
as per the installation instructions.
My PATH looks like this:
PATH=C:\bin;C:\Ruby193\bin;C:\windows;C:\windows\system32;C:\windows\system32\Wbem;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;C:\Program Files\Java\jdk1.6.0_33\bin;C:\Program Files (x86)\Common Files\Apple\Mobile Device Support\;C:\Program Files (x86)\Common Files\Apple\Apple Application Support;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files\TortoiseSVN\bin;C:/inpath;C:\Program Files (x86)\WinMerge;C:\ChromeDriver;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64
The important things being that C:/bin
and C:/Ruby193/bin
are in the path. This means that ruby 1.9.3 is loaded by default when I fire up a shell and I can successfully switch to 2.0.0 with pik use 2.0.0p353
. In other words, pik works fine.
Devkit is intended to allow the compiling of native C/C++ binaries from gems on Windows, so as to aviod using precompiled windows binaries.
Because I've got two versions of ruby installed, and each requires a different devkit (one for 2x and one for 1x), I had to do the setup for devkit twice:
cd C:/Ruby193-devkit
ruby dk.rb init
# Edit config.yml to remove all but Ruby193
ruby dk.rb install
cd C:/Ruby200-devkit
ruby dk.rb init
# Edit config.yml to remove all but C:/Ruby200
ruby dk.rb install
At this point I should have been able to run gem install json —platform=ruby
successfully, but got the error above. After a little digging I discovered this, which advises checking that COMSPEC is set corectly and removing any AutoRun keys from HKEY_CURRENT_USER\Software\Microsoft\Command Processor
– I had one from ANSIcon and duly deleted it.
Unfortunatly I was still unable to install the json gem.
It then struck me that perhaps the wrong version of GCC was being used, or not being found. The two versions of Devkit come with different versions of gcc:
> C:\Ruby193-devkit\mingw\bin\gcc —version
gcc (tdm-1) 4.5.2
> C:\Ruby200-devkit-x32\mingw\bin\gcc —version
gcc (rubenv-4.7.2-release) 4.7.2
I then wondered if pik wasn't loading the version of devtools (and therefore gcc) for the specific version of ruby that i'd picked, and was always using 1.9.3. Thanks to this article, it seems that's not the case:
> pik use 193
> where ruby
C:\Ruby193\bin\ruby.exe
> cat C:\Ruby193\lib\ruby\site_ruby\devkit.rb
# enable RubyInstaller DevKit usage as a vendorable helper library
unless ENV['PATH'].include?('C:\\Ruby193-devkit\\mingw\\bin') then
puts 'Temporarily enhancing PATH to include DevKit...'
ENV['PATH'] = 'C:\\Ruby193-devkit\\bin;C:\\Ruby193-devkit\\mingw\\bin;' + ENV['PATH']
end
ENV['RI_DEVKIT'] = 'C:\\Ruby193-devkit'
ENV['CC'] = 'gcc'
ENV['CXX'] = 'g++'
ENV['CPP'] = 'cpp'
> pik use 200
> where ruby
C:\Ruby200\bin\ruby.exe
> cat C:\Ruby200\lib\ruby\site_ruby\devkit.rb
# enable RubyInstaller DevKit usage as a vendorable helper library
unless ENV['PATH'].include?('C:\\Ruby200-devkit-x32\\mingw\\bin') then
phrase = 'Temporarily enhancing PATH to include DevKit...'
if defined?(Gem)
Gem.ui.say(phrase) if Gem.configuration.verbose
else
puts phrase
end
puts "Prepending ENV['PATH'] to include DevKit..." if $DEBUG
ENV['PATH'] = 'C:\\Ruby200-devkit-x32\\bin;C:\\Ruby200-devkit-x32\\mingw\\bin;' + ENV['PATH']
end
ENV['RI_DEVKIT'] = 'C:\\Ruby200-devkit-x32'
ENV['CC'] = 'gcc'
ENV['CXX'] = 'g++'
ENV['CPP'] = 'cpp'
(I don't actually have cat available on windows but it makes for a clearer explanation)
As you can see, it looks like the correct version of devkit is being added to the path by devkit.rb, which is obviously being loaded because my error contains 'Temporarily enhancing PATH to include DevKit…'.
Back to the original error
It was:
The system cannot find the path specified.
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
The system cannot find the path specified.
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
C:/Ruby193/bin/ruby.exe extconf.rb
creating Makefile
Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1 for inspection.
Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
Unfortunatly the results log doesn't exactly offer much in the way of help. This is what gem_make.out looks like:
C:/Ruby193/bin/ruby.exe extconf.rb
creating Makefile
I thought that extconf.rb
might offer some help, but I can't make head nor tail of it:
require 'mkmf'
unless $CFLAGS.gsub!(/ -O[\dsz]?/, ' -O3')
$CFLAGS << ' -O3'
end
if CONFIG['CC'] =~ /gcc/
$CFLAGS << ' -Wall'
unless $DEBUG && !$CFLAGS.gsub!(/ -O[\dsz]?/, ' -O0 -ggdb')
$CFLAGS << ' -O0 -ggdb'
end
end
$defs << "-DJSON_GENERATOR"
create_makefile 'json/ext/generator'
The Makefile in C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1/ext/json/ext/generator
looks like this. It seems odd to me that this Makefile is even being created.
If anybody with a bit more Windows/Ruby experience can shed any light on this it would be amazing!
PS. I'm on Windows 7 Professional SP1
Update after some more digging
So I wanted to check that devkit was defiantly enhancing the path with the correct devkit directories. Thanks to a suggestion from another SO question, I moved the devkit installations inside the Ruby directories:
The tdm devkit now lives in C:\Ruby193\devkit
while the mingw64 lives in C:\Ruby200\devkit
. Having run ruby dk.rb install -f
for each devkit, I opened up both devkit.rb files to check that the path's had been updated correctly. They had, and I updated the puts so it should print "Temporarily enhancing PATH do include DevKit for 1.9" or "Temporarily enhancing PATH do include DevKit for 2". By way of confirmation that the correct devkit is being loaded:
C:\>pik 193
C:\>ruby -rdevkit -ve "puts ENV['PATH']"
ruby 1.9.3p484 (2013-11-22) [i386-mingw32]
Temporarily enhancing PATH to include DevKit for 1.9...
C:\Ruby193\devkit\bin;C:\Ruby193\devkit\mingw\bin;C:\bin;C:\Ruby193\bin;C:\windows;C:\windows\system32;C:\windows\system32\Wbem;c:\Program Files (x86)
\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Pro
gram Files (x86)\Common Files\Roxio Shared\DLLShared\;C:\Program Files\Java\jdk1.6.0_33\bin;C:\Program Files (x86)\Common Files\Apple\Mobile Device Su
pport\;C:\Program Files (x86)\Common Files\Apple\Apple Application Support;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files\TortoiseSVN\bin
;C:/inpath;C:\Program Files (x86)\WinMerge;C:\ChromeDriver;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\sy
swow64
C:\>pik 200
C:\>ruby -rdevkit -ve "puts ENV['PATH']"
ruby 2.0.0p353 (2013-11-22) [i386-mingw32]
Temporarily enhancing PATH to include DevKit for 2...
C:\Ruby200\devkit\bin;C:\Ruby200\devkit\mingw\bin;C:\bin;C:\Ruby200\bin;C:\windows;C:\windows\system32;C:\windows\system32\Wbem;c:\Program Files (x86)
\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Pro
gram Files (x86)\Common Files\Roxio Shared\DLLShared\;C:\Program Files\Java\jdk1.6.0_33\bin;C:\Program Files (x86)\Common Files\Apple\Mobile Device Su
pport\;C:\Program Files (x86)\Common Files\Apple\Apple Application Support;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files\TortoiseSVN\bin
;C:/inpath;C:\Program Files (x86)\WinMerge;C:\ChromeDriver;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\sy
swow64
So that all looks like it works correctly. but:
C:\>gem install json --platform=ruby
Temporarily enhancing PATH to include DevKit for 2...
Building native extensions. This could take a while...
The system cannot find the path specified.
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
C:/Ruby200/bin/ruby.exe extconf.rb
creating Makefile
Gem files will remain installed in C:/Ruby200/lib/ruby/gems/2.0.0/gems/json-1.8.1 for inspection.
Results logged to C:/Ruby200/lib/ruby/gems/2.0.0/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
C:\>pik 193
C:\>gem install json --platform=ruby
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
The system cannot find the path specified.
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
C:/Ruby193/bin/ruby.exe extconf.rb
creating Makefile
Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1 for inspection.
Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
This clearly tells us two things:
- Some other devkit.rb file is being loaded when I'm using ruby 1.9, as the 'for 1.9' message isn't being printed.
- This is unlikely to be the actual problem, as the error is identical in either case.
I'm going to see if I can build manually using the generated Makefiles.
Source: (StackOverflow)
After a failure trying to install Ruby on Rails from here: http://railsinstaller.org/, I am now trying to install things manually.
I thought I would install Pik first and then hit "pik install ruby" from the command prompt. Seemingly, nothing could be simpler than that. However, I am receiving the message "Ruby not found". How could this be?
Source: (StackOverflow)
I'm running win 7 and just installed pik via the installer. I listed the ruby versions and the most recent version is 1.9.2[-1.3.6]. I saw a post where someone mentioned to use "pik list -r" but pik tells me it's deprecated and then uses "list known" anyway. I want to install ruby 1.9.3 and do not currently have any ruby installed on this machine.
Sorry in advance if this is a duplicate question, but I didn't see it.
Thanks
Patrick
Source: (StackOverflow)
I am using windows machine and want to install pik (similar to RVM) for managing different versions of ruby and rails. However as far as I know pik currently do not have facility to create gemsets as we do with RVM.
In such a case how do I create gemsets in windows for bundling my gems. And if pik supports such a feature then please some guide me through it.
Source: (StackOverflow)
I've installed pik in a windows machine so I can manage my ruby versions I also added the path to the PATH variable, but pik is not being recognized, I also created an alias but that just results in an error when it's used but the program runs fine when I run it directly ("C:\ruby_bin\pik").
What is going on?
p.s. ruby is installed in "C:\ruby", just so you know.
Source: (StackOverflow)
I'm running multiple versions of Ruby (and Rails) on Windows and use Pik to switch between them. At the command line, I'm able to call
> pik list
186: ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]
192: ruby 1.9.2p0 (2010-08-18) [i386-mingw32]
to get a list of ruby versions available, and use
> pik 192
> ruby -v
ruby 1.9.2p0 (2010-08-18) [i386-mingw32]
to make ruby 1.9.2 the active version:
I am not able to do the same in git bash:
$ pik list
sh.exe": pik: command not found
and the version of ruby is still 1.8.6
$ ruby -v
ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]
It seems like git bash can't see the path to pik. Is there a way to alter the path within git bash or is there another way to run pik in git bash?
Source: (StackOverflow)
I am using pik
on Windows 7. I am unable to make pik
to remember the ruby version selection.
Example:
Command Window 1
> pik list
* 187: ruby 1.8.7 (2011-02-18 patchlevel 334) [i386-mingw32]
192: ruby 1.9.2p290 (2011-07-09) [i386-mingw32]
193: ruby 1.9.3p125 (2012-02-16) [i386-mingw32]
I select version 193.
>pik 193
>pik list
187: ruby 1.8.7 (2011-02-18 patchlevel 334) [i386-mingw32]
192: ruby 1.9.2p290 (2011-07-09) [i386-mingw32]
* 193: ruby 1.9.3p125 (2012-02-16) [i386-mingw32]
Now I launch another command window:
Command Window 2
> pik list
* 187: ruby 1.8.7 (2011-02-18 patchlevel 334) [i386-mingw32]
192: ruby 1.9.2p290 (2011-07-09) [i386-mingw32]
193: ruby 1.9.3p125 (2012-02-16) [i386-mingw32]
In the new window the ruby selection is not remembered. How do I make pik
persist the ruby selection across command window sessions?
Source: (StackOverflow)
I've installed two rubies using pik, but I haven't installed any rubies outside of pik.
When I choose a Ruby using pik, and then try to set up devkit, no binaries are added to the generated config.yml file:
# This configuration file contains the absolute path locations of all
# installed Rubies to be enhanced to work with the DevKit. This config
# file is generated by the 'ruby dk.rb init' step and may be modified
# before running the 'ruby dk.rb install' step. To include any installed
# Rubies that were not automagically discovered, simply add a line below
# the triple hyphens with the absolute path to the Ruby root directory.
#
# Example:
#
# ---
# - C:/ruby19trunk
# - C:/ruby192dev
#
---
I tried adding the binaries within pik to the path, so that config.yml has
- C:/pik/rubies/ruby-1.9.2-p136
- C:/Users/agrimm/.pik/rubies/JRuby-170preview1
but I get
bash-3.1$ ruby dk.rb install
[INFO] Updating convenience notice gem override for 'C:/pik/rubies/ruby-1.9.2-p136'
[INFO] Installing 'C:/pik/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/devkit.rb'
[ERROR] Unable to find RubyGems in site_ruby or core Ruby. Please
install RubyGems and rerun 'ruby dk.rb install'.
C:\DevKit>ruby dk.rb install
[INFO] Skipping existing gem override for 'C:/pik/rubies/ruby-1.9.2-p136'
[WARN] Skipping existing DevKit helper library for 'C:/pik/rubies/ruby-1.9.2-p136'
[ERROR] Unable to find RubyGems in site_ruby or core Ruby. Please
install RubyGems and rerun 'ruby dk.rb install'.
C:\DevKit>gem --version
1.3.7
C:\DevKit>echo %PATH%
C:\pik\rubies\ruby-1.9.2-p136\bin;C:\Program Files (x86)\Parallels\Parallels Tools\Applications;C:\pik\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Git\cmd;C:\DevKit\bin
C:\DevKit>PATH=%PATH%;C:\Users\agrimm\.pik\rubies\JRuby-170preview1\bin
C:\DevKit>echo %PATH%
C:\pik\rubies\ruby-1.9.2-p136\bin;C:\Program Files (x86)\Parallels\Parallels Tools\Applications;C:\pik\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Git\cmd;C:\DevKit\bin;C
:\Users\agrimm\.pik\rubies\JRuby-170preview1\bin
C:\DevKit>ruby dk.rb install
[INFO] Skipping existing gem override for 'C:/pik/rubies/ruby-1.9.2-p136'
[WARN] Skipping existing DevKit helper library for 'C:/pik/rubies/ruby-1.9.2-p136'
[ERROR] Unable to find RubyGems in site_ruby or core Ruby. Please
install RubyGems and rerun 'ruby dk.rb install'.
Do I need to install a ruby outside of pik in order to have devkit work?
Source: (StackOverflow)
I´m getting an error when adding JRuby 1.3.1 to pik. Error:
Error: private method `gsub' called for nil:NilClass
this is my path environment variable:
C:\Users\Owner>echo %path%
C:\Program Files\Java\jdk1.7.0_05\bin;c:\jruby-1.7.0.preview1\bin;C:\jruby-1.3.1\bin;c:\pik
this is when trying to add 1.3.1 version:
C:\Users\Owner>pik add C:\jruby-1.3.1\bin
There was an error.
Error: private method `gsub' called for nil:NilClass
in: pik/commands/command.rb:124:in `get_version'
in: pik/commands/add_command.rb:23:in `add'
in: pik/commands/add_command.rb:13:in `execute'
in: pik_runner:33
It´s not the case when adding JRuby 1.7.0 version.
I have added JRuby 1.3.1 before to pik, but I don´t know what might be causing this error this time. Any ideas?
Source: (StackOverflow)
I was trying to push my local database to Heroku and received this error:
...Taps Server Error: PGError: ERROR: time zone displacement out of range:...
Some googling later I discovered that this error doesn't occur with ruby 1.9.2
and that (because being on windows) I'd have to install pik
to run 1.9.2 alongside 1.9.3. So I installed pik and ruby 1.9.2.
However, when I try to install rails
on 1.9.2
I get this error:
...ERROR: Failed to build gem native extension...
After plenty of googling I've ran into the following:
- Don't bother using windows for ruby/rails development :(
- Something to do with devkit?
- Or installing a binary kit version of rails?
- Compile it yourself
Any help is much appreciated!
EDIT:
Full error stack trace:
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
C:/Ruby192/bin/ruby.exe extconf.rb
creating Makefile
make
gcc -I. -IC:/Ruby192/include/ruby-1.9.1/i386-mingw32 -I/C/Ruby192/include/ruby-1.9.1/ruby/backward -
I/C/Ruby192/include/ruby-1.9.1 -I. -DJSON_GENERATOR -O3 -g -Wextra -Wno-unused-parameter -Wno-par
entheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -O3 -Wall -O
0 -ggdb -o generator.o -c generator.c
make: gcc: Command not found
make: *** [generator.o] Error 127
Gem files will remain installed in C:/Ruby192/lib/ruby/gems/1.9.1/gems/json-1.7.6 for inspection.
Results logged to C:/Ruby192/lib/ruby/gems/1.9.1/gems/json-1.7.6/ext/json/ext/generator/gem_make.out
Source: (StackOverflow)
I installed ruby 1.9.2 via one click installer on windows 7.
Now I have a gem that only runs on 1.8.7
So I installed Pik and am trying to get 1.8.7 working.
irb runs fine, but require does not.
For example if I do a gem list
it lists the gem in question
When I require the gem in irb it says no such file to load.
When I use Pik to switch back to 1.9.2 all is well (i.e. the gem loads)
I have tried loading the gems outside of pik and inside of pik.
here is my load path running under 1.8.7:
....>ruby -ve "puts $LOAD_PATH.inspect"
ruby 1.8.7 (2011-06-30 patchlevel 352) [i386-mingw32]
["C:/Ruby187/lib/ruby/site_ruby/1.8", "C:/Ruby187/lib/ruby/site_ruby/1.8/i386-ms
vcrt", "C:/Ruby187/lib/ruby/site_ruby", "C:/Ruby187/lib/ruby/vendor_ruby/1.8", "
C:/Ruby187/lib/ruby/vendor_ruby/1.8/i386-msvcrt", "C:/Ruby187/lib/ruby/vendor_ru
by", "C:/Ruby187/lib/ruby/1.8", "C:/Ruby187/lib/ruby/1.8/i386-mingw32", "."]
I do not see Ruby187/lib/ruby/gems/1.8 on the path... perhaps that is the problem? if so how do I fix it (I don't know how to change the load path) and does anybody know why pik is not working or what I could do to fix.
In the end, does anybody know just how to get rid of 1.9.2, and do a clean install of 1.8.7?
Thanks for any help!
Source: (StackOverflow)