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.
Related
I need to make changed to the Twitter gem, so I cloned it to a local folder, then changed my bundle file like so:
gem 'twitter', :path => '~/code/twitter-ruby'
I added a new method, and ran a test that simply calls the method, to start off with. But I get an error of undefined method. In other words, it hasn't detected my changes. I tried commenting out a whole file, ran my other tests and those all worked, as though the file were still there.
In my project I'm still importing as require 'twitter'.
I've tried running bundle update twitter, I've tried removing it from the bundle, I've tried increasing the version number (which it does detect, and updates to the most recent version), I've tried committing my changes to GIT. Nothing seems to work - I just keep getting the same undefined method error. Any ideas?
EDIT: my Gemfile.lock:
PATH
remote: /Users/Andrew/code/twitter
specs:
twitter (5.15.0)
GEM
remote: https://rubygems.org/
specs:
PLATFORMS
ruby
DEPENDENCIES
twitter!
BUNDLED WITH
1.12.4
My issue was that I was using bundle to install the gems, but I wasn't using bundle exec to run my application. It became clear after running the uninstall suggestion and the require my_lib line starting to fail inside irb. bundle exec irb allowed it to work using the gem path defined in the Gemfile.
try this out:
First uninstall the twitter gem, by doing gem uninstall twitter, then do bundle install
Try giving the branch name too.
gem 'twitter', path: <absolute-path-to-your-local-twitter-repo>, branch: <branch-name>
EDIT
e.g. path as "/Users/me/path/to/repo"
And run
bundle update twitter
Then restart server, if running as a web application.
I am developing a gem meant to be used with Rails projects and want to try it out locally with another Rails app of mine.
I built the gem with bundle exec rake release which put a .gem file in the /pkg directory.
Then, in my Rails app, I added the following to my gemfile
gem 'mygem', '0.1.1', path: '/Users/me/projects/mygem/ruby/pkg'
I then ran bundle install which said it installed the gem. When I do this, it removes the gem from the path. IDK where it went.
When I start the Rails app, it's like the gem isn't included at all.
Interestingly, if I add a version that doesn't even exist, it still says bundle install works fine. (Example: gem 'mygem', '0.1.2345', path: '/Users/me/projects/mygem/ruby/pkg')
What am I supposed to do to try out my Gem locally with a Rails app?
This question is different from How can I specify a local gem in my Gemfile? because I explicitly tell bundle in my Gemfile to use the local gem, with the path given, and it still doesn't work. When I run bundle install, it says
Using mygem 0.1.1 from source at /Users/me/projects/mygem/pkg
So you'd think it works right, but it still doesn't.
Interestly, if I try it with a version number that doesn't exist, like mygem 1.2.3, it still runs bundle install successfully, which is really weird and seems like a bug:
Using mygem 1.2.3 (was 0.1.1) from source at /Users/me/projects/mygem/pkg
I prefer to use the following when working on a local gem side-by-side with a Rails project:
gem 'foo',
:git => '/path/to/local/git/repo',
:branch => 'my-fancy-feature-branch'
Could I simply copy the devise app and lib (and gem?) folders into my respective project folders and have them work just as if I was using the gem? I'd like to do this so that I can really see all the code, possibly do some customization, and also avoid some "cannot find" errors in my IDE.
Is this a bad idea? If this is something that would work would I simply need to remove the gem and copy over the necessary files or would I need to "undo" things that the gem has done. Could this create problems down the road with updates?
Lastly, how exactly is devise working when I do not have all of the code in my project? It works when I'm offline so is the code just stored in some secret invisible file or something? Do some gems require an internet connection to retrieve their functionality or could any gem simply be copied and used in a project without declaring it in the gem file.
See http://bundler.io/v1.5/git.html
Bundler also allows you to work against a git repository locally instead of using the remote version. This can be achieved by setting up a local override:
bundle config local.GEM_NAME /path/to/local/git/repository
Also
http://ryanbigg.com/2013/08/bundler-local-paths/
"There's a little known feature of Bundler that allows you to use a local Git repository while developing locally, and a remote Git repo when deploying. This feature means that you no longer have to constantly switch between local paths:"
gem 'spree', :path => "~/Projects/gems/spree"
And remote paths:
gem 'spree', :github => 'spree/spree', :branch => 'master'
Whether this is possible, short answer: Yes. Is this a bad idea? Definitely! In fact, the code is not in your project, but when you install a gem, all its contents will be stored somewhere in your local machine. Therefore, once downloaded, you don't have to be online to use it. Well, though it's not common (and not recommended), you can clone the gem's repository to your project and set the path in the project's Gemfile.
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'
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.