Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unpack a ruby .gem without 'gem unpack' available?

Tags:

ruby

gem

At work I am forced to use an old rubygem version. Upgrading is not possible due to IT department being lazy.

Is there a way to unpack a .gem file without gem unpack?

Thanks.

like image 971
shevy Avatar asked Feb 17 '14 09:02

shevy


People also ask

How do I extract a .gem file?

Thus, in order to extract the source files from the packaged gem we need to first extract the gem as a tar archive, then extract the data archive inside it and finally the source files can be found in the lib folder under data .

Which is the command used to list all the gems available in Ruby?

The list command is used to view the gems you have installed locally.

How do I get RubyGems?

Open up the 'Software Center' app from your launcher and type in `RubyGems` without quotes into the application search box at the top right, and press [enter]. RubyGems then can be installed by just clicking on the button labeled 'Install', thats it.

How do I install a specific version of a gem?

Use `gem install -v` You may already be familiar with gem install , but if you add the -v flag, you can specify the version of the gem to install. Using -v you can specify an exact version or use version comparators.


1 Answers

Gem files are just uncompressed tar archives. You can unpack them using the tar command:

$ ls
fruity-0.2.0.gem

$ tar xf fruity-0.2.0.gem 
$ ls
data.tar.gz  fruity-0.2.0.gem  metadata.gz

The file data.tar.gz is a gzip compressed tar archive that contains the gem files, you can unpack it using tar:

$ mkdir gem; cd gem
$ tar xzf ../data.tar.gz
$ ls
fruity.gemspec  Gemfile.lock  LICENSE.txt  README.rdoc  VERSION
Gemfile         lib           Rakefile     spec
like image 178
toro2k Avatar answered Nov 07 '22 05:11

toro2k