Bundler won't ignore production gems in development. #2341

Closed
starrychloe opened this Issue Feb 26, 2013 · 17 comments

Comments

Projects
None yet
7 participants

I had to re-enter this issue because someone closed it without reading it.

I have this in my Gemfile, yet Bundler won't stop trying to install 'pg' or 'sys-proctable' in development. I've tried many ways to get it to ignore it.

group :production do
  gem 'pg', '0.12.2'
end

I can't install sys-proctable with bundle. It won't stop complaining even though it's installed:

$ gem install sys-proctable --platform universal-linux
Fetching: sys-proctable-0.9.2-universal-linux.gem (100%)
Successfully installed sys-proctable-0.9.2-universal-linux
1 gem installed

$ bundle install
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Could not find sys-proctable-0.9.2 in any of the sources

$ bundle install --platform universal-linux
Unknown switches '--platform'

$ bundle config build.sys-proctable --platform univeral-linux

$ bundle install
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Could not find sys-proctable-0.9.2 in any of the sources

$ bundle install --without production
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Could not find sys-proctable-0.9.2 in any of the sources

$ grep proctable Gemfile

$  rails console
You have requested:
  pg = 0.12.2

The bundle currently has pg locked at 0.12.2.
Try running `bundle update pg`
Run `bundle install` to install missing gems.

$ uname -a
CYGWIN_NT-5.1 dumbopc 1.7.17(0.262/5/3) 2012-10-19 14:39 i686 Cygwin

$ bundle -v
Bundler version 1.3.0

Gemfile: http://pastebin.com/Fre28yTp

gem list --local: http://pastebin.com/yP0sbHF2

Tried adding gem 'sys-proctable', '~>0.9.2', :git => 'git://github.com/djberg96/sys-proctable.git' to the Gemfile, but that didn't work:

$ bundle install
Updating git://github.com/djberg96/sys-proctable.git
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Could not find gem 'sys-proctable (~> 0.9.2) ruby' in git://github.com/djberg96/sys-proctable.git (at master).
Source contains 'sys-proctable' at: 0.9.2

I had to download sys-proctable source, run gem build, copy it to vendor/gems, then add :path => vendor/gems. However, then bundler started complaining about the 'pg' gem!

checking for pg_config... no
An error occurred while installing pg (0.12.2), and Bundler cannot continue.

deiga commented Feb 26, 2013

I just copied your gemfile and ran it with `RAILS_ENV=development bundle``

I didn't encounter your error, but I did get another one (http://pastie.org/6337957)

deiga commented Feb 26, 2013

Ok, I'm on OSX 10.8.2 so the comparison might not work too well.

But for me the wdm version 0.0.3 caused problems (0.1.0 worked) and the win32console(didn't try any other version)

which ruby version are you using?

At least you got that far, and could decide to remove 'wdm'. I looked up 'wdm' and it's only for Windows. I'm not familiar with RAILS_ENV=development bundle shell syntax. Are you sure it does what you think it does?

$ COW=chicken echo x$COW
x

I have

$ ruby -v
ruby 1.9.3p385 (2013-02-06 revision 39114) [i386-cygwin]

$ RAILS_ENV=development bundle install
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Could not find sys-proctable-0.9.2 in any of the sources

deiga commented Feb 26, 2013

RAILS_ENV=development bundle just specifies the environment variable RAILS_ENV for just this command.
That kind of syntax is used heavily to start rails server/console in dev/test/prod modes without having to change configurations etc.

Could you run DEBUG_RESOLVER=true bundle install and post the logs? :)

The log was pretty big. It almost fell off my buffer. pastie.org couldn't handle over 64kb. http://pastebin.com/Ye0t2epK

deiga commented Feb 26, 2013

Okay, I'm getting the hunch here, that bundler might be looking for the wrong platform version of sys-proctable.
And I think bundler syntax doesn't yet support specifing the gem platform.

We have a similar problem (but a gem that was not supposed to be touched on production). A quick fix was to use a separate gemfile for development.
Bundler tries to execute git for a gem that is under a group.
Something similar to:

group :development do
  gem "nokogiri", :git => "git://github.com/tenderlove/nokogiri.git"
end

Sounds like a similar issue.

I have since learned how to find the gem that caused the dependency:

$ gem dependency sys-proctable --reverse-dependencies
Gem sys-proctable-0.9.2-universal-linux
  test-unit (>= 2.4.0, development)
  Used by
    guard-spork-1.2.0 (sys-proctable (>= 0))

Though the platform and environment issue still exists.

Owner

indirect commented Mar 1, 2013

The sys-proctable gem says that it only works on Linux, and Bundler is respecting that. That is why it won't install on Windows. I'm not sure what to tell you, other than "please don't try to use linux-only gems on windows, because they won't work". If you remove the sys-proctable gem, are you still having trouble?

The problem isn't entirely with sys-proctable. I downloaded the source and compiled it fine. I can also run gem install sys-proctable --platform universal-linux. Cygwin is just like generic Unix or Linux.

If you read the first post carefully, you will see that I did not even have sys-proctable, as expressed by the grep proctable Gemfile line. It was being required from another gem, both guard-spork and pg.

These are the following problems:

  1. There should be a way to specify the platform, i.e. universal-linux. Alternatively, treat Cygwin as Unix, not Windows.
  2. Despite using --without production, it still tried to install the pg gem that was in the production group.
Owner

indirect commented Mar 3, 2013

It sounds like treating Cygwin as Unix is probably the right thing to do. I'm not totally sure how to do that, but I'll look into it.

As for the without groups, I tried to reproduce your problem and I couldn't. The gems in the production group aren't installed for me.

On Mar 2, 2013, at 9:54 PM, starrychloe notifications@github.com wrote:

The problem isn't entirely with sys-proctable. I downloaded the source and compiled it fine. I can also run gem install sys-proctable --platform universal-linux. Cygwin is just like generic Unix or Linux.

If you read the first post carefully, you will see that I did not even have sys-proctable, as expressed by the grep proctable Gemfile line. It was being required from another gem, both guard-spork and pg.

These are the following problems:

There should be a way to specify the platform, i.e. universal-linux. Alternatively, treat Cygwin as Unix, not Windows.
Despite using --without production, it still tried to install the pg gem that was in the production group.

Reply to this email directly or view it on GitHub.

p commented Mar 4, 2013

$ COW=chicken echo x$COW
x

This is different because $COW is expanded when the command is built, not when it is executed. Compare:

% COW=chicken sh -c 'echo x$COW'
xchicken
Contributor

xaviershay commented Aug 21, 2013

Please reopen if still a problem on 1.4rc. Sorry I'm not able to try and repro this myself.

xaviershay closed this Aug 21, 2013

dt1973 commented Jun 9, 2015

Hi! Using Bundler 1.10.3 with Ruby 2.2.0 on OpenBSD 5.7 -- gems inside the production group are still installed in development, despite RAILS_ENV=development bundle install.

Owner

indirect commented Jun 9, 2015

@dt1973 this is a closed ticket. Please check the documentation at bundler.io, and then read ISSUES for help with troubleshooting. If you're still having problems, open a new ticket.

dt1973 commented Jun 10, 2015

Will do, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment