Bestand wählen

How Does Bundler Work, Anyway?

Zitierlink des Filmsegments
Embed Code

Automatisierte Medienanalyse

Erkannte Entitäten
time and a new and so on and so so it's a little bit and so by this factor is about How when the words and city and those 1 work this is interesting question will we'll talk about it for a while and so this talk is kind of
a brief hopefully brief history of dependency management in Ruby and kind of a discussion of how of libraries and shared code works by its how it's worked in the past and how it works now because property now was kind of I directly a result of how it used to work in the past and trying to fix problems that have been back that and so before
it started to introduce myself findings on Arco I and indirect upon pretty much all interact things that's my Avatara using a web page somewhere but as
my day job I work because the development of doing Ruby on Rails on the web and number consulting and review whether mobile development and I mostly do architectural consulting and senior developer pairing in training and it that's something that you're companies and to talk to me later but the other the other
company that I have found it is called Ruby together and it's a non profit and it's kind of like and incorporated but without the venture capital and really together is a trade association that takes money from companies and people who use really and use London regions and all the public infrastructure that everyone who uses reviews this and pays for developers to work on that stuff so that regions covered stays up and so that people keep being able to have genomes which is pretty cool and
as part of my work for a review together and I work as leader of the ability and I'm than working on bummer since before 1 point OK now and I've been team lead the last 4 years so
using Ruby code written by other developers on nowadays this is actually really easy you
you outlined here damn found through you go you turn on your amongst all of you so using that actually it on pretty cool that's really easy the thing that I've noticed talking to people who are use Butler and think that it's often is that it's not actually clear would just and based on the text and it up by 1 will install it seems like something probably got downloaded and something probably have installed but it's not totally clear what that downloaded it's not clear what got installed not clear where any of that happened and it's not clear here like what get what exactly happened and nobody's really share and how how is just putting aligning ejemplo even start using somebody else's code and so to explain that will need a little bit of history and then go back in time and I'm going to give you a little to were from the beginning of sharing code and the the up until now and and hopefully by the end of that you understand why things work the way they do so I am a start talking about require which came with the very 1st version released ever in 1994 and then talk about set up Bobby which came out in 2 thousand and revisions which came out in 2003 and then by which came out in 2009 and that's what we're still using to that and so require
other require method has been around since 1994 with the very very 1st version really that actually came out of and or guess I should say I'm sure that require had been around since at least 1997 because that's the oldest version of Ruby that we have in version control style was probably there before that some but require can be broken down and even smaller subsets so using code from a file is basically the same as just inserting that code and having rerun it like you just written in the and so it's actually possible to implement require yourself with just a 1 line function and you say I have a family and I wanna it a and you read the file into memory into a string and the fastest and the evil and the runs it and it's just like you type accurate yourself and the government so there's some problems with this and this is not her require works in real life I'm sure this 1 we find that this will run that same piece of code over and over and over the required over and over and over you like having lots and lots of constants keep getting redefined and ships to be fine so were here and that is actually also pretty straightforward and you can just keep track of what you are required the in an array and not require something again in the tightening the acquired from this as you can see here you set up an array you check to see if the array already contains the file name that just got passed and and then if it doesn't if it hasn't already been required to do something weird before we the file and that's a and then added to the race that you are required again later on this In fact this is exactly where b does albeit written in C and not in the there is a loaded features global variable and it's an array and it contains a list of all the things that you require passed and so if you ever wanted to know if you required something yeah you can actually just check features on so there's 1 more problem with this words is that right now it only works if you pass that absolute that I'm sure you don't mind taking the full path from wherever you are to exactly where the pilot you wanna requires ensure that something to a so the easiest way to allow requires that aren't absolute is to just treat all requires as if their relative to the path where you started the review program and and that's easy but that doesn't help a lot if you wanna required proposed Ruby files from different places so say you have a folder full of this library wrote in a folder full of this application anyone use the library from application you can like rating relative passive are the start of the review program would be terrible on so instead we can create an array that hold the list of pads that we want to load really given a burst of creativity and is going to call that variable the load path and here's an implementation of a lot that if you put something in the load path array you can and has a relative path to any directory that's in the load path array and will look for the file it's the file so if you require flu will say is the family and who inside any of the lowpass directories and if the first one that we find searching the load path in order from 1st to last will require that who incidentally this is exactly where readers there's a global variable named load paths and if you put up a string that contains a path to a directory in at Ruby whenever you require something will look in that directory to see if there's a file that made it so you can totally used the low-pass you require files from somewhere else while you're working with on and of course the load path and features can both be combined but that couldn't fit on a single slide so all the that of an exercise that and it's pretty straightforward to be honest so
but that's a pretty good and they allow us to lower read directories even if the spread across multiple places at this point we could even have like automatically at the start of every script we could add the directory that holds the standard library to load path and in all the files that are part of the the library like now http you all the set of all those cool things that come with through the could just be available for require automatically you wouldn't have to worry about putting them in the lab pack yourself and is exactly where he does the standard library starts on the load path every restart Ruby and it's been great so this was cool on and for several years this was enough people just adding civil about a lot or wrote scripts that added thanks to the low impact before acquiring things before the actual scripts but the thing that got super tedious about just having load pass is that if you want to get code from someone else you have to find code I would like to put it in some somewhere remember where that somewhere is put that somewhere in the low fat and then require this pretty tedious sorry at so the
next thing that happened was set up on the but so were totally caught up to the state of the art in the libraries around the year 2000 everyone still installing shared Rico by hand CPE CP on and that wasn't so much fun so a developer Japanese Ruby developer named narrow quality of wrote sent a copy and amazingly even those was created in the year 2000 set of B is still around on the internet on the the website for this developer is I'm not love me . net which is pretty cool and you can even download center Bobby although to be perfectly honest it hasn't been updated since 2005 so I'm not sure it's super helpful to you so I haven't said about the work
well you at its core set of kind of mimic the classic helix installation pattern of downloading a piece of software decompressing it and then Running configure make make install and so return copy set apart because of copy that Peruvian would set of the set set of our weak Fig set up are stop and what would happen is so would copy all of the Ruby files and there is a specific directory structure kind of like a jam today where you would have a library files and been files that you can launch programs in and support files and set up a review copy all those files into a directory that was already in the load path called site and and I was like the review files that you had installed that were specific to your computer and and so after set of RBE using review libraries was actually much easier than it had been you could find a cool library on the Internet you can download that cool library you and and follicle library by hand and then you have to run could be set of RB all by hand but then he it was also known were manually copying a more you know like having them and all these files and everything was and all that is required as soon as you so obvious particles on so after a little while some of the shortcomings of this scheme became apparent to there's no versions for any of these libraries and after you run Setup RB there's not even a way to tell what version you have unless you know like unless you like write it down on most of the library offers a really nice of like put the version into the code somehow on and there's no uninstall everything just gets under the same directory so you you know you and set of for 5 different really libraries and now hold all of the files are just in 1 directory good luck figuring out which ones belong to which can if you delete the online to at the and then and upgrading upgrading the super fun but if there was a new version of the library which good luck finding that out great you had to remember the website where you got it from the 1st place I hope you write all these down I hope you've written down every word so you ever downloaded before up you to go back to that website and you have to remember which written you have which as I said before there's nothing there unless you wrote it down and then you have to download the tarball with the new version and decompresses and CD into it and run of RB all and hope that the new version didn't delete any files because the old files are still there is just 1 over the top of the that so overall business it's probably sounds little tedious it's really tedious on people frequently kind I had no idea what was actually happening with their libraries on and it was actually not uncommon for people to be like 0 this doesn't work I'm just gonna fix it in my site really directory OK everything around right yeah superacids thank you yeah so at some point some people were like hey this isn't actually had great 1 if you could just gem
install can be cool and and so in 2003 RubyGems came to the rescue and kind of fixed all the problems with set of our that 1 of them so you could check to see if a library existed by running gem lest you created in solid understanding gem install but you could install super great pan-Indian uninstall and regions kept each of these libraries in different directories so that you knew which libraries you had new had uninstall those libraries and you had installed versions of libraries and was all with a single command there is no like find on internet somewhere downloaded unpack it centerpartiet In RubyGems had another super cool trick up its sleeve which was versions of regions actually kept each version of each genome in a different place and you can install multiple versions of the same library and they could all be in your really because they did not know 1 9 fold and they all in their own separate folders so there's a folder for available for her house for 1 4 to but on this pretty cool so to make this actually work because required doesn't support versioning inherently regions added a engine method that lets you say hey I know that I have have were had and really care whether it's installed or not I need I in version 1 . 0 of lack and regions will check to make sure it's installed and then put that directory just the 1 with track 1 . 0 into your little so that when you run require accurate 1 . 0 is pretty cool I'm the and so calling the GM method told regions that you want to manipulate the load path to load it exactly the version that you knew that your code wanted to talk to produce I regions also has a way to support versioning even in commands that come with Japan's so like the rapture and comes with the racket command and if you have multiple versions of rap installed the racket command could run any of its purchase so regions defaults to the newest version that you have installed hoping that the newest version is the right 1 but if that's not the right 1 revisions actually checks of the 1st argument to the command to see if there's something with underscores on either side of it and it thinks that that will be the version number that you want so in this example were running rack up from Rackham version 1 . 2 . 2 and the only version 1 . 2 . 2 you don't have a a 1 . 2 . 2 installed regionally like a sigh I couldn't find evidence you need stops of regions was what really really successful and we grew in popularity alot but Ruby gems needed review libraries and sharing so they grow in popularity alot on present day we have about 100 thousand different genomes and about a million different versions of those 100 thousand jets on that is a lot of shared will code and that is super cool so and you probably knew this was coming as cool as regions is it still has some problems if
you have multiple applications that all use regions to load their dependencies this can be problematic it's really hard to coordinate across multiple applications because every way RubyGems works every machine or technically every individual version of Ruby but each installation of Ruby itself just has a set of genomes may procure random solve now is all these terms of and so if if 1 developer runs gem install through and starts using through an application and then like commits that code checks and the next person checks it out and tries to an application can explode with like I don't know if through is where is it in the text and for me and so it led to an error of basically share manual dependency management the so and
break this this no joke this literally happened to me in 2008 you just have welcome the the team is you clearly lapped we expect to have that running by next so it actually took me and I I a was totally working overtime on this I think it only took me 3 and a half so it was amazing of to figure out which Germans to run gem install I like looked in the readme and there was a list and install them and then clearly there were some that some people just kind of forgot to put in the Remy and hand in a kind of work but then I was able to like get images working in in some underdeveloped was like 0 yeah I have to install ImageMagick this is before homebrew the it was really really terrified of that yeah on so to try and kind of like fix this problem of like we have just link to which petitioner really how we even know if we have written everything in the in the eyes and try it uh and of course he had to get a new machine to try it on because some person you after 3 years of using review determines told everything and you have no idea what is important and what is an important that's step for us so people started working on tools to help this problem and
rails actually added this thing called configure knowledge and and is like rails 2 . 3 year at 2 . 2 error and where you would say Hey rails I need this gem and you would put it inside your application of the file and I was super helpful if you need to like you know for sure that this was the last a list of all the germs we need applications but you can only access that list in rails was already loaded so if you upgrade rails over here yeah it was pretty I so because regions automatically uses the newest version of each genome just having an older version installed didn't mean that it would be useful and if you like install some Jan on month after the other person did maybe there's a new version you just get a new version automatically so this is also totally in real life experience that happened the in 2009 debugger production server at that just throws Exception sometimes for 3 days the other production servers affine can reproduce this problem on a single developer laptop like what is even going on this so weird after 3 days and I finally thought to look at the output from journalist list for the entire production machine and I was like 0 this production server has generally in 1 1 3 and every other production server and slapped and every developer laptop has genuine 1 1 4 and that was the problem there was a bond and a back any matter and this problem and and then like I was saying about rails versions you could gem install rails be happy making laughter and a server everything's great and then you switch to another application on existed did didn't get written to use that version rails gap the some older roots rails no like OK let's go this is just another over rows and there is no way to like if you put the rails version in your configure genome line inside your application then rails would complain the the wrong version rails Perales had have successfully started up to tell you that you have the original rail sudden actually help of and ultimately like it was actually a significant part of my job as a Ruby developer to like figure this shit out by hand and so on depending on what exactly did on the team some people on my team at the time spent like a quarter or a 3rd of the time doing nothing but figuring out and fixing dependency many issues and it was really really like I felt really bad and sometimes it was me and I don't really bad for me the and then there's 1 more even after you've done all this by management of there's 1 more problem that regions has of that yeah is another reason why bone was created and that is activation areas on which yeah so in activation error is what happens in regions where in you load application and you start by saying hey I need this step and investor any of this other gene and so regions will will the newest version of those genomes that can on and so sometimes it's a standard this term and and this gem only that in that Germany this chair and you'll get like the newest version of that that child you and then later you say 0 I also need this and I don't work that who uh so how how common can this be really well unfortunately it was super common but not like happens to you everyday common but like happens to you may be 2 or 3 times a year and when it happens you basically Terrell your hair out to your entire install and reinstall really started selling and again it is figuring out exactly which combination of installed genomes was causing this problem it was just a total nightmare and so in this is this is a real life activation and salvage this from a presentation that I gave in 2010 about why but exists at so this is a Rails and it's loading and Wales of course depends on action packed this is the rails to 3 three-year action-packed depends on rack Rock agenda helped will start web servers and fear which is a web server also depend on so rackets how rails talks to the of and talks to rails but there's a problem this is perfectly happy to use rock 1 . 1 which make some changes to have works action attack on the other hand is not happy to use record . 1 and can only use rack 1 . 0 and so when you run your server your server course loads thin 1st because the is the server and think it's to work trying to load up your around application and Rails application says I can actually use that rats are at the end of so but the conclusion here is that so the reason that these activation errors what happened is that regions does what we call runtime resolution on which is the regions figures out which versions of which gender it should load after regions already running around and you say anything and it's like OK I think this version works and then at some point if later on you say anything that doesn't work with things we've already done RubyGems just has to be like all contigs that and so the the fix for this problem is to figure out all of the versions before you run your application you have to know that the versions that you can use are all versions that can work together with 1 on and so resolving things when you like at install time right which is when you install the germs no bigger installing version that work together an obsession
you're probably saying how how do we make sure that all the variants that were installing work together well that's actually were about to so no it before but the the process of figuring out which gems would work together was done entirely by hand and it consisted of German install gem install slightly older version does real sort of get time uninstalled giants or slightly older versions Israel start up yet but and when the exception stopped you need 1 of unsurprisingly computers are a little bit faster this process the people and computers are also really good and accurate at trying many many many many many options until 1 of them actually works and so this is what we're that's
what you think yes and no when the figures out the entire list of every genome and every version of every jam that you need but also all work together with other this is called dependency graph resolution and there's like an entire act like his entire academic literature about dependency graph resolution and its it's kind of a well-known hard problem it's part of a set of problems called NP complete and the talk will be fantastic thing and I say this as a person who has to fixed on the 1 that doesn't work is that in theory you can construct a set of genomes and GEM file such that it is not possible to find a set of genomes that work together until after the heat death of the
most of the time we don't have that long to wait and so we use a lot of tricks and shortcuts and heuristics to try and figure out which aims to try 1st and hopefully actually finish you know before you drop a cup of coffee or whatever on so we had this pretty large Bill subset of tricks over the years and most and actually result in less than 10 seconds which is pretty cool considering that the upper bound on that is practically infinite and so after finding versions that work together because this problem is really hard and we don't have to keep doing it over and over and over on minor rates down the exact aversions of every genome that did all work together so that they can be reused by other people who are also interested in learning applications and so that file is called the GEM piled up lock this is the little snippet of a gem filed locked showing you which never need to be installed which versions of those gently be installed and as a bonus the log file is what makes it possible to install the exact same version of every German on every machine that's running this application that means that when you develop on your laptop you get whatever version of the genome was newest we were developing is you know but song about the newest version and faltering but because of the log file when you put them on a production server completely guaranteed that you will also have a version 1 . 1 . 4 of fragments and your you will have to spend 3 days figuring out why a production server doesn't quite work out it's pretty great so the fundamentally like the core of 1 consists of 2 steps model install and but exact so the steps to run on store actually pretty simple on they're totally understandable in plain english that fits on a single slide which is great and I in this slide for maybe 10 minutes to leading words and 2 so the steps to bundle installed are read the Gentile ask regions . org for a list of all the genomes that were going to need find versions of those genomes that are both allowed by the gentiles because you can sometimes say mean what this version I only want that were not only 1 version is greater than ever and so on and then once you found versions that all work together because he checked right although the intent lot and then install every version until every intelligence lockers and and that's about all sorts 1 install actually uses revisions the covers to do the installation on and so every bundle is its own little regions isolated install on every application has its own rich text on and in the next step is by exact which is how we use that applications dedicated little regions instead of the 1 that just has whatever and because the random install last year so the women exact works is it reads file and theory the lot of box there it uses the log if thought I was there and if the lockout isn't there it finds directions that all work together just like install except penguins that doesn't do any installing just as well our pathogens that work together it is cool on and then bundle exec deletes any gyms there already in the low-pass is sometimes that happens before 1 nodes and then it adds the exact German at the exact version that you need to look at the news of the great that's it that's all the that does its incidence collagens that actually work together and the exact versions in the world that the application just goes on its way in there's no activation areas all your requires actually succeed I hope everything's pretty great on that so as I think I promised in the abstract for this talk here is a bundle exec removing proton and I don't really like typing bundle exec and really annoying but bummer provides a way to not have to take on that call time and it is to create programs that map to the little copies like the the region insulation that belongs just to application and you can use the been stubs command on open stubs some gems and it will create into the bin directory a program for that genome that only runs the exact version that belongs to the application and so if you have passed back in your else that you can have been ah a spectacle in the march the correct and in this way you can have been a spec refer to large victory in this application and have been spectra forgot to that kitchen no exact the data on rails actually started to do this very thing and wells for ships with been rails and been lake that our scope like so when you run males you get the exact reals version for that application and not this application and when you and then break you get the exact indirect at application and not this much pretty cool No model exact if everyone did this and because you can check in these minced right so you can take an hour spent in Britain get and it will be maps to just that application forever so no 1 would ever have to bundle exec ever again if every article on so now we bundle on don't show up we have versions that are dedicated to each individual application but as you probably since the pattern going through history that that wasn't actually there and there still problems that show up on after Balmer came out the biggest problem that was left with a running battle installed just took a really long time and if you live really far away from the US it took a really long time so I talked to some developers in South Africa and I wanted to give a talk and they told me about how running bundle install means that they literally get up to start making themselves a cup of coffee that they can finish before but most often actions i so to train speed things up on the 1 . 1 created a completely new way to get information from regions about gems and that spending things that by like around 50 % which was a pretty big win of we keep working on this but the 1 . 9 just came out this month and there's a bunch more improvements that were still working on but they will keep getting better and if you're interested in following along with that the on the website has news announcement mom and I O and on Twitter were also but I so having said all this up if you use when I would totally love to have your help working on my and it's an open source project were super we have dedicated a lot of time to making it easy for people who don't know how to do open source to help with bomber and start working on moment it it get into open source that way and it's a project and get home at bomber bomber it's on twitter if you are interested but don't really know where to start you can totally e-mail them on a team a team that won the I O and all that you set up on the other hand if you have a job that means you have money but not time joinery together and give us money and will work on my and it'll be better as we read together grows were also me tackling bigger community issues we want had an easy-to-use gem there's so that you don't have to go all the way to regions . org for officer for a data center we won and better public benchmarks is a project called the ruby benched that's starting to do that and we like to expand it there's a bunch of other things everybody is working on the we will call but if you want but were read together stickers I have a giant pile so far in the late and who bands in in the in the in the in and you come
Betrag <Mathematik>
Skript <Programm>
Schreiben <Datenverarbeitung>
Kategorie <Mathematik>
Mobiles Internet
Güte der Anpassung
Rechter Winkel
Lesen <Datenverarbeitung>
Ordnung <Mathematik>
Überlagerung <Mathematik>
Virtuelle Maschine
Weg <Topologie>
Reelle Zahl
Installation <Informatik>
Ganze Funktion
Open Source
Elektronische Publikation
Binder <Informatik>
EINKAUF <Programm>
Offene Menge
NP-vollständiges Problem
Wort <Informatik>
Wiederherstellung <Informatik>
Prozess <Physik>
Gemeinsamer Speicher
Familie <Mathematik>
Kartesische Koordinaten
Computerunterstütztes Verfahren
Prozess <Informatik>
Wurzel <Mathematik>
Figurierte Zahl
Funktion <Mathematik>
Lineares Funktional
Installation <Informatik>
Klassische Physik
Konfiguration <Informatik>
Arithmetisches Mittel
Twitter <Softwareplattform>
Projektive Ebene
Arithmetisches Mittel
Web Site
Virtuelle Maschine
Kombinatorische Gruppentheorie
Physikalische Theorie
Speicher <Informatik>
Bildgebendes Verfahren
NP-hartes Problem
Elektronische Publikation
Einfache Genauigkeit
Mapping <Computergraphik>


