1

I have a very recurrent problem here. (it happens literally all the time). I have found ways to go around it but i really would appreciate a solution for this problem:

Here is how it goes:

At my development machine, i have in my gem file a line like this:

gem "sqlite3-ruby", :require => "sqlite3"

what happens is that, when i bundle install --no-deployment, it goes alright:

Using sqlite3 (1.3.5)
Using sqlite3-ruby (1.3.3)
Updating .gem files in vendor/cache
Your bundle is complete! It was installed into ./vendor/bundle

But then, in the deployment, running bundle install --deployment, i get:

Using sqlite3-ruby (1.3.3)
Updating .gem files in vendor/cache
Your bundle is complete! It was installed into ./vendor/bundle

... which causes require errors that makes the application crash.. Then, what i do is bundle install --no-deployment at the deployment machine. Then i run again bundle install --deployment and then, magically:

Using sqlite3 (1.3.5)
Using sqlite3-ruby (1.3.3)
Updating .gem files in vendor/cache

And then the application runs fine.

So, what i most basically want is that bundler recognizes the sqlite3 dependency on sqlite3 gem

pedrozath
  • 2,353
  • 4
  • 20
  • 23

1 Answers1

1

But then, in the development, running bundle install --deployment, i get:

Okay, this is the first suspicious thing. Why would you run --deployment in development?

You generally don't want to do that. If you're switching all the time between "--deployment" and "--no-deployment" on the same machine, it's easy to get things confused, yes.

Running "bundle install --deployment" will save something in the .bundle/config file in your project, that tells bundler "from here on out, only install these certain gems". "--no-deployment" removes that again, in case you made a mistake or need to hack around. But in general, you shouldn't need to and don't want to always be switching back and forth. Run --deployment on your production/deployment machine, don't run it on your development machine. You don't ever need to run --no-deployment unless you made a mistake and didn't mean --deployment

At this point, I'd rm -rf .bundle (it's okay, it'll just remove all the things bundler 'remembers' about what you want to do, like --deployment), and start over with bundle install.

If there's some reason this doesn't work, then that's the question.

From the line Updating .gem files in vendor/cache, I suspect at some point you also ran bundle package, which is another thing that's "remembered" in the .bundle/config thing, and is also probably interacting with your other commands oddly and doing things you don't expect. Removing your .bundle/config will get rid of that remembered setting too. (you may also need to delete your ./vendor/cache directory contents)

Just run bundle install unless you have a reason you understand for needing package, and understand what it does. Or it'll confuse you.

jrochkind
  • 22,799
  • 12
  • 59
  • 74
  • I meant deployment, not development. Nevertheless, your answer clarified me some stuff. I'll deploy a new website soon then i'll let you know the results. Thanks anyway for your explanations. – pedrozath Mar 20 '12 at 18:29