Specifying target path in Gemfile for bundler - ruby-on-rails-3

I'm trying to fetch a gem from remote source and then extract it into vendor/engines
Is there a way to do this using bundler and Gemfile?
Is there a way to specify target directory for a gem?

You can do this by
gem "mygem", :path => "vendor/MyPath/MyGem.gem"
refer, How to tell the Gem File to use a specific local copy of a gem

Related

Rails can't install gem sqlite

Gem files will remain installed in
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/sqlite3-1.4.0 for
inspection.
Results logged to
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/extensions/x86-mingw32/2.3.0/sqlite3-1.4.0/gem_make.out
An error occurred while installing sqlite3 (1.4.0), and Bundler cannot continue.
Make sure that gem install sqlite3 -v '1.4.0' succeeds before bundling.
I tried to install earlier version on sqlite, not working.
Tried one of the solutions from stackoverflow :
gem 'sqlite3', '~> 1.3.6'
getting this error
ERROR: While executing gem ... (Gem::CommandLineError)
Unknown command sqlite3,
Please help i'm new in Rails , this is my first project in rails.
Add gem 'sqlite3' to Gemfile in the root directory of your rails project. Then run bundle install and it should install sqlite and make it available to use in your rails project.
Specify git and branch for the gem sqlite3 in your Gemfile should fix the problem.
gem 'sqlite3', git: "https://github.com/larskanis/sqlite3-ruby", branch: "add-gemspec"
For more info
https://medium.com/#declancronje/installing-and-troubleshooting-ruby-on-rails-sqlite3-windows-10-fix-87c8886d03b
cannot load such file — sqlite3/sqlite3_native (LoadError) Ruby on Rails
Replace gem 'sqlite3' with gem 'sqlite3', '~> 1.3.11' which is in Gemfile in the root directory of your rails project. Then run bundle install.

Rails bundle install production only

I'm still new to rails/ruby/bundler and am a little confused.
In our config/application.rb file there's this bundler segment:
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end
and in our Gemfile we use different groups, e.g.
group :development, :test do
gem "rspec-rails", ">= 2.7.0", :group => [:development, :test]
gem 'shoulda-matchers'
gem 'watchr'
gem 'spork', '~> 1.0rc'
gem 'spectator'
gem 'debugger'
gem 'wirble'
end
But when I run RAILS_ENV=production bundle install (or bundle install --deployment), it still installs gems from the development/test group...
Why does this happens or how can I make this work properly?
THIS ANSWER IS OUTDATED
Take a look at --without option:
bundle install --without development test
By default Bundler installs all gems and your application uses the gems that it needs. Bundler itself knows nothing about Rails and the current environment.
An alternative solution is to use the bundle-only ruby gem. It can be used as follows:
> gem install bundle-only
> bundle-only production
This library does not pollute your bundler configs or augment Gemfile.lock; it is a simple alternative to the built in bundle --without every other group option that bundler provides.

How does bundler know which version of a gem to install?

I have been using the less-rails-bootstrap gem from https://github.com/metaskills/less-rails-bootstrap in my rails 3.1 project.
I want to upgrade to the 2.0wip version of bootstrap and I found a fork with the same name under https://github.com/sgruhier/less-rails-bootstrap
Both version say to install you add gem 'less-rails-bootstrap' to your gemfile.
Well, how is bundler going to know which one to use? What if 20 people had gems with the exact same name?
I guess the bigger question is how to I specify which gem to use?
Bundler will use the one found on http://rubygems.org, which is the one at the first link you posted.
When trying to use an unreleased branch/fork, you should pass the :git option in your Gemfile to tell Bundler to use that git repository:
gem 'less-rails-bootstrap', :git => "git://github.com/sgruhier/less-rails-bootstrap.git"

Rails3: How to manage tainted gem

I'm a n00b in Rails and in Rails 3. I had to patch activerecord-jdbc-adapter source locally because of a bug. See Rails 3 ActiveRecord chaining for details. I modified locally lib/arel/visitors/sql_server.rb as described by the page https://github.com/ystael/activerecord-jdbc-adapter/commit/8815d2fe133afb6774ebe12cc27c3a977dbf7ad2.
I would like to manage these changes until the problem is solved centrally with a special attention on smooth deployment. What commands should I run? Which path should I apply the patch on? Which things should I add to my SVN repo? How will I deploy then?
Here is my Gemfile, maybe counts:
source 'http://rubygems.org'
gem 'rails', '3.0.7'
gem 'will_paginate', '3.0.pre'
gem 'activerecord-jdbcmysql-adapter'
gem 'activerecord-jdbcmssql-adapter'
You can add git repository to you gem command.
gem 'activerecord-jdbcmysql-adapter', :git => 'git://github.com/..REPOSITORY...git'

bundle install error

I'm trying to install this gem: https://github.com/jongilbraith/simple-private-messages with bundle install.
And I'm getting the following error message:
Updating git://github.com/professionalnerd/simple-private-messages.git
Fetching source index for http://rubygems.org/
Could not find gem 'simple-private-messages (>= 0, runtime)' in git://github.com/professionalnerd/simple-private-messages.git (at master).
Source does not contain any versions of 'simple-private-messages (>= 0, runtime)'
entry in Gemfile:
gem "simple-private-messages",:git =>"git://github.com/professionalnerd/simple-private-messages.git"
Any ideas?
As per #bjeanes answer, ideally the Git repository should have a .gemspec file for each gem the Git repository represents.
However, if the repository is only missing the .gemspec file and would otherwise be a valid Git gem source, you can specify a version number in your gem call to have Bundler generate a .gemspec for you:
gem 'simple-private-messages', '0.0.0', :git => 'git://github.com/jongilbraith/simple-private-messages.git'
The git repo needs to have a .gemspec file in it in order to be a valid gem.