Formale Metadaten

Titel How Does Bundler Work, Anyway?
Serientitel RailsConf 2015
Teil 06
Anzahl der Teile 94
Autor Arko, André
Lizenz CC-Namensnennung - Weitergabe unter gleichen Bedingungen 3.0 Unported:
Sie dürfen das Werk bzw. den Inhalt zu jedem legalen und nicht-kommerziellen Zweck nutzen, verändern und in unveränderter oder veränderter Form vervielfältigen, verbreiten und öffentlich zugänglich machen, sofern Sie den Namen des Autors/Rechteinhabers in der von ihm festgelegten Weise nennen und das Werk bzw. diesen Inhalt auch in veränderter Form nur unter den Bedingungen dieser Lizenz weitergeben.
DOI 10.5446/30668
Herausgeber Confreaks, LLC
Erscheinungsjahr 2015
Sprache Englisch

Inhaltliche Metadaten

Fachgebiet Informatik
Abstract We all run bundle install so we can use some gem or other, sometimes several times a day. But what does it do, exactly? How does Bundler allow your code to use those gems? Why do we have to use bundle exec? What's the point of checking in the Gemfile.lock? Why can't we just gem install the gems we need? Join us for a walk through the reasons that Bundler exists, and a guide to what actually happens when you use it. Finally, we'll cover some Bundler "pro tips" that can improve your workflow when developing on multiple applications at once.

Ähnliche Filme