Contributing to Gem - gem not updating - ruby-on-rails

I'm trying to add a small bug fix to an open source gem. Here's what I've done:
cloned the repository to local
made changes and saved
changed gemfile of rails project to point to local version of gem
> gem 'gem_name', path: "/Users/admin/gem_name"
> bundle install
> bundle update gem_name
> rails s
The gem doesn't reflect any changes I've made (gem isn't updated). I had to change the version.rb file and then run bundle update gem_name to see changes. But to my understanding, this shouldn't be required to see changes?

Why don't you fork the gem in github? fix what you want and then point that for your github link... If you think your fix could be great for another users, why not a pull request? ;)
gem 'gem_name', :git => 'https://github.com/my_user/gem.git'

Related

Use additional gem in deployment

does anyone have any idea how to add ruby gems if Gemfile.lock exists?
I’m using an application from an apt package but I want to add my custom gem.
In the Gemfile it says:
# Want to extend Zammad with additional gems?
# ZAMMAD USERS: Specify them in Gemfile.local
# (That way, you can customize the Gemfile
# without having your changes overwritten during upgrades.)
But if I create the Gemfile.local with my Gem the Application couldn start.
You are trying to install in deployment mode after changing
your Gemfile. Run bundle install elsewhere and add the
updated Gemfile.lock to version control.
If this is a development machine, remove the / opt / zammad / Gemfile freeze
by running bundle install --no-deployment.
The list of sources changed
The dependencies in your gem file changed
You have added to the Gemfile:
mySpecialGem
I used to be able to do this with bundle install --no-deployment , but when I do that I always get the same message
Are you installing the gem as:
gem "gem_name", path: "/Users/Matthies/gem_location"
Could you post what your Gemfile looks like?
the gemfile from the original package is
https://github.com/zammad/zammad/blob/stable/Gemfile
in my Gemfile.local is this:
gem 'gem_name', git: 'https://github.com/myname/mygem'

Update local gem source code

I'm testing a gem in a Rails project.
The current Gemfile:
gem 'mygemname', path: '/path/to/my/gem'
When I edit a gem locally I can build the gem, remove the gem from Gemfile, run bundle install, add the gem back to the Gemfile and run bundle install again. Is there an easier way to do this locally?
If you use bundle config local.GEM_NAME /path/to/local/git/repository from the command line then every time you reload your application it will load the latest source from your file system.
To remove the changes (when you have pushed your code to GitHub or RubyGems), you need to run bundle config --delete local.GEM_NAME
Source: http://bundler.io/v1.10/git.html
You can bump your Gem's version. Next time you run bundle your gem will be updated to the next iteration.
VERSION = "1.0.0"
Bump the patch version to
VERSION = "1.0.1"
Now just run bundle. Bundler will notice it and log 1.0.1 (was 1.0.0) in the output.

How to make edits to a gem and have that take affect on heroku?

I have a gem to which I want to make a few edits.
I have opened the gem using
bundle open gem_name
Made the edits and they work fine on development.
What do I need to do in order to make the changes take affect on heroku.
There is nothing to commit locally.
Your local gem is modified, but during deployment the one on github gets installed.
What you could do is to find the gem project on github, and fork it.
Then you can apply all your custom mods and commit into your gem repo.
Once you're done, remember to point to the right repo in your Gemfile:
gem your_gem, , :git => "https://github.com/your_user_name/your_gem.git"
You can vendorize the gem like this:-
gem unpack my_private_gem --target vendor/gems
and then in your Gemfile
gem 'my_private_gem', :path => "vendor/gems/my_private_gem-VERSION"

Branch of a Gem is not installed correctly with Rails and Gemfile

Initial Problem
I was using yaml_db in a Rails project, but it seems the default branch has some issues with boolean records. Now I know that there's a branch on github that has a fixed version.
I changed my Gemfile so that this branch will be installed instead of the default yaml_db,
gem 'yaml_db', :git => "https://github.com/robsharp/yaml_db.git"
I run bundle install and it shows:
Using yaml_db (0.2.0) from https://github.com/robsharp/yaml_db.git (at master).
Your bundle is complete! It was installed into /Users/user/.rvm/gems/ruby-1.9.2-p0
Fine. Now the fixed file in the Git repository should have this line in lib/serialization_helper.rb:
record[column] = convert_boolean(record[column])
Yet, when I look at my local file, which is .rvm/gems/ruby-1.9.2-p0/bundler/gems/yaml_db-ca178cfb59cf/lib/serialization_helper.rb, it still shows the unpatched old line:
record[column] = (record[column] == 't' or record[column] == '1')
Fine, seems as my local file isn't changed.
Gem not being installed correctly
Running gem list won't show me yaml_db at all. I removed the Gem lockfile and installed the bundle again, still there is no yaml_db in my Gem listing. Running gem install yaml_db of course only installs the broken version.
Manual Install
I now try to manually install from the Git source.
git clone https://github.com/robsharp/yaml_db.git
cd yaml_db
git checkout -b fix_boolean_checks_to_support_oracle
Still, the serialization_helper.rb file is not updated correctly. I just manually changed it and built the Gem. Everything works fine now.
My new question: Why won't it check out the correct file?
If you run gem list yaml_db and see multiple versions in parenthesis, define the version you need in your Gemfile like so
gem 'yaml_db', '~> 0.2.0', :git => "https://github.com/robsharp/yaml_db.git"
I had a similar problem and found out that the Gemfile.lock file stored my old and not–updated version and used that for my project.

How to install Rails 3 master from GitHub

I'm using rvm (Ruby Version Manager) and running Rails 3 RC. I need to test an app to see if a bug has been resolved with a recent commit to Rails 3 master on GitHub.
How do I install Rails 3 master from GitHub and then generate a new app?
I can't use
gem install rails --pre
because I want the edge version, not the release candidate.
Can you suggest a helpful gist or blog post?
All I could find was this:
http://weblog.rubyonrails.org/2010/1/1/getting-a-new-app-running-on-edge
and it is out-of-date.
Thanks!
You can create an empty folder, then put a Gemfile inside, with this:
source 'http://rubygems.org'
gem 'rails', :git => 'git://github.com/rails/rails.git'
Then inside the folder, run:
bundle install
Inside the folder again, run:
bundle exec rails new /path/to_my_new_application/appname
And that's it.
You can do this with your rails 3 app Gemfile. Bundler is able to install directly from github and if you dont specify a branch or tag then it will use master. Add this to your Gemfile after you generate your rails 3 app, and then run bundle install and start up your app. After you bundle install it will show you the commit number in Gemfile.lock.. it should be the latest commit number from the master rails repo. Here is what I do in my Gemfile:
gem 'rails', :git => 'git://github.com/rails/rails.git'
#gem 'rails', '3.0.0.rc'
I just uncomment and comment these 2 lines to switch b/w RC and master... and bundle install.
Alternately, you can clone the repo and then use your local source in the Gemfile:
I think it should look something like this (untested):
gem 'rails', :require => 'rails', :path => "/path_to/rails"
Why not take a look through the commit log here: http://github.com/rails/rails/commits/master before cloning the repository? I don't know what bug you are looking for but remember, you can also look at the "diffs" from each commit to see what has changed.

Resources