View Gemstone Source Code

A Ruby dabbler / newbie here who is not familiar with the ecosystem, so apologize if this is one of those super-spirit issues.

Is there a way to view all files and / or source code installed by a stone? That is, I just ran

$ gem install sass 

And sass stone is now part of my local system

 $ gem list --local ... sass (3.1.16, 3.1.2) ... 

I want to know what the gem install command put on my system. Is there a command that I can run to see all the files installed in gem?

After some searches, man gem and gem help commands , I found the contents command.

$ gem contents sass

However , when I run this command with the aforementioned sass stone, I get the following results

 .../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/engine_test.rb .../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/functions_test.rb .../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/extend_test.rb .../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/logger_test.rb .../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/css2sass_test.rb .../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/conversion_test.rb .../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/script_test.rb .../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/util/subset_map_test.rb .../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/util/multibyte_string_scanner_test.rb .../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/callbacks_test.rb .../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/importer_test.rb .../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/scss/css_test.rb .../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/scss/scss_test.rb .../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/scss/rx_test.rb .../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/util_test.rb .../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/script_conversion_test.rb .../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/less_conversion_test.rb .../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/cache_test.rb .../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/test/sass/plugin_test.rb .../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/bin/sass .../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/bin/sass-convert .../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.16/bin/scss 

However, this list seems incomplete since I know that there are files in

 .../.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.2/lib/ 

Why doesn't contents show files from lib ?

Is it possible to install the gem installer to install files outside the gems folder?

Is there a team that can show everything set by a stone?

+42
ruby rubygems
May 4 '12 at 17:10
source share
6 answers

gem has the unpack command: http://guides.rubygems.org/command-reference/#gem-unpack

 gem unpack rake ls rake-0.4.3/ 
+42
May 04 '12 at 17:34
source share

There are two really good ways to do this. There is another gem that allows you to open the gem and edit it. This gem is called gem-open

 gem install gem-open 

then

 gem open sass 

Another way is to create your own rdocs.

 gem rdoc sass 

Then you can look at your rdocs on

 gem server 

Also, if you use rvm, you can enter rvm info and it will show the location of GEM_HOME . This will be the entire source code of your gem.

 cd $GEM_HOME cd gems/sass-3.1.2/ 

Update:

That is how I basically do it now when I use bundler.

 cd $(bundle show sass) 

This will be the sass version in your gemfile.

+34
May 04 '12 at 17:34
source share

You mentioned the lib / directory for version 3.1.2. gem contents without --version will simply list one version (it seems to select the latest version, but I cannot verify that this is always true). What result do you get for gem contents --version 3.1.2 sass ?

+7
May 05 '12 at 17:08
source share

I usually open the stone by running this command from the console

 EDITOR=<your editor> bundle open <name of gem> 
+6
Apr 21 '15 at 11:26
source share

You can also just rename the .gem file to .tar and extract it as a posix archive. The source code is inside it in the lib folder. See https://blog.srcclr.com/extracting-ruby-source-code-from-gem-packages/ for more details.

+2
Apr 11 '15 at 3:03 on
source share

In addition to gem contents another command you may find useful is gem environment . If you have several ways to set gems, they will all be listed under the β€œGEM PATHS” label.

+1
Apr 6 '16 at 20:13
source share



All Articles