Gem commands, OSX info needed


I’m experimenting with Ruby and SU, and came across an issue with gem list on Windows. On Windows, the gem directory is in a user folder that the user has full rights to. The SU application is installed in a normal app folder where the user may not have full rights. On windows, this a normal practice.

I just opened an issue in rubygems/rubygems to fix the issue, but I’m not sure how OSX sets up the folders. Is the gem folder in a separate folder from the SU application?

If I’m not being clear, the following code should output the gem environment and gem list commands to the Ruby Console. What I’m interested in is the OSX SU installation folder and the INSTALLATION DIRECTORY listed in Gem environment.

# frozen_string_literal: true
# load '<path to file>'
# Runs gem environment and gem list, outputs to Ruby Console, handles IO routing...


require 'stringio'
require 'rubygems/commands/environment_command'
require 'rubygems/commands/list_command'

# create streamUI with io
sio_in, sio_out, sio_err =,,
strm_io =, sio_out, sio_err, false)

# create environment command & attach io
cmd =
cmd.ui = strm_io
cmd.options[:args] = []

# environment execute & get info
cnsl_out ="#{'-' * 50} Gem Environment\n")
cnsl_out << sio_out.string
sio_out.truncate(0)       # Other apps might require sio_err to be flushed

# create list command & attach io
cmd =
cmd.ui = strm_io

# list execute & get info
cnsl_out << "\n#{'-' * 50} Installed Gems\n"
cnsl_out << sio_out.string
cnsl_out << "#{'-' * 66}"

puts cnsl_out

# clean up
cmd = nil
strm_io = nil
sio_in.close ; sio_out.close ; sio_err.close
sio_in, sio_out, sio_err = nil, nil, nil

-------------------------------------------------- Gem Environment
RubyGems Environment:
  - RUBY VERSION: 2.2.4 (2015-12-16 patchlevel 230) [x86_64-darwin14]
  - INSTALLATION DIRECTORY: /Users/johns_iMac/Library/Application Support/SketchUp 2017/SketchUp/Gems
  - RUBY EXECUTABLE: "/Applications/SketchUp 2017/"
  - EXECUTABLE DIRECTORY: /Users/johns_iMac/Library/Application Support/SketchUp 2017/SketchUp/Gems/bin
  - SPEC CACHE DIRECTORY: /Users/johns_iMac/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /Users/obirsoy/Downloads/ruby/ruby-install2/etc
    - ruby
    - x86_64-darwin-14
     - /Users/johns_iMac/Library/Application Support/SketchUp 2017/SketchUp/Gems
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin

-------------------------------------------------- Installed Gems
afm (0.2.2)
Ascii85 (1.0.2)
ast (2.3.0)
chunky_png (1.3.8)
crypt (2.2.1)
hashery (2.1.2)
macaddr (1.7.1)
parser (
pdf-reader (2.0.0)
powerpack (0.1.1)
rainbow (2.1.0)
rubocop (0.45.0, 0.43.0)
ruby-progressbar (1.8.1)
ruby-rc4 (0.1.5)
savage (1.2.0)
systemu (2.6.5)
ttfunk (1.5.1)
unicode-display_width (1.1.1)
victor (0.1.3)
[nil, nil, nil]

notice that - SYSTEM CONFIGURATION DIRECTORY: is on the Trimble developers mac, not mine…

I believe this leads to Error: ERROR: Failed to build gem native extension. issue on the mac…




Thanks for the output. Aside - I’m kind of wondering where the [nil, nil, nil] comes from, I don’t see that in my console. There may be IO differences between Windows and OSX.

Re the SYSTEM CONFIGURATION DIRECTORY issue, you probably already know, but I believe that is in the rbconfig.rb file. On Windows, the contents in the folder probably have nothing to do with native/extension gems.

If you’ll pardon two more OSX questions:

  1. specifications folder - I have one in the folder listed as INSTALLATION DIRECTORY folder, but not in my apps folder. Is that also true on OSX?

  2. RubyGems lists a RUBY_EXECUTABLE file. I don’t have a file there (or a ruby.exe file anywhere within SU folders), does OSX?

Re Error: ERROR: Failed to build gem native extension, RubyGems uses mkmf.rb to build/compile/make extension gems. On WIndows, I believe that file is not included in the installation.


the last call is always returned to console, unless it’s nil itself…

1=> all gem folders are in Users/path…

%x[ls "/Users/johns_iMac/Library/Application Support/SketchUp 2017/SketchUp/Gems"]

2=> the path shown is to a symbolic link and the actual ‘ruby’ is in /Applications/SketchUp\ 2017/

which is also missing from the SU ruby install…

is installed but requires ‘rbconfig.rb’ to run…




Well, as long as we’re this far…

Ruby 2.2.6 has default gems, I can’t/won’t check back further. Since SU Windows uses one folder for gems and gemspecs, and I’ve got multiple installs running against it, mine isn’t clean. As you know, if the specifications folder you listed above has a default sub-folder, Ruby 2.2.4 has default gems.

Anyway, in the file rubygems/basic_specification.rb, around line 37, if you change/rename the following method:

def self.default_specifications_dir
  File.join(Gem.default_dir, "specifications", "default")

And add the following code:

def self.default_specifications_dir
  dflt_dir = File.join(Gem.default_dir, "specifications", "default")
  Dir.exist?(dflt_dir) ? dflt_dir :
    File.join(Gem.dir, "specifications", "default")

Then run the code from above again (after restart), do you see default gems listed in the ‘Installed Gems’ list?

If you could verify, I could let the RubyGems guys know the patch was tested on both OSX and WIndows…



absolutely identical returns…




I apologize, I wonder what’s (not) happening. I dl’d a Windows build of 2.2.6, and assumed 2.2.4 was the same. The following default gems existed in 2.2.6:


After your response, I checked the repo on GitHub, and in 2.2.4, the list is smaller, but I found three default
gemspecs, bigdecimal, io-console and psych. They’re all extensions, so as I understand what you’ve said about SU OSX, you couldn’t update them anyway. Maybe it’s another thing that was left out.

Hence, I assume the folder /Users/johns_iMac/Library/Application Support/SketchUp 2017/SketchUp/Gems/specifications/default does not exist, or it’s empty?

I thought OSX has a Ruby install by default. Do you have a specifications/default folder there? If so, are there gemspec files in it?

Thanks for the help on OSX. I’ve been away from SU for a few years, and when I saw SU2017 was using 2.2.4, I thought maybe some community effort would help convince Trimble to stay more current.

Obviously, many plugin authors are trying to maintain backward compatibility, but current versions should come with up to date, secure libraries/extensions for json, psych, and openssl…

Do you have any thoughts on what version of Ruby you’d prefer to see in future releases?


this one has a default install of ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin15]

but I’m almost 2 os versions behind on this computer…

it has no /Gems/specifications/default folder…

I’d like SU to keep pace with Apple, which is 2.3 for the High Sierra Beta …



This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.