RubyGems - Anyone interested in using?


#1

Is any one interested in using RubyGems? A few points:

  1. Given the current ruby setup in SU, one should not expect a ‘public’ plugin/extension to be able to install gems.

  2. From #1, depending on the gem, one may be able to include the gem files in a plugin. This may involve licensing issues, I don’t know.

  3. Gems that require compiling may be able to be used by SU, but to compile them, one needs a stand-alone version of Ruby matching the version used in SU, and the compile tools. Also, some of these type of gems may require additional ‘package’ files, which may be tricky to add to a plugin/extension. Haven’t tried, nor thought about. On windows, some of these gems are available ‘pre-compiled’.

  4. Current SU RubyGems setup will not allow one to use gems installed as ‘–user-install’.

  5. SU 2016 and earlier have a version of RubyGems that must be updated.

  6. RubyGems, like many Ruby utilities, is largely used from a command line, which can’t be done with SU.

So, given the above, what can I provide?

  1. Instructions for updating RubyGems. It requires either a standalone version of Ruby or 7-Zip. Files will need to updated in the base SU install folder

  2. A file that correctly configures RubyGems to allow operations on ‘–user-install’ gems. Note that once this is done, gems installed this way can be used by both SU and a matching stand-alone Ruby install.

  3. A small file that creates a module (SUGem), allowing one to type all gem commands in the SU console, some examples:

SUGem.install "anygem -N --user-install"
SUGem.list "-d"
SUGem.outdated

If anyone is interested, I can write it up this weekend…

Thanks, Greg


#2

my interest comes and goes when I hit roadblocks…

the mac instal seems even less predicable than windows…

if I use cli gem from a local instal, I can usef the commands…

%x| ~/local/ruby-2.2.0/bin/gem ENV  2>&1 |
RubyGems Environment:
  - RUBYGEMS VERSION: 2.4.5
  - RUBY VERSION: 2.2.0 (2014-12-25 patchlevel 0) [x86_64-darwin15]
  - INSTALLATION DIRECTORY: /Users/johns_iMac/Library/Application Support/SketchUp 2018/SketchUp/Gems
  - RUBY EXECUTABLE: /Users/johns_iMac/local/ruby-2.2.0/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/johns_iMac/Library/Application Support/SketchUp 2018/SketchUp/Gems/bin
  - SPEC CACHE DIRECTORY: /Users/johns_iMac/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /Users/johns_iMac/local/ruby-2.2.0/etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-15
  - GEM PATHS:
     - /Users/johns_iMac/Library/Application Support/SketchUp 2018/SketchUp/Gems
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin

and

%x| ~/local/ruby-2.2.0/bin/gem list  2>&1 |

returns my SU gems

outdated works, but update fails on some e.g.

ERROR:  Error installing psych:
	psych requires Ruby version >= 2.2.2.

to a large extent I think SU should disable all gems…

john


#3

John,

Thanks (again) for the info. 2018 on windows is bundled with 2.2.4, looks like MacOS is 2.2.0, or is that your stand-alone?

Re gem update, that’s broken, even in the current RubyGems release (2.7.4). Currently, it grabs the most current release, downloads the gem, then looks at the spec and sees that the ruby version constraint won’t work with what it’s being installed into, and stops. AFAIK, all the info needed is available on their server, so it should be able to discern the correct gem version to use, if available.

As a work around, if you go to RubyGems.org, search on psych, flip thru the versions, you’ll find that 2.2.4 will work with your ruby version, then do gem install psych:2.2.4, and you should be good to go. gem update should also work. Psych is an extension gem, and it should compile on your system (it won’t on Windows, unless…).

