Rails Bundle Install Not Finding Gem - ruby-on-rails

I'm having a problem with the rails
bundle install
command not being able to find a local gemfile.
The gem is located here::
~/.gem/ruby/2.1.5/gems/mygemname-1.5.0.SNAPSHOT
I included the gem in my Gemfile. But when I try to bundle my application, it get this error::
Could not find gem 'mygemname-1.5.0.SNAPSHOT' (>= 0) ruby' in the gems available on this machine.
I can see the gem sitting on my hardrive, but the bundle install command says it doesn't exist. Does anybody have any ideas on what may be going on here?
Thanks for your time.

As I canĀ“t comment yet...
I would check:
- Is it really the .gem folder holding the gem or is it symlinked (I am not confident that symlinks work on bundle install)
- Is rbenv or rvm in the game and is the installed gem installed with one of those or globally?

Related

Ruby Gems not found despite bundle install

I have a Rails app. My collaborator updated the app's Ruby version and added Gems. I had to update my local version of Ruby to 2.3.1.
Now it seems that rails s looks for gems in a different location than where bundle install puts them. What do I have to do to get both to put and look for gems in the same place?
Concretely, when I try to start the Rails server with
rails s
I get the message
/Users/Falk/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/dependency.rb:319:in `to_specs': Could not find 'railties' (>= 0) among 5 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=/Users/Falk/.gem/ruby/2.3.0:/Users/Falk/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0', execute `gem env` for more information
from /Users/Falk/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/dependency.rb:328:in `to_spec'
from /Users/Falk/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_gem.rb:65:in `gem'
from /usr/local/bin/rails:22:in `<main>'
This happens even though I have already run
bundle install
and all the required gems are included in the gem file. I was able to make progress by manually uninstalling and reinstalling individual gems through
gem uninstall <gem_name>
gem install <gem_name>
but it kept on complaining about one missing gem after another. Then I uninstalled all gems using
for x in `gem list --no-versions`; do gem uninstall $x -a -x -I; done
After that, bundle install still acts as if all gems were already installed. But rails s still does not work and complains about missing gems. What should I do now?
I was able to solve this problem by following the steps outlined here:
bundle uses wrong ruby version
Go to the service/repository that you are trying to run, and go to bin/bundle file. open the file and you will find a code snippet like this :
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
load Gem.bin_path('bundler', 'bundle')
Change the path to your gemfile as is mentioned here, after which in your service/repository you will find your gemfile. By checking its source provide the right directory path. After which include all your gems into the gem file, like this:
gem 'protobuf'
gem 'grpc'
gem 'protobuf-activerecord'
Finally use
bundle list
to check if the bundler has all the gems initialised in it.

Linux Rails Gem Install Error

Does anyone know what's happening here?
root#ip-172-31-5-114:/home/bitnami/htdocs/kicksharer/kickscraper# gem install rails
Successfully installed rails-5.0.0.1
Parsing documentation for rails-5.0.0.1
Done installing documentation for rails after 0 seconds
1 gem installed
root#ip-172-31-5-114:/home/bitnami/htdocs/kicksharer/kickscraper# bundle show rails-5.0.0.1
Could not find gem 'rails-5.0.0.1'.
Any suggestions for troubleshooting would be really appreciated.
When you gem install rails it installs it on your system. You need to make sure rails is specified in your gem file and then bundle install in order to install those gems in the bundle. (It should use the already installed gems on your system)

Unable to install Doorkeeper-MongoDB

I have a fresh installation of rails 4 with MongoMapper. Now i'm trying to install doorkeeper on my rails instance.
I added the "gem 'doorkeeper-mongodb'" line in my Gemfile. Then I ran 'bundle install'. And I got the following error :
Could not find gem 'doorkeeper-mongodb (>= 0) ruby' in any of the gem sources listed in your Gemfile or available on this machine.
Also, I tried to install it using the gem install command but it doesn't work either.
I'm on Mac OS X.
The line to put in the Gemfile is
gem 'doorkeeper-mongodb', github: 'doorkeeper-gem/doorkeeper-mongodb'
I tried checking the gems in https://rubygems.org and could not find doorkeeper-mongodb.
And then googled out, and found that if you want to install gems from github source, then the right way seems like this following:
gem 'doorkeeper-mongodb', :git => 'git://github.com/doorkeeper-gem/doorkeeper-mongodb.git'
Or you can also download the source from github, and install it from local.

Remove gem installed via Bundler from Git/Github

In my Rails app, I have installed the gem sdoc from Github by specifying gem 'sdoc', github: 'voloko/sdoc' in my Gemfile. All was well until I recently updated Bundler to v1.6.0.rc.
Now I get the following error message when Bundler tries to load the gem:
There was a LoadError while loading sdoc.gemspec:
cannot infer basepath from
/Users/manuel/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/sdoc-1a0e80c2d629/sdoc.gemspec:2:in `require_relative'
Does it try to require a relative path? That's been removed in Ruby 1.9.
I've already fixed the issue and submitted a pull request, but I cannot get rid of the "broken" gem!
This is what I tried:
removing the gem from the Gemfile or setting it to a different version
removing Gemfile.lock
deleting the gem folder /Users/manuel/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/sdoc-1a0e80c2d629
gem uninstall sdoc (It doesn't even appear in gem list)
Nothing helped, every time I do bundle install or bundle update afterwards, I get the same error.
Any hints?
First-off: Clarifying a few things
From the Bundler documentation:
Because Rubygems lacks the ability to handle gems from git, any gems installed from a git repository will not show up in gem list. They will, however, be available after running Bundler.setup
Also, after deleting the gem inside the . . . /bundler/gems/ directory, you also should run rbenv rehash. This should get rid of the gem for you.
Answer:
Go to the root directory of your project (where the Gemfile resides) and run bundle clean. You have to pass either --path or --force switches. This should remove gems installed via git (usually if you have those gems installed and listed by gem list).
If you have issues. Delete the directories manually as you already tried and run rbenv rehash.
If I were you I would downgrade Bundler (ie. uninstall the RC release and install the latest stable).

Rails: purpose of downloading gems locally

Generally, if I need a gem, I put it in the Gemfile and bundle install. However, I don't understand if there is a benefit to downloading the gems locally first with gem install _____. Is there any benefit to this? Does bundle install no longer have to connect to the net in that situation?
Bundler installs the gems located in your Gemfile locally the same as if you ran gem install for each of those gems.
Gem install needed for gems that can be used outside of bundler applications. For example request-log-analyzer need to be installed outside of any apps for be available in command line.
I myself use gem install _______ then i use bundle install --local which doesn't require internet connection if the gem is found locally but will return an error if the gem was not found locally...
I find this method faster in downloading and installing gems, plus if the gems are found locally then i have also the benefit of altering the gemfile and install the gems without having internet connection.

Resources