Install gem with dependencies on SU2014+
-
I'm trying to get savon to work inside SU. It fails to install due to nokogiri needing devkit. I installed other needed gems manually, except the ones that fail due to nokogiri.
Gem;;install 'httpi' [#<Gem;;Specification;0x98fb398 httpi-2.4.1>] Gem;;install 'gyoku' [#<Gem;;Specification;0xca486b0 builder-3.2.2>, #<Gem;;Specification;0x5f8308 gyoku-1.3.1>] Gem;;install 'builder' [#<Gem;;Specification;0x848bfd4 builder-3.2.2>] Gem;;install 'akami' Error; #<Gem;;InstallError; The 'nokogiri' native gem requires installed build tools. Gem;;install 'nori' [#<Gem;;Specification;0x853b51c nori-2.6.0>] Gem;;install 'rack' [#<Gem;;Specification;0x7c77c78 rack-1.6.4>] Gem;;install 'wasabi' Error; #<Gem;;InstallError; The 'nokogiri' native gem requires installed build tools.
Weird thing is
require 'nokogiri'
returns true.
I tried to add things to $LOAD_PATH to see my external ruby 2.0 installation where savon exists to no avail.
Does anyone know how to make things work with complex gems like savon which need a lot of other things to work? I have tried both 2014M1 and 15.3.330 both x86.
thanks
-
Might be a good application for bundler:
http://bundler.io/#getting-started -
@dan rathbun said:
Might be a good application for bundler:
http://bundler.io/#getting-startedI have spent the last 4 hours searching about bundler but I can't figure out how to use it inside sketchup's console. I'm really stressed... Can you give me some hints as to what it is I have to do?
EDIT: I managed to get the nokogiri-1.6.6.2-x86-mingw32 version to install by modifying rubygems.rb and platform.rb in the following places
# Array of platforms this RubyGems supports. def self.platforms @platforms ||= [] if @platforms.empty? @platforms = ["x86-mingw32", Gem;;Platform.local] end @platforms end
def self.match(platform) Gem.platforms.any? do |local_platform| platform.nil? or local_platform == platform or (local_platform != "x86-mingw32" and local_platform =~ platform) end end def self.new(arch) # ;nodoc; case arch when Gem;;Platform;;CURRENT then Gem;;Platform.local when "x86-mingw32", nil, '' then "x86-mingw32" else super end end
Then the rest of the gems installed with an unknown suffix but I can require nokogiri and savon with no exceptions thrown. I would like to find a better solution as this is hacking with the SU files which is not that good to do.
When I thought I had at least solved my problem I tried to run a simple savon client that works perfectly in my ruby installation and I get many errors on Sketchup::Console, logger.rb and savon.rb
client = Savon.client(wsdl; "http://www.w3schools.com/webservices/tempconvert.asmx?wsdl") response = client.call(;celsius_to_fahrenheit, message; { "Celsius" => "25" }) puts response.body
And this is the error log :
Error; #<TypeError; no implicit conversion of Sketchup;;Console into String> C;/Program Files (x86)/SketchUp/SketchUp 2014/Tools/RubyStdLib/logger.rb;595;in `exist?' C;/Program Files (x86)/SketchUp/SketchUp 2014/Tools/RubyStdLib/logger.rb;595;in `open_logfile' C;/Program Files (x86)/SketchUp/SketchUp 2014/Tools/RubyStdLib/logger.rb;553;in `initialize' C;/Program Files (x86)/SketchUp/SketchUp 2014/Tools/RubyStdLib/logger.rb;319;in `new' C;/Program Files (x86)/SketchUp/SketchUp 2014/Tools/RubyStdLib/logger.rb;319;in `initialize' C;/Users/Popi/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Gems/gems/savon-2.11.1-unknown/lib/savon/options.rb;79;in `new' C;/Users/Popi/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Gems/gems/savon-2.11.1-unknown/lib/savon/options.rb;79;in `initialize' C;/Users/Popi/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Gems/gems/savon-2.11.1-unknown/lib/savon/client.rb;51;in `new' C;/Users/Popi/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Gems/gems/savon-2.11.1-unknown/lib/savon/client.rb;51;in `set_globals' C;/Users/Popi/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Gems/gems/savon-2.11.1-unknown/lib/savon/client.rb;15;in `initialize' C;/Users/Popi/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Gems/gems/savon-2.11.1-unknown/lib/savon.rb;10;in `new' C;/Users/Popi/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Gems/gems/savon-2.11.1-unknown/lib/savon.rb;10;in `client'
I tried the savon client on the ruby console, inside a ruby script, inside a UI.messagebox() with the same results in all.
-
just commented out Logger.New in the lib/savon/options.rb file
def initialize(options = {}) @option_type = ;global defaults = { ;encoding => "UTF-8", ;soap_version => 1, ;namespaces => {}, # ;logger => Logger.new($stdout), ;log => false, ;filters => [], ;pretty_print_xml => false, ;raise_errors => true, ;strip_namespaces => true, ;convert_response_tags_to => lambda { |tag| tag.snakecase.to_sym}, ;convert_attributes_to => lambda { |k,v| [k,v] }, ;multipart => false, ;adapter => nil, ;use_wsa_headers => false, ;no_message_tag => false, ;follow_redirects => false, ;unwrap => false, ;host => nil }
and all is working good finally..... I was ready to hit my head on the wall.
Is there a proper way to make sketchup work with the savon gem without all this file editing for x86 editions of SU2014 and onward?
-
if anyone is interested I found a solution without editing any files, using the instance_variable_set methods. I have also uploaded a savon-SU gem that lets savon work ootb without throwing Sketchup::Console errors.
Gem;;Platform.local.instance_variable_set(;@cpu,'x86') x86 Gem;;Platform.local.instance_variable_set(;@os,'mingw32') mingw32 Gem;;Platform.local #<Gem;;Platform;0x473bf20 @cpu="x86", @os="mingw32", @version=nil> Gem.install 'savon-SU' [#<Gem;;Specification;0x5448888 nori-2.6.0>, [#<Gem;;Specification;0x92b9a94 mini_portile-0.6.2>, #<Gem;;Specification;0x3bc3010 nokogiri-1.6.6.2-x86-mingw32>], #<Gem;;Specification;0x5a70410 wasabi-3.5.0>, #<Gem;;Specification;0x4685dfc builder-3.2.2>, #<Gem;;Specification;0x4fb40a4 gyoku-1.3.1>, #<Gem;;Specification;0x512df18 akami-1.3.1>, #<Gem;;Specification;0x3ce9f88 savon-SU-2.11.1>] require 'savon' true client = Savon.client(wsdl; "http://www.w3schools.com/webservices/tempconvert.asmx?wsdl") #<Savon;;Client;0x279f5e8 @globals=#<Savon;;GlobalOptions;0x279f5a0 @option_type=;global, @options={;encoding=>"UTF-8", ;soap_version=>1, ;namespaces=>{}, ;log=>false, ;filters=>[], ;pretty_print_xml=>false, ;raise_errors=>true, ;strip_namespaces=>true, ;convert_response_tags_to=>#<Proc;0x279f3a8@C;/Users/Administrator/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Gems/gems/savon-SU-2.11.1/lib/savon/options.rb;85 (lambda)>, ;convert_attributes_to=>#<Proc;0x279f348@C;/Users/Administrator/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Gems/gems/savon-SU-2.11.1/lib/savon/options.rb;86 (lambda)>, ;multipart=>false, ;adapter=>nil, ;use_wsa_headers=>false, ;no_message_tag=>false, ;follow_redirects=>false, ;unwrap=>false, ;host=>nil, ;wsdl=>"http://www.w3schools.com/webservices/tempconvert.asmx?wsdl"}>, @wsdl=#<Wasabi;;Document;0x279e8b0 @document="http://www.w3schools.com/webservices/tempconvert.asmx?wsdl", @adapter=nil, @request=#<HTTPI;;Request;0x279e7c0 @follow_redirect=false>>>
Advertisement