sel
sel

Reputation: 493

unpacking, editing and rebuilding ruby gem

I need to edit the contents of a ruby gem, call him a.gem.
I used gem unpack a.gem ,got the insides of it, and gem unpack --spec a.gem to get a .gemspec.
I've added a new file, updated the files: section of the .gemspec to include it.
I've put a.gemspec inside the folder resulted from unpacking the gem.

Now I'm try to gem build a.gemspec, and I'm getting the following error:

Invalid gemspec in [logstash-output-jdbc-5.2.1-java.gemspec]: logstash-output-jdbc-5.2.1-java.gemspec:1: syntax error, unexpected tSYMBEG, expecting keyword_do or '{' or '('
--- !ruby/object:Gem::Specification
                 ^
logstash-output-jdbc-5.2.1-java.gemspec:2: syntax error, unexpected ':', expecting end-of-input
name: logstash-output-jdbc
     ^
ERROR:  Error loading gemspec. Aborting.

What am I doing something wrong? I'm not a ruby programmer and I just need to edit something there.

Upvotes: 0

Views: 1146

Answers (2)

blindsnowmobile
blindsnowmobile

Reputation: 4298

A little late for OP, but these steps worked for me. Perhaps they'll help someone else:

gem spec pkg-1.2.3.gem --ruby > pkg.spec
gem unpack pkg-1.2.3.gem
mv pkg.spec pkg-1.2.3
cd pkg-1.2.3
gem build pkg.spec

Need the --ruby, otherwise the spec file is yaml.

Upvotes: 2

Sergio Tulentsev
Sergio Tulentsev

Reputation: 230306

Try a simpler workflow

gem open my_gem

This will open the installed gem's source code in your EDITOR. Make your edits. Save, restart your app to see the effects.

Upvotes: 1

Related Questions