I am developing with bundler under Windows and am wondering how to create the Gemfile.lock for my production environment.
What seems missing are the gems for other platforms. Running bundle install on
group :production do
gem 'mysql2'
end
on Windows creates a Gemfile.lock
mysql2 (0.3.18-x86-mingw32)
When deploying to a Linux environment this is obviously not correct, I would need the Gemfile.lock to also contain the correct result for Linux. I can run bundle install on Linux and learn that indeed
mysql2 (0.3.18)
is the correct gem for Linux. I then manually update the Gemfile.lock in the repository to contain both:
mysql2 (0.3.18)
mysql2 (0.3.18-x86-mingw32)
This works clean under both platforms, but it seems a kludge.
How can I tell bundle to resolve the Gemfile.lock for another platform other than the local one? I guess I need something like bundle install --all-platforms. What am I missing?
It would appear this is a known shortcoming in bundler and the workaround seems to be to run bundle pack on every platform you need to use.
Running the following commands will fix your issue.
bundle lock --add-platform x86_64-linux
bundle install
git add . ; git commit -m fix
Reference
https://www.moncefbelyamani.com/understanding-the-gemfile-lock-file/#platforms
https://bundler.io/man/gemfile.5.html#PLATFORMS
https://github.com/rubygems/rubygems/issues/4269#issuecomment-758564690
Related
Whenever I run bundle update or bundle install on Windows 8.1 I can't update/install gems from github. I can install other gems like uglifier, but it doesn't work for github gems specifically. For example, putting this in the Gemfile
group :development, :test do
gem 'rspec-rails', '2.13.1'
gem 'spork-rails', github: 'sporkrb/spork-rails'
end
results in the error:
Retrying source fetch due to error (2/3): You need to install git to be able to use gems from git repositories.
The problem is I definitely have git installed. I was running this from Git Bash and working in a project that I was cloning, pulling, and working with off of Git. So why does the bundle update/install keep insisting that I don't have git installed? How do I fix it and make bundle install work?
Are you running a pre-release version of Bundler? This commit might be related to your problem; it looks like earlier versions of Bundler scan your %PATH% for "git", but not "git.exe".
The easiest solution would be to backport bundler to 1.3.5:
gem uninstall bundler
gem install bundler
Don't forget to select radio "Use git from Windows Command Prompt" while installing the Git. Thats the key!
By default "Use git from Git Bash only" is set.
For me it was also the path, with space and accent, I guess that was the accent the issue. installed the bundler 1.6-pre, uninstalled git, reinstalled it in C:\Git, changed the path of git in my IDE (RubyMine) and finally installed every gems using bundle install.
Thanks a lot!
While on Windows, if you're still getting that error after installing git too, make sure to close the 'CMD' instance and open it again, the system paths vars have been set, but not instantiated in the active 'CMD' window.
I'm going through Micharl Hartl's well known Rails tutorial, and this piece is confusing me. Every time a new app is set up, these commands are run:
$ bundle install --without production
$ bundle update
$ bundle install
I don't really get why install is being run twice. What is the effect of these three commands run in this sequence?
You should not have to run bundle install twice as bundle update will also install all of your gems (as well as updating them to their most current version). I have not read the tutorial you mentioned but perhaps the purpose of the second install is to install all of the gems, including those reserved for production.
Your second question, what is the effect of these three commands:
bundle install --without production
Inspect the gemfile, ignoring gems that are reserved for production
Resolve all dependencies
Install all gems and dependent gems
Save the exact version of each gem to Gemfile.lock
bundle update
Inspect the gemfile
Resolve all dependencies from scratch using the newest version of each gem and completely ignoring Gemfile.lock
Install all gems and dependent gems
Save the exact version of each gem to Gemfile.lock
bundle install
Because this is the first run of the production gems, inspect the gemfile and resolve dependencies of the production gems
Use Gemfile.lock for exact versions of all other gems to be installed
Install all gems and dependent gems
Save the exact version of each gem to Gemfile.lock
Hoped this helped, for more detailed info about the two commands check out this and this.
$ bundle install --without production prevents bundler from installing any of the production gems. It also gets saved in your local repository and you don't have to run it more than once. Any subsequent run of bundle install will include --without production.
bundle install installs only the missing gems from your Gemfile, while bundle update updates/installs every single gem to the latest version as specified in the GemFile..
I want to be able to define in my Gemfile that on my development machine (Windows 7) a certain gem (pg) version (0.14.0-x86-mingw32) should be installed, but on my production server (Debian) it should install the regular version.
I have tried defining groups in the Gemfile, but this does not seem to be reflected in the Gemfile.lock and when I run bundle install on my development machine (Windows), it lists the windows version of the gem in the Gemfile.lock. Then when I try and deploy with Capistrano, it runs bundle with the --deployment argument (and --without groups-i-want-to-exclude), which uses Gemfile.lock and doesn't install the pg gem at all because the version listed is for Windows.
I don't want to have to manually edit Gemfile.lock on my production server, because this is generally a bad idea, and each time I redeploy from my repo it will change back to the windows-specific version. I also don't want to turn off the --deployment option (my current solution) because this is not how bundler was intended to be used in this situation.
If you don't want to change Gemfile.lock on production server then you can change it on local machine. Try hope this work, change manually in Gemfile.lock after bundle install, and deploy -
PLATFORMS
ruby
x86-mingw32
Authlogic has a couple unfortunate deprecation warnings that are fixed in a fork.
How do I use this forked version? I tried adding the following to my Gemfile:
gem 'authlogic', :git => 'git://github.com/railsware/authlogic.git'
And it didn't work quite that well. I started getting:
git://github.com/railsware/authlogic.git (at master) is not checked out. Please run bundle install
And
The git source git://github.com/railsware/authlogic.git is not yet checked out. Please run bundle install before trying to start your application
Assistance will be rewarded with virtual cookies.
Have you tried running bundle install after removing Gemfile.lock?
rm Gemfile.lock
bundle install
Your Gemfile configuration should work, I was able to use the same for and my bundle install command executes as does my bundle list command.
My other suggestion would be removing you ~/.bundler and .bundle directories and checking that you have properly configured git.
You need to run bundle install from the terminal after updating your Gemfile.
I'm pretty new to Ruby/Rails but I was taking a look at bundler and was wondering how it works exactly. Do you install a full set of gems like normal gem install XYZand then use the Gemfile to pull a certain subset of those gems for use with a specific application? Or do you not install gems normally anymore and just include them in the Gemfile and then do a bundle install to include them all in a bundle that is then used with your application?
Thank you so much for taking the time to answer this, I'm just a little confused on what bundler's functionality is exactly.
-- MAP
These two links explain everything about bundler.
How does bundler bundle
How does bundle require gems
Think of bundler as a package management tool.
From bundle help command:
bundle install # Install the current environment to the system
bundle package # Locks and then caches all of the gems into vendor/cache
So bundle install command will install all gems to the system that are listed in Gemfile as well as their dependencies. If the gem was not previously installed it will grab it from the gemcutter repo. bundle package will cache the .gem files into your apps vendor/cache directory.
No need to run gem install first.