Project

General

Profile

Bug #1367

Ensure all gems are defined in Bundler Gemfile

Added by Ohad Levy over 7 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Rails
Target version:
Difficulty:
Triaged:
No
Bugzilla link:
Pull request:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

Currently some dependencies of Foreman, especially gems for database access like `pg` or `mysql`, are missing from our `Gemfile` because we have no good way of handling them selectively.


Related issues

Related to Foreman - Bug #1382: no such file to load -- pgDuplicate2011-12-07
Related to Foreman - Bug #1380: /has_many_polymorphs.git (at master) is not checked out. Please run `bundle install` (Bundler::GitError)Closed2011-12-07

Associated revisions

Revision e6d6111b (diff)
Added by Ohad Levy over 7 years ago

refs #1367 - a better version of our gemfiles, not perfect yet.

History

#1 Updated by Jochen Schalanda over 7 years ago

  • Subject changed from ensure all gems are defined in bundler gemlock file to Ensure all gems are defined in Bundler Gemfile

Short relevant discussion on https://github.com/ohadlevy/foreman/pull/23

Comment

ok, a few points then:

  1. we cant ship bundle lock file in the app
  2. we either need to manage the config file in the package, or run in post section of each db package bundle --without

what do you think?

From the perspective of creating Debian packages for Foreman the "database gems" (`mysql`, `pg`, `sqlite3`) don't have to be listed in the `Gemfile` at all. They're all available as packages in the Debian-based distributions we're supporting.

These three gems are special in the way that they need additional packages or header files installed on the system and they are bound to the respective Ruby version they've been installed for since they contain binary extensions.

But of course it's not a good practice to have an incomplete manifest of dependencies (which `Gemfile` basically is) for any other user which would want to install Foreman from source or from the git repository.

In my opinion the best option currently is having separate groups for these dependencies (like the pull request introduced) plus adding Bundler's `.bundle/config` file in which these groups are excluded.

For example if a user wants to use `sqlite3` she can run `bundle install --without mysql postgresql`. A simple `bundle install` without additional parameters would install neither `mysql`, `postgresql`, nor `sqlite3`.

#2 Updated by Ohad Levy over 7 years ago

Jochen Schalanda wrote:

From the perspective of creating Debian packages for Foreman the "database gems" (`mysql`, `pg`, `sqlite3`) don't have to be listed in the `Gemfile` at all. They're all available as packages in the Debian-based distributions we're supporting.

True, but bundler has two reposibilties, it download and require the gem, so AFIAK, if its not in the Gemfile, then its not loaded at all.

These three gems are special in the way that they need additional packages or header files installed on the system and they are bound to the respective Ruby version they've been installed for since they contain binary extensions.

But of course it's not a good practice to have an incomplete manifest of dependencies (which `Gemfile` basically is) for any other user which would want to install Foreman from source or from the git repository.

In my opinion the best option currently is having separate groups for these dependencies (like the pull request introduced) plus adding Bundler's `.bundle/config` file in which these groups are excluded.

For example if a user wants to use `sqlite3` she can run `bundle install --without mysql postgresql`. A simple `bundle install` without additional parameters would install neither `mysql`, `postgresql`, nor `sqlite3`.

I agree, what about removing the lock file from the repo?

#3 Updated by Jochen Schalanda over 7 years ago

Ohad Levy wrote:

True, but bundler has two reposibilties, it download and require the gem, so AFIAK, if its not in the Gemfile, then its not loaded at all.

I have to check that again, but if a library is installed in Ruby's library path (not necessarily by RubyGems or intermediarily by Bundler) it should be possible to load them by simply require-ing them. In case of Foreman these libraries are being loaded by ActiveRecord, aren't they?

I agree, what about removing the lock file from the repo?

I'm not sure about this. On the one hand having a working set of definitely working dependency versions is good, but on the other hand it might be a problem if the Ruby version or architecture changes. Currently I'm for keeping the Gemfile.lock in the repository.

#4 Updated by Ohad Levy over 7 years ago

Jochen Schalanda wrote:

Ohad Levy wrote:

True, but bundler has two reposibilties, it download and require the gem, so AFIAK, if its not in the Gemfile, then its not loaded at all.

I have to check that again, but if a library is installed in Ruby's library path (not necessarily by RubyGems or intermediarily by Bundler) it should be possible to load them by simply require-ing them. In case of Foreman these libraries are being loaded by ActiveRecord, aren't they?

Yes, but db gems are special imho, not sure who loads first.

I agree, what about removing the lock file from the repo?

I'm not sure about this. On the one hand having a working set of definitely working dependency versions is good, but on the other hand it might be a problem if the Ruby version or architecture changes. Currently I'm for keeping the Gemfile.lock in the repository.

Well, what about different versions of puppet, or other 3rd party gems that are already in various versions in the different distributions?

#5 Updated by Ohad Levy almost 7 years ago

  • Status changed from New to Closed

this has been resolved by the varios packages.

Also available in: Atom PDF