The SUGem code I have runs the gem `.rb files in SU, as with SU on Windows, there is no ‘ruby.exe’ file, or, one can’t shell out to gem.

Finally, this can get sorted out better, and I suspect Trimble will update things if they get sorted out here. I’m fairly familiar with RubyGems, and it is open source. Like a lot of ruby open source repo’s, the number of active ‘windows’ contributors is rather low. The update bug and three others are issues I’ve committed to fixing, but recently I’ve been looking at Ruby in SU in general.

In some respects, unless one really knows how Ruby works stand-alone, one doesn’t know what’s amiss in an embedded situation like SU. Being a Ruby builder, I’m also familiar with Ruby configuration…

If you have a minute, it would be very helpful for me to see the output of your `gem env’ command run from your stand-alone.

Thanks,

Greg

Footnote: Ruby has been converting many std-lib items to what is known as ‘default gems’. Default gems can be updated, but, unlike normal gems, the original version cannot be removed. Many are also extension gems, in that they require compiling.

Part of the reason for this is to make Ruby more modular, but also, as some of these std-libs/gems have security implications, it allows a user to update them without requiring installation of a new Ruby version (as before). So, this is a positive thing.

But, since RubyGems is ‘not quite right’ is SU, this can’t be taken advantage of. Also, as you found, most of the current default gems require at least Ruby 2.3.x.

Below is a list of all the current default gems:

 Vers   Name                      Ruby
 1.3.4  bigdecimal             >= 0
 1.0.0  cmath                  >= 2.3.0
 1.0.0  csv                    >= 2.4.0
 1.0.0  date                   >= 2.4.0
 1.0.0  dbm                    >= 2.3.0
 1.0.0  etc                    >= 2.3.0
 1.0.0  fcntl                  >= 2.3.0
 1.0.0  fiddle                 >= 2.3.0
 1.0.2  fileutils              >= 2.4.0
 2.0.0  gdbm                   >= 2.3.0
 0.4.6  io-console             >= 2.0.0
 1.2.0  ipaddr                 >= 0
 2.1.0  json                   >= 1.9.0
 2.1.0  openssl                >= 2.3.0
 3.0.2  psych                  >= 2.2.2
 6.0.1  rdoc                   >= 2.2.2
 1.0.0  scanf                  >= 2.3.0
 1.0.0  sdbm                   >= 2.3.0
 0.0.1  stringio               Not a gem
 1.0.0  strscan                Not a gem
 1.4.2  webrick                >= 2.3.0
 1.0.0  zlib                   >= 2.3.0

#4

I didn’t set it up for running from Terminal, I only wanted to test gem from Ruby Console…

it’s been years since I installed separate versions and I only did it now because my System ruby is older than SU’s…

2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin15]

EDIT: just added a local version match for SU ruby…

Upstairs:~ johns_iMac$ ruby -v
ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-darwin15]
Upstairs:~ johns_iMac$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 2.4.8
  - RUBY VERSION: 2.2.4 (2015-12-16 patchlevel 230) [x86_64-darwin15]
  - INSTALLATION DIRECTORY: /Users/johns_iMac/.rvm/gems/ruby-2.2.4
  - RUBY EXECUTABLE: /Users/johns_iMac/.rvm/rubies/ruby-2.2.4/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/johns_iMac/.rvm/gems/ruby-2.2.4/bin
  - SPEC CACHE DIRECTORY: /Users/johns_iMac/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-15
  - GEM PATHS:
     - /Users/johns_iMac/.rvm/gems/ruby-2.2.4
     - /Users/johns_iMac/.rvm/gems/ruby-2.2.4@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /Users/johns_iMac/.rvm/gems/ruby-2.2.4/bin
     - /Users/johns_iMac/.rvm/gems/ruby-2.2.4@global/bin
     - /Users/johns_iMac/.rvm/rubies/ruby-2.2.4/bin
     - /Users/johns_iMac/.rvm/bin
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /opt/X11/bin
     - /Users/johns_iMac/.gem/ruby/2.0.0/bin

now I need to remember how to change the ‘SPEC CACHE DIRECTORY:’ fro RVM…

john


#5

Hi,

I have only installed some gems while following some Ruby on Rails tutorials, but I have no clue how to do this in SketchUp.

Is there some resource like a book or video tutorial where I can start learning?

I was thinking (dangerous)… Wouldn’t be better to create a Ruby on Rails web app which is live on the web with all the gems and make SketchUp Extensions connect to this online app?

Again, I am a noob when it comes to this…

Thanks for the topic!


#6

John,

Thanks again. I’ve never dealt with rvm (except in Travis testing), so this is interesting.

This is just a cache of specs that RubyGems uses, and there shouldn’t be a problem if it’s shared between a stand-alone & SU. I have a lot of stand-alone ruby versions installed (testing), and they all share the same folder…

Sharing gems between stand-alone & SU is broken on windows, but it may work on MacOS. RubyGems is setup to allow gems to be either ‘private’ or ‘shared’. Shared gems are only shared with matching major.minor Ruby versions, so a gem installed with 2.3.x can’t be shared with 2.2.x. If it’s broken, I do have a fix, which required adding a file to SU.

Also, the two installs have RubyGems 2.4.x. Current version is 2.7.4, and it’s not hard to update in SU, especially if you have stand-alone.

Thanks again,

Greg

I’ve added two files:

su_info.rb, outputs info about a ruby install, and it can be used in stand-alone or SU. See notes at top.

su_gem.rb - this is the file that allows gem commands from the Ruby console. See RubyGems 2.7.4 Command Reference for a RubyGems command summary. See notes at top.

su_info.rb (12.3 KB)
su_gem.rb (2.6 KB)


#7

I’m not sure what exactly you want to learn about. If you’re interested in RoR, it’s not really designed to be used in an embedded Ruby app, like SketchUp’s Ruby.

Most rails apps are about accessing data from a browser or thru http/websockets. Some extensions may do that, but most are about adding functionality to SU, and hence, they don’t even require an internet connection…

Thanks,

Greg


#8

I PM’d the other…

does the - SYSTEM CONFIGURATION DIRECTORY: make any odds?

SUGem.env
RubyGems Environment:
  - RUBYGEMS VERSION: 2.4.5.1
  - RUBY VERSION: 2.2.4 (2015-12-16 patchlevel 230) [x86_64-darwin14]
  - INSTALLATION DIRECTORY: /Users/johns_iMac/Library/Application Support/SketchUp 2018/SketchUp/Gems
  - RUBY EXECUTABLE: "/Applications/SketchUp 2018/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions/2.2/bin/ruby"
  - EXECUTABLE DIRECTORY: /Users/johns_iMac/Library/Application Support/SketchUp 2018/SketchUp/Gems/bin
  - SPEC CACHE DIRECTORY: /Users/johns_iMac/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /Users/obirsoy/Downloads/ruby/ruby-install2/etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-14
  - GEM PATHS:
     - /Users/johns_iMac/Library/Application Support/SketchUp 2018/SketchUp/Gems
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin

john


#9

See Gem::ConfigFile. Near the bottom of the ‘Overview’ section, you’ll see mention of a ‘system wide’ .gemrc file. AFAIK, that’s the only place that SYSTEM CONFIGURATION DIRECTORY is used, which actually comes from Gem::ConfigFile::SYSTEM_CONFIG_PATH. You’ll noticed that the next constant listed is SYSTEM_WIDE_CONFIG_FILE, which uses it.

So, unless you’ve got your system setup to use ruby with a bunch of different user accounts, no big deal.

Thanks,

Greg


#10

I am interested in this, if it’s still a possibility.


#11

As asked elsewhere, MacOS or Windows? I believe the code for SUGem is attached above. Somewhere I have a file needed to allow SU to get at --user-install gems…

Building extension gems is another issue.


#12

Thanks. At the moment, Mac OS is a priority, but I’m working on both. I saw the scripts after I left my comment, then downloaded them and took a look, but wasn’t totally sure about how to put them to use.


#13

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