devkit path issue (maybe related to #55)

Issue #95 resolved
Manuel Widmer created an issue

I have seen there was alreday a ticket about devkit on windows and you explained in detail how it works. However I have some issues when trying to install some native gems, and it seems definitively to be related with uru or the environment / PATH.

I have properly installed devkit via dk.rb and for some native gem it works, but for some other it doesn't. Looks like some native gems somehow start multiple "subshells" or processes for compilation and do not get the proper path to devkit.

D:\Programming\ruby>gem install debase
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing debase:
        ERROR: Failed to build gem native extension.

    current directory: c:/ruby/ruby225-p319/lib/ruby/gems/2.2.0/gems/debase-0.2.1/ext
c:/ruby/ruby225-p319/bin/ruby.exe -r ./siteconf20170331-12100-pt36fh.rb extconf.rb
checking for vm_core.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

I have currently the following rubies installed:

uru ls
    193p545     : ruby 1.9.3p545 (2014-02-24) [i386-mingw32]
    200p598     : ruby 2.0.0p598 (2014-11-13) [i386-mingw32]
    223p173     : ruby 2.2.3p173 (2015-08-18 revision 51636) [i386-mingw32]
 => 225p319     : ruby 2.2.5p319 (2016-04-26 revision 54774) [i386-mingw32]

See also the github issue I opened first for debase: https://github.com/denofevil/debase/issues/38

After adding both following devkit folders to the path, the gem installation works seamless:

C:\ruby\DevKit-32-4.7.2-1151\bin
C:\ruby\DevKit-32-4.7.2-1151\mingw\bin
D:\Programming\ruby>gem install debase
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
Successfully installed debase-0.2.1
Parsing documentation for debase-0.2.1
Installing ri documentation for debase-0.2.1
Done installing documentation for debase after 1 seconds
1 gem installed

Comments (6)

  1. Jon repo owner

    I'm not able to repro your issue on my Win8.1 x64 system.

    C:\Users\Jon\Downloads
    $ uru ls
     => 234p301-x32 : ruby 2.3.4p301 (2017-03-30 revision 58213) [i386-mingw32]
        241p111-x32 : ruby 2.4.1p111 (2017-03-22 revision 58052) [i386-mingw32]
        jruby       : jruby 9.1.8.0 (2.3.1) 2017-03-06 90fc7ab Java HotSpot(TM) 64-Bit...
    
    C:\Users\Jon\Downloads
    $ gem i debase-0.2.1.gem
    Fetching: debase-ruby_core_source-0.9.9.gem (100%)
    Successfully installed debase-ruby_core_source-0.9.9
    Temporarily enhancing PATH to include DevKit...
    Building native extensions.  This could take a while...
    Successfully installed debase-0.2.1
    2 gems installed
    
    C:\Users\Jon\Downloads
    $ ruby -rdebase -e "puts %Q[debase: #{Debase::VERSION}]; puts Debase.singleton_methods.inspect"
    debase: 0.2.1
    [:skip, :start, :stop, :handler, :start_, :setup_tracepoints, :remove_tracepoints, :keep_frame_binding, :tracing,
    :started?, :add_breakpoint, :breakpoints, :remove_breakpoint, :source_reload, :post_mortem?, :debug,
    :add_catchpoint, :catchpoints, :last_context, :file_filter, :current_context, :debug_load, :contexts, :verbose?,
    :verbose=, :handler=, :keep_frame_binding=, :tracing=]
    

    My environment is different that yours (e.g. - ruby234 vs 225, gcc 6.3.0 vs 4.7.2), but it appears that something else is going on in your system. uru is essentially a glorified PATH updater. Once a particular ruby is activated, it's on PATH similar to how it would be if not using uru.

    A couple ideas to try...

    1. Open a new Command Prompt instance, manually add your ruby 225p319 to PATH, and see if you can install debase. I suspect you'll get the same failure, indicating that uru isn't the cause.
    2. Double check that your C:\ruby\ruby225-319\lib\ruby\site_ruby\devkit.rb file correctly references your devkit. For example, mine looks like the following (ignore the difference of the MSYS2 exes in ...\\usr\\bin as I'm using a newer, custom devkit.)
    # enable RubyInstaller DevKit usage as a vendorable helper library
    unless ENV['PATH'].include?('C:\\Devkit-x32-6.3.0\\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:\\Devkit-x32-6.3.0\\usr\\bin;C:\\Devkit-x32-6.3.0\\mingw\\bin;' + ENV['PATH']
    end
    ENV['RI_DEVKIT'] = 'C:\\Devkit-x32-6.3.0'
    ENV['MSYSTEM'] = 'MINGW32'
    ENV['CC'] = 'gcc'
    ENV['CXX'] = 'g++'
    ENV['CPP'] = 'cpp'
    
  2. Manuel Widmer reporter

    Hi Jon, many thanks for your time and detailed explanation. I think I found the reason why it doesn't work on my environment.

    I used the "autocommand" registry value to automatically load a default ruby with uru:

    reg add "HKCU\Software\Microsoft\Command Processor" /v AutoRun ^
      /t REG_EXPAND_SZ /d "%"USERPROFILE"%\init.cmd  > NUL 2>&1" /f
    

    where the contents of my init.cmd are the following

    @echo OFF
    uru 225
    

    this seems to reset the environment during native gem installs, as soon as i comment (with rem) the two statements, the installation of native gems starts to work.

    Example with init.cmd:

    D:\programming\ruby\telcocloud\BnsE2ETests>gem install debase
    Temporarily enhancing PATH to include DevKit...
    Building native extensions.  This could take a while...
    ERROR:  Error installing debase:
            ERROR: Failed to build gem native extension.
    
        current directory: D:/Anwendungen/ruby/ruby225-p319/lib/ruby/gems/2.2.0/gems/debase-0.2.1/ext
    D:/Anwendungen/ruby/ruby225-p319/bin/ruby.exe -r ./siteconf20170404-1972-1ese3z2.rb extconf.rb
    ---> Now using ruby 2.2.5-p319 tagged as `225p319`          <<<<<<<<<<<<< here uru is loaded again by autocommand init.cmd this probably removes again the devkit path which was added before
    checking for vm_core.h... *** extconf.rb failed ***
    Could not create Makefile due to some reason, probably lack of necessary
    libraries and/or headers.  Check the mkmf.log file for more details.  You may
    need configuration options.
    

    example with uru commented out in init.cmd

    D:\programming\ruby\telcocloud\BnsE2ETests>gem install debase
    Temporarily enhancing PATH to include DevKit...
    Building native extensions.  This could take a while...
    Successfully installed debase-0.2.1
    1 gem installed
    

    is there some other way than autocommand on windows to set a "default" ruby, which doesn't conflict with devkit or the native gem installation ?

  3. Jon repo owner

    Good to know, thanks for the info.

    While not the same as cmd's AutoRun feature, you might find uru's .ruby-version support interesting.

    Another option is to check whether tweaking your init.cmd script to check for the presence of the uru-specific envar URU_INVOKER before automatically activating a default ruby will work for your scenario.

  4. Manuel Widmer reporter

    Cool, thanks you just brought me to the solution.. Checking URU_INVOKER didn't help because it is always defined as URU_INVOKER=batch on my system regardless if a ruby was alread loaded or not. But now I just check if ruby is already in the path, and if so, uru is not executed, if not uru will load a default ruby.

    I.e. my init.cmd looks as follows now and it seems to work fine, also for native gem install:

    @echo OFF
    set Path | findstr /I ruby
    if ERRORLEVEL 1 uru <taggedruby>
    

    Instead of checking for a ruby in the path (e.g. if there's always some ruby keyword in the path) we could also check uru ls if there is a hashrocket.

    @echo OFF
    uru ls | findstr "=>"
    if ERRORLEVEL 1 uru <taggedruby>
    

    Maybe you want to document those possibilites to setup a "default" ruby on windows in the wiki. On linux I guess the same could be done with .bashrc or .profile

  5. Jon repo owner

    Your first option looks more robust.

    uru ls could show no active ruby (i.e. - no =>) and a ruby could still be on PATH if one configured their system to use a not recommended "system" ruby, i.e. - they've put a ruby on PATH outside of uru.

  6. Log in to comment