Ruby

Summarized using AI

Managing Ruby Projects with RVM

Wayne E. Seguin • February 11, 2015 • Earth

This video features a presentation by Wayne E. Seguin at the MountainWest RubyConf 2010, focusing on managing Ruby projects using RVM (Ruby Version Manager). Seguin introduces RVM as a command-line tool designed to facilitate the installation and management of multiple Ruby interpreters, their patch levels, and associated gem sets on a system level. The presentation emphasizes the importance of RVM as it supports project independence and environment consistency across various development stages.

Key points discussed in the video include:

  • Introduction to RVM: RVM allows users to manage Ruby versions and installed gems, addressing the challenges of using multiple Ruby environments for different projects.
  • User Experience with RVM: Seguin shares anecdotes about initial challenges with RVM, its development journey, and how it evolved from basic bash code to a powerful tool.
  • Installation and Features: Users can install multiple Ruby versions with commands like rvm install, switch between them easily, and manage project-specific gem sets, making it convenient for developers working on different applications simultaneously.
  • Testing and Maintenance: RVM supports testing across different Ruby versions, offering options to run tests and monitor changes in real time, enhancing development workflow and ensuring compatibility.
  • Collaboration and Environment Configuration: The use of .rvmrc files allows developers to share their Ruby configurations, which helps maintain consistency across team members' environments, making onboarding easier.
  • Community Engagement: Seguin acknowledges contributions from other developers and encourages community input to further improve RVM.

In conclusion, RVM is portrayed as an essential tool for Ruby developers that streamlines project management, encourages collaborative development, and simplifies workflows through its powerful features and user-friendly commands. Seguin advocates for using RVM and invites developers to engage with the RVM community for support and improvements.

Managing Ruby Projects with RVM
Wayne E. Seguin • February 11, 2015 • Earth

Help us caption & translate this video!

http://amara.org/v/GGpN/

MountainWest RubyConf 2010

00:00:15.400 All right, there we go! Welcome to a little talk about managing our Ruby projects with RVM. I'm going to try to go very quickly as there's a lot of information in RVM at this point, and I just can't cover it all in half an hour. We'll see what I can get through.
00:00:20.359 So, how many people have not heard of RVM? Raise your hands, please. All right, good. Um, how many people are using RVM? All right, that's not bad. How many have tried it and it didn't work, and are now just not using it? Find me later.
00:00:37.760 So, what is RVM? Well, RVM stands for Ruby Version Manager. It's essentially a command-line tool that allows you to type 'rvm' at the command line with various options to manage Ruby interpreters in a way that's not quite natural. It allows you to install multiple versions of Ruby interpreters, manage patch levels, revisions, and also manage sets of gems for each of these installations.
00:00:54.640 RVM does this on a system level, not within your application. For that, I recommend something like Bundler for managing your gems. Bundler is great for virtual environments and for performing operations over installed interpreters and gem sets. If I have five different Ruby versions installed and I want to perform certain actions against all of them, RVM will allow me to do that.
00:01:10.360 There are, as I mentioned, a whole bunch of other items that you can do with RVM. You can check everything you need on the RVM website, which I will leave at the last slide. The website is rvmb-rescue.com. The documentation at the bottom of the screen is kind of constrained, but it's currently about 50% complete with the functionalities that RVM provides.
00:01:20.800 Now, who am I? Well, real quick, I have about 10 years of development experience. I previously worked for Engine Yard and now I work for a company called Academic Management Systems, where I develop admission software and other applications. I am a partner and member of a company called Division by Zero, along with two other brilliant folks, Mark Joseph and Bill Chapman.
00:01:35.360 I have four children, all under the age of five, which makes things very interesting—sleep? No. I used to hack on MongoDB and a bunch of open-source projects, and I love to help out when I can if I have a clue about what someone is doing. Currently, I hack on RVM, BDSM, DBM, and UPM in that order of activity.
00:01:48.320 RVM, as you may have guessed, is the most active project and kind of takes most of my time. RVM originally started in October 2007 after I started conversations with a coworker, Jim Lindley, who is the best UI guy I have ever met. We had a problem where we had four applications, and each one had to run on a different interpreter.
00:02:06.560 We were using Ruby Enterprise Edition for one of our apps, and another app had to be on JRuby. In addition, we had a brand-new app where we decided to go with Ruby 1.9 due to its phenomenal performance characteristics. It was a hard problem: on August 21, 2009, I spoke with Jim and we had three simple requirements.
00:02:31.080 We wanted to easily install the Ruby interpreters we were going to be using for these projects, and we needed a way to quickly switch between those interpreters while ensuring that our environments—be it development, staging, testing, CI, demo, or production—were identical. I had tried RVM in 2007 but failed miserably and thought it was a great idea that I just didn’t have the right grasp on then.
00:02:54.960 Fortunately, Jim encouraged me to try again, and that's how we have RVM as it stands today. A day later, after a night of thought and a day of furious hacking and changing diapers, I did my first check-in, which was about 300 lines of bash code. Now, it has grown to over 4,000 lines and an incredible amount of functionality.
00:03:07.720 The first check-in satisfied our three initial requirements fairly well. For those wondering why I used bash for this, it's because bash is installed on every Unix system I've ever encountered. It allows me to bootstrap Ruby without requiring a system Ruby on our production servers. I deploy our entire system using RVM, making everything self-contained according to each user.
00:03:21.680 This means each project operates independently within its user directory. With RVM, I can bootstrap everything from scratch with no Ruby required. With bash, we can directly manipulate our working environment, allowing users to type commands like 'rvm use macruby' and seamlessly work with it. This provides a consistent API across every interpreter.
00:03:39.440 Now, why would you want to use this tool? Once installed properly, RVM provides methods to run a single command against multiple Ruby environments at the same time. For instance, if you want to install Ruby 1.8.6, 1.9.1, and JRuby in one go, you can do 'rvm install 1.8.6 1.9.1 jruby' and RVM will install those versions in your RVM directory.
00:03:56.920 RVM is self-contained, so if you install it as a user rather than root, it's located in the RVM directory in your home folder. This means if you want to start fresh or clean, it's relatively safe to blow it away and start over. You can also select which Ruby version to use for your current shell. If you run 'rvm use 1.9.1', it will switch to that version in your current shell.
00:04:14.800 Additionally, you can make use of RVM's gem sets. RVM's gem set feature allows you to create and manage sets of gems at the system level for specific projects. Let's say you're experimenting with Rails 3, but you don't want that to affect your current work—you can completely isolate it using RVM.
00:04:34.839 You can run different Ruby versions and Rails environments simultaneously without any conflicts. In essence, you can open multiple terminal windows or shells and use different Ruby versions and gem sets to run Rails on each of them at the same time.
00:04:57.200 Another powerful feature of RVM is its testing capabilities. Suppose you are using a testing framework like RSpec and want to ensure that your application is compatible with the different rubies you have installed. RVM can run your test suite against each ruby version you've set up to make sure everything works as expected.
00:05:15.200 For example, you could run 'rvm run tests' for specific versions and get outputs tailored to your needs: JSON summaries, human-readable output, or error logs for debugging your tests in an organized manner.
00:05:34.720 RVM also has an interesting feature called 'monitor' which watches your test directory. Whenever you change a test file, RVM will automatically rerun your test suite to ensure that everything is still functioning correctly across the different ruby versions.
00:05:50.240 I did it once, and it worked well for me, so if anyone starts using that feature, please let me know how it works for you. Another useful feature is RVM Benchmark, which allows you to test a chunk of code across various ruby implementations to measure their performance. You can output the results in a clear, comparable format.
00:06:05.919 Updating RVM is also quite easy and there are many ways to install it. I definitely recommend keeping RVM updated because it's a fast-moving project that frequently gets new features and fixes. To get RVM, I recommend reading the installation instructions on the website to ensure you do it properly.
00:06:21.200 Now, let's talk about managing Ruby projects with RVM. After creating your project directory, you will need to select the appropriate Ruby version you're going to use, for instance, 'rvm use ruby-head'. This will set it as the Ruby version for the current shell.
00:06:35.720 Next, you can create a gem set for this project using 'rvm gemset create project_a' and then switch to that gem set with 'rvm gemset use project_a'. Now you have Ruby head selected with the specified gem set ready to be filled with all your dependencies.
00:06:55.440 Once your setup is complete, you can start installing gems using commands like 'gem install'. You will have separate gem directories, which helps you manage your project dependencies more cleanly, ensuring that different project environments don’t interfere with each other.
00:07:12.480 RVM provides mechanisms to help you manage this setup efficiently. For example, you can run 'rvm --default' to set default Ruby and gem set combinations for easy reuse whenever you switch into that project directory.
00:07:29.360 In doing so, all of your configurations can be condensed into a single command once you are in the project directory. When you set up your environment, RVM will create a .rvmrc file that keeps track of the Ruby version and gem set you selected, thereby ensuring that each time you enter that directory, your environment is replicated automatically.
00:07:49.600 This functionality is very useful, especially in collaborative environments where multiple developers may be working on the same project. RVM’s .rvmrc file effectively allows you to share your Ruby and gem configurations with others, ensuring consistency across different development setups.
00:08:07.680 You can export your gem requirements using 'rvm gems export project_a.gems', allowing other team members to easily set up their environments by importing the gem lists you’ve generated.
00:08:24.160 As you can see, RVM supports managing complex Ruby projects with ease and efficiency. By creating separate gem sets, defining Ruby versions, and making it easy to share configurations, RVM becomes an essential tool in any Ruby developer’s toolkit.
00:08:43.919 I’d like to thank a few people before I end this presentation. A huge thank you to Jim Lindley, Bill Chapman, Mark Joseph, and Tyler Bird for their encouragement and input. I’d also like to thank Tim Brandis for redesigning the new site layout, and Curtis Migel for reviewing it and providing excellent feedback.
00:09:01.520 Lastly, thanks to the Ruby community at large, you are what makes RVM possible. If you have any questions, please save them for the breaks. I will be around at the hackfest on Freenode at the RVM channel. You can find this presentation on rvmb-rescue.com.
00:09:20.480 All the documentation for RVM can be found at rvmb-rescue.com, and I highly recommend using Pivotal Tracker for development tracking. You can find links to the development tracker from this presentation. If you need to reach out to me, feel free to do so through that platform.
00:09:33.520 I encourage you all to try out RVM. If you face any questions, hop on the channel, ask away, and keep this positive energy flowing. RVM is a user-driven development tool. Your thoughts and ideas are needed to make RVM even better.
00:09:50.480 Thank you, and that’s all I have for today.
Explore all talks recorded at MountainWest RubyConf 2010
+22