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
Okay, this is the first suspicious thing. Why would you run
--deploymentin 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/configfile 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--deploymenton your production/deployment machine, don’t run it on your development machine. You don’t ever need to run--no-deploymentunless you made a mistake and didn’t mean--deploymentAt 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 withbundle 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 ranbundle package, which is another thing that’s “remembered” in the.bundle/configthing, and is also probably interacting with your other commands oddly and doing things you don’t expect. Removing your.bundle/configwill get rid of that remembered setting too. (you may also need to delete your ./vendor/cache directory contents)Just run
bundle installunless you have a reason you understand for needingpackage, and understand what it does. Or it’ll confuse you.