I've been advised not to untrack Gemfile.lock, however i ran into issues.
I develop on my windows machine, and push to a linux (ubuntu) server, the issue is Bundler locks the windows version of some gems, by adding: x86-mingw32
after the version number, which causes issues.
GEM
remote: http://rubygems.org/
specs:
actionmailer (3.2.1)
...
mysql2 (0.3.11-x86-mingw32)
...
PLATFORMS
x86-mingw32
I use Capistrano to deploy, and i get this error:
Please install the mysql adapter: gem install activerecord-mysql-adapter (mysql is not part of the bundle. Add it to Gemfile.)
Even though my gemfile is like:
...
gem 'mysql2'
...
I think that's because Rails tries to use the windows version of mysql2 which is found on Gemfile.lock
Any ideas to solve this?
Add something like the following to your Gemfile and then bundle update (Replace your current mysql2 gem listing obviously)
if RUBY_PLATFORM =~ /win32/
gem "mysql2", :platform => [:mswin, :mingw]
else
gem "mysql2", :platform => :ruby
end
What this means is if the platform is 'win32' (Windows) then install the windows version, else install the normal version which is 'ruby' for all Unix systems. At least I don't know any Unix systems (from Mac OS X, to Linux, to Solaris, to *BSD) that that wouldn't work on.
UPDATE: Got a bit more information. The problem is that --deployment flag only looks at the lock file. Otherwise you could forgo the --deployment, lock your gems to a specific version in the Gemfile itself, and then run a bundle update to force the Gemfile to be re-evaluated which would force the selector. The problem is that bundle is not capable of what you want because it only evaluates the lock file when using --deployment flag. This means it has no way to re-evaluate what platform its on. It goes strictly by what is in the lock file. This is why the only real solution is to lock your gem versions in the main Gemfile, and then bundle update to force the re-eval.
You could probably forgo the --deployment and just use
bundle update && bundle install --without=development,test,any_other_groups --path=./vendor/bundle
This is a necessity if you're going to be developing on a completely different platform than what you're deploying on due to, as referenced, the way bundler works. The above command should replicate exactly what --deployment does. All of this will be recorded in .bundle/config as well.
You can check the RUBY_PLATFORM by typing this at the command prompt on Windows.
ruby -e 'puts RUBY_PLATFORM'
For example, this Gemfile can be shared on my Windows laptop and Linux sever.
if RUBY_PLATFORM =~ /(win32)|(i386-mingw32)/
gem 'mongrel','1.2.0.pre2'
else
gem 'unicorn'
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With