How to load forked github repo as gem in sinatra/rack application - ruby

I'm trying to use a gem called "rbing" but there is an issue with it and the project has been abandoned but someone made a fix in a repo so I decided to use bundler to specify the new version.
gem "rbing", :git => "https://github.com/KellyMahan/rbing.git"
It even installed correctly when I ran bundle install, but inside my Gemfile RubyMine is complaining that "The gem with the specified version requirements isn't available inside SDK RVM: ruby-2.0.0"
And it doesn't show up in my external libraries directory.
Any help is very much appreciated guys,
Cheers, Adam
EDIT: Ruby version,
Bundler 1.3.5
Ruby 2.0.0 (2013-05-14 patchlevel 195) [x86_64-darwin12.3.0]
Rubygems 2.0.3
rvm 1.20.11 (stable)
GEM_HOME /Users/adam419/.rvm/gems/ruby-2.0.0-p195
GEM_PATH /Users/adam419/.rvm/gems/ruby-2.0.0-p195:/Users/adam419/.rvm/gems/ruby-2.0.0- p195#global
rubygems-bundler (1.1.1)

Change your Gemfile to:
source "https://rubygems.org"
gem 'sinatra'
gem 'rbing', :git => 'https://github.com/KellyMahan/rbing'
I just did it here for RubyMine 5.4 and it works like a charm:

Related

Bundler could not find compatible versions for gem "globalize":

Hi everyone I have recently started developing with this framework, I am having difficulties in starting a project locally.
When I go to run a
bundle install
I get this error message:
Bundler could not find compatible versions for gem "globalize": In Gemfile:
globalize java
globalize-accessors java was resolved to 0.2.1, which depends on
globalize (>= 5.0.0, ~> 5.0)
Could not find gem 'globalize (>= 5.0.0, ~> 5.0)', which is required by gem 'globalize-accessors', in any of the relevant sources: https://github.com/globalize/globalize.git (at master#bcfa30f)
Bundler could not find compatible versions for gem "globalize-accessors": In snapshot (Gemfile.lock):
globalize-accessors (= 0.2.1)
In Gemfile:
globalize-accessors java
Running `bundle update` will rebuild your snapshot from scratch, using only the gems in your Gemfile, which may resolve the conflict.
this is the part of the gemfile concerned:
########## Globalization
gem "route_translator", git: "https://github.com/enriclluelles/route_translator.git"
gem 'activemodel-serializers-xml'
gem 'globalize-accessors'
gem 'globalize', github: 'globalize/globalize'
gem 'kaminari', github: "amatsuda/kaminari", branch: '0-17-stable'
gem "kaminari-i18n"
i also tried to run bundle update but it didn't fix the problem
Ruby version:2.3.3
gem -v:2.5.2
The version of globalize in your gemfile seems not to correspond to the version required for globalize-accessors.
Try installing globalize like so :
gem 'globalize', "~> 5.0"

How to install active support with rbenv

I have setup ruby and rails using rbenv.
$ which ruby
~/.rbenv/shims/ruby
$ which rails
~/.rbenv/shims/rails
I want to install two gems i.e. activesupport and i18n. Is the procedure same i.e. Go to terminal> type the following:
$gem install activesupport
$gem install i18n
or for rbenv manager there is some other way? I don't want to break anything.
Details:
rbenv version 0.4.0.
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin15]
I prefer to use a Gemfile in the directory of the project I am working on.
Your Gemfile might look like
gem 'activesupport'
gem 'i18n'
Then run
$ bundle install
This will pull the latest versions of these gems and save them according to your defined rbenv.
Not only that. In terms of your concerns about "breaking things", when you run bundle install a Gemfile.lock file will be created detailing the current versions of the gems used specific to the project of the directory you are working in.

Ruby: Rails: Which version of a gem is used?

I have a Rails 3 application which has the following line in the Gemfile.
gem 'sqlite3', '1.3.6'
However, if I list my local gems I get:
> gem list sqlite3 --local
*** LOCAL GEMS ***
sqlite3 (1.3.6, 1.3.4)
When my Rails apps does a
require 'sqlite3'
which version of the gem is selected? Is it that the first gem in the list is selected? Is there a way to tell the Ruby runtime to use version 1.3.4 even if version 1.3.6 is installed, and mandated by the Gemfile?
You could find out with
bundle exec gem list sqlite3
Either the Gemfile will specify a version or Gemfile.lock will have the version.
Examples:
Gemfile:
gem 'tiny_tds', '0.5.0'
Gemfile.lock:
tiny_tds (0.5.0)
Edit: if you want to see the version, use iltempos' suggestion or in the rails console type
1.9.3p194 :001 > SQLite3::VERSION
=> "1.3.6"
the Gemfile list all the dependencies of your Rails application, you can add constrains about the version to use for each gem. In your example you specified that your application depends on sqlite3 1.3.6 so it will use the version 1.3.6.
In general the exact version of the gems required by your application are in the Gemfile.lock.
There are several syntaxes you can you to specify the versions:
gem 'gemname', '1.2.3' - Requires gemname version 1.2.3
gem 'gemname', '>= 1.2.3' - Requires gemname version 1.2.3 or any higher version. Can break things
gem 'gemname', '~> 1.2' - Require gemname 1.2 or a minor update like 1.2.9. You get updates but not mayor one which could break compatibility
The interesting thing to note is that once the Gemfile.lock is written and checked in your version control, it's shared between all the members of the team that all will use the same, exact, versions of the required gems.
If you need to update a required gem you can do that in 2 steps:
Update the Gemfile if needed
Run bundle update gemname
The step 2 will download the new gem version (if there is a new version respecting the constrain in the Gemfile), install it and update the Gemfile.lock accordingly.

How to install (ruby) bundler when bundler is broken

After adding
gem "ransack", :git => "git://github.com/ernie/ransack.git"
to my gemfile, I now get the error message :
git://github.com/ernie/ransack.git (at master) is not checked out. Please run `bundle install` (Bundler::GitError)
for any rails <>, bundle, or gem command.
This is with bundler version 1.0.21.
I see there is now version 1.30 on github, but the install "instructions" on the bundler site, seem to imply that it using an existing bundler to set up the new version?
http://gembundler.com/
require "rubygems"
require "bundler"
Bundler.setup(:default, :ci)
require "nokogiri"
How can I un-install the existing (broken) bundler, and install the new version, without an older version present ?
Mike
Bundler is just a gem like any gem, and there is no need to use Bundler to install Bundler, regardless of what the instructions tell you. It's as simple as:
gem uninstall bundler
gem install bundler
If you are using RVM, there may be a little more to it than this (you may have to switch to the 'global' gemset first), but not much.

gem install rails does not work

I am working on ubuntu and rvm. In any case I tried to use sudo gem (any command) it does not recognize gem as command. In addition if I use gem seperately as:
gem install rails
ERROR: Could not find a valid gem 'rails' (>= 0) in any repository
ERROR: Possible alternatives: rails
I got that error. I cannot see the reason.
rvm version 1.10.3
ruby version 1.8.7
gem version 1.6.7
What is the possible reason behind this?
Re-install all rvm and ruby and the gems, solved my problem.

Resources