gems not showing in RubyMine - ruby-on-rails

I added some gem I wrote in my local gem repo (some ~/.rvm/gems/ruby-2.0.0-p195/gems path), but when I require it in my RubyMine project, it is not found and indeed it does not appear in my RubyMine loaded gems, and I can't find how to add it. How can I circumvent this ?

There may be several things to try here - hard to tell what you have already done.
In RubyMine Tools > Bundler > Update
make sure you've got the gem in your Gemfile - either locally, or on a specific github repo...
gem 'mygemname', :path => '../myGem'
gem 'myGitGem', :git => 'git#github.com:MYREPOS/mygitgem.git'

Related

Ruby On Rails, Where Do Bundler install gems that are fetched with :git=>'/your_name/project_name.git'?

This is my first question on StackOverflow. Please bear with me if I am doing it wrong.
I am working on a ruby on rails application and had to change the source code of a gem I am using in
/Users/username/.rvm/gems/ruby-2.0.0-p353/gems/gemname-4.1.0.
This works well and I make a fork of the gem on github, applied the changes I made, pushed, and change my gemfile line from
gem 'gemname'
to
gem 'gemname',:git=>"git#github.com:/name/gemname.git"
I run bundle install again and now the changes made are not applied to my application anymore.
When I do bundle show 'gemname' I saw the gem is install in
/Users/username/.rvm/gems/ruby-2.0.0-p353/bundler/gems/gemname-a0ed76fc98e2
I am not an expert on how bundle and github works. If anymore could explain how they work and what I should do to use my own forked version of the gem in my application, it would be very help!
Thanks in advance!
you could also write:
gem 'gemname', 'git://github.com/name/gem_name.git
or:
gem 'gemname', github: 'name/gem_name'
also be sure that you have your changes in master, and restarted your server after bundle
I ended up doing,
gem 'gemname',:git => "git#github.com:/myname/gemname.git", :branch => '1.1'
and it works fine now.
I think the problem is that I need to specify the branch 1.1 which is my branch, otherwise it uses the master's branch which my changes are not applied.

Local Gem assets not updating

I've forked a gem, and in trying to change it, decided to change the the gemfile from my git repository (which had been updating fine):
gem 'bootstrap-wysihtml5-rails', :git => 'git://github.com/Asherlc/bootstrap-wysihtml5-rails.git'
to the local directory (just the cloned git repository):
gem 'bootstrap-wysihtml5-rails', :path => '/Users/ashercohen/Documents/bootstrap-wysihtml5-rails'
Upon running either bundle update or bundle install, it shows the correct version number (updated since switching gem sources) in the readout. However, none of the files in the /vendor/assetspath seem to be getting updated in my Rails app. Is there some kind of caching thing I need to clear out?
I don't have a /vendor/cache file in my Rails app, and I'm confident that since the gem version is updating correctly in the bundler readout that the path is correct.
Is there some step I'm missing here?
Turns out Chrome was just aggressively caching the JS.

Whats the best way to tweak ruby gems for code reading

To help understand the source code of various gems I often want to place various puts statements in the source code or even try using the ruby debugger.
But whats the best way of doing this?
Do you clone the project from github and make changes locally, if so how do you "force" the use of the local cloned code over the local gem on your machine. Do I just create some scripts that explicitly require the path of the cloned repos folder?
Or do should I use rvm to create a temp gemset, download the gem and modify it directly?
Are there any other methods ive overlooked? How would this change for gems designed for use within rails projects.
The way I usually do it when I want to make changes to a Gem:
Fork the repository on Github
Check it out and create a new branch for local changes
Use Bundler to manage dependencies for the project which uses the Gem
Change one line in the Gemfile to make it use the forked version of the Gem:
gem "thegem", :git => "git://github.com/name/thegem.git", :branch => 'mybranch'
or
gem "thegem", :git => "file:///path/to/thegem", :branch => 'mybranch'
with /path/to/thegem being the path to your local working copy.
The advantage is that you now already have a the perfect infrastructure set up for contributing your changes through a pull request :)
With Bundler.
In a Rails app simply edit the Gemfile and add:
gem "gem_name", :path => "~/MyGems/gem_name"
PS: Bundler work with any Ruby project.
You can use rvm to create a temp gemset, download the gem and modify it directly. A fast way to view/modify a gem is using gemedit :
Install:
gem install gemedit
Usage:
gem edit devise
or: gem edit devise -e mate

gem version dilemma with rails 3.1

I want to use ebayapi gem (https://github.com/codyfauser/ebay) with my rails 3.1 application.
If I add the gem in the Gemfile, rails doesn't run.
/Users/ssk/.rvm/gems/ree-1.8.7-2011.03/gems/money-1.7.1/lib/support/cattr_accessor.rb:7:in `cattr_reader': undefined method `id2name' for {:instance_writer=>true}:Hash (NoMethodError)
I removed the ebayapi gem and tried "require 'ebay'" but it said that "no such file to load".
Ebayapi gem works only with money 1.7.1 and I think that conflicts with rails 3.1 (maybe 3.0 as well).
Is there a way to workaround?
Thanks.
Sam
If it's truly incompatible, and you're up to fixing it yourself, then fork the projects in question on github, and update your Gemfile to point to your git repo (or even a local path to make editing a lot easier).
Here's an example:
gem 'money', :path => "~/dev/ruby/gems/money"
# or
gem 'money', :git => "git://github.com/my_account/money.git"
Once you've fixed it, send a pull request to the original project so they can include the fix.

How to find out what fork/original of a gem is installed on my system?

When I add gem 'delayed_job' to my gemfile, how do I know whether I am going to get
collectiveidea / delayed_job or tobi / delayed_job ?
Also, is there some way to check among the list of gems I already have installed, as to which fork/location those gems were downloaded/installed from?
Ps. I am using RVM on Ubuntu, Bundler and Rails 3.0.3
There isn't one way to tell which github fork or branch you are downloading from. For the delayed_job gem you are downloading from collectiveidea's branch. You can tell on this page where the homepage points to collectiveidea's github fork. The reason you can't tell which fork in particular is because rubygems aren't linked to github repositories. They are simply packages that are uploaded to the site. For all you know you could be downloading a gem from a copy of someone's local repository that isn't even published on the internet. You could also be downloading from an SVN repository instead of a Git repository. In general the rubygems.org site should give you some idea of how to find the source code for a gem though. Also, most github gems tag their commits with a version number so that you can tell which revision you are using by checking the github/git tags.
If you want to specify git location you can use :git param:
gem "delayed_job", :git => "git://github.com/collectiveidea/delayed_job.git"
gem "delayed_job", :git => "git://github.com/tobi/delayed_job.git"
Read more about Gemfile
The gemspec contains a homepage attribute, which often shows the source code repository. You can view a gemspec of a locally installed gem with:
gem spec delayed_job
View the homepage with:
gem spec delayed_job | grep homepage
That said, the gemspec does not always have the source repo.
To help solve this problem (and others), I wrote a gem called gemdiff. It does the gemspec inspection, and if that does not contain a github URL, it searches github for a match. It includes exceptions for gems like delayed_job, which is a fork of the original repository by tobi.
gem install gemdiff
gemdiff find delayed_job
=> http://github.com/collectiveidea/delayed_job
More valuably, gemdiff will inspect your project's bundle and can show you the source code diff between the version of a gem you have installed and the highest version that can be installed, as determined by bundler.
https://github.com/teeparham/gemdiff

Resources