Hafter I Say Vagrant Halt How Should I Have the Vagrant Running Again
The Ultimate Guide to Getting Started with Vagrant and Why Every Software Programmer Should've Been Using it Similar Yesterday.
Why do all the blog posts ever make vagrant into rocket science?
I mean… It Can be similar rocket scientific discipline but getting started with it is and then like shooting fish in a barrel my great grandma can do it — and she's not fifty-fifty alive. That should requite you lot a crude sense of how easy it is.
Before we begin, I'm gonna need you to put your onesies on because this stuff can get a little heavy. We are gonna exist talking nearly concepts like Virtual Environments, Bundle Managers, VMware, and Evolution Environments.
Whether you simply learned how to turn on your computer, or y'all are a rocket scientist… Learning the basics about this stuff will not only salvage you years of frustration, pain, and misery. But, it will likewise permit you to apace build mouthwatering real world projects that soup up your portfolio and dazzle your potential employers.
Plus, you get to put all of this on your resume. Well-nigh professional development teams at companies are dying to rent people who can streamline their development process using things like VMware and all the other cool stuff I'll be showing you in this post.
I'll be keeping the examples specific to python but this is but equally useful and applicative to a developer working in ANY language (Coffee, Ruby, PHP, Javascript, etc).
Information technology took me YEARS to learn well-nigh this stuff because most online blog posts were fabricated past P.H.D's or by developers who write for other developers!
And at present that I know this stuff, I could NEVER go dorsum to that onetime lifestyle. If I COULD go back… I would slap my quondam self in the face up and force him to larn this stuff.
Endless of my dreams have died simply because certain libraries I needed wouldn't get installed, or JUST WOULDN'T WORK! I followed every step in the docs, read stackoverflow, scoured reddit, and fifty-fifty read through every single closed issue in the library'due south github repo to see if my trouble was already solved by someone else… But NOPE.
Finally, subsequently going through all that tedious work, I would surrender and merely effort to do a more boring project considering it required things I already had in my computer.
Earlier we start, permit'south first talk about your life now without Vagrant.
Your Problematic Life Without Vagrant
Most of the times following an online tutorial or working on any project you want works just fine. You lot pip install your way through hell and virtualenv similar a boss to go stuff done.
I know near of you lot reading this from the Clever Programmer community accept Zero thought about this simply, this is a game changer, so listen up.
For my beginner python friends or people from outside the python world — GASP — pip is a parcel director in python which allows y'all to install modules and libraries super easily (basically it makes it dangerously easy to ethically steal code and go infinite ability)!
pip install django Now you're gear up to create django apps.
pip install flask You're ready to create flask apps. Yeah, it's that easy.
Unless, of course, you endeavor pip install scipy or pip install scikit-learn or pip install pygame or pip install numpy
You get the thought.
Now, if yous're incredibly lucky or you have deliberately worked to create the perfect setup, 99% of you WON'T be able to become all of those libraries installed without a problem… If at all.
If you are on Windows you might have even gotten the beautiful bash: pip: command not plant error. God, I just hate Windows. Windows sucks for developers.
My communication is unremarkably to purchase a mac Os or go a Virtual Machine installed as fast as possible. BUT, you're in luck. Vagrant simply saved you $1500, once you learn how to use it of form.
Virtualenv allows you lot to create these little virtual environments where Django project doesn't have to know about your Flask project. Just like your bathroom doesn't know almost your kitchen. How does that saying go once again, "Don't sit down where you lot eat"…? Yeah, I think information technology's something similar that. Anyways, moving on!
Now, let'south talk about…
What your life will exist like later on Vagrant
- Utilise your favorite OS — Since you ssh into this (y'all'll know what SSH means if you don't know already), you get to be on your favorite operating organization. I personally HATED having Ubuntu VMware on my MacOS because Mac's Os is mode more than mature than the freebie and bad Ubuntu. Plus VMwares are not native and so they slow your computer down AND they are clunky.
- You lot'll be able to follow every tutorial & learn any new technology without any trouble — No environment problem just because you have Windows, or that your ruby virtual environment is cleaved, or that your paths are all screwed upwards. I remember mode back when I couldn't get iPython to piece of work, or I couldn't install
npmcause of some random stuff existence broken in my calculator. - Everyone in the globe will be able to use your code — No more "umm… well it works on my car" crap. This is awesome for professional developers working on a team, beginner coders who want to share their code, or teachers trying to get all their students on the same page without pulling their hair out(the last i is the story of my life.)
- Your hire-ability volition skyrocket plus you'll beef up that resume — Employers dearest people who can apply virtual environments, package managers, virtual machines, and tools like Vagrant! Anything cloud based gets those shot callers drooling.
- You'll save years of your time and 10x your progress in your software development journey– You won't feel like crying. You won't give up. Plus you'll get stuff done. FAST. Flow.
- Stick with your favorite editor — Because of something called Synced Folders in Vagrant… You go to even utilise your favorite editors like Sublime Text, Atom, or Pycharm AND your favorite Os! This wouldn't be possible if you used a VMware.
If yous're not sold yet… You're just a wannabe programmer and you should only quit.
Notwithstanding here? Are you pumped?
LET'S GO!
I'thousand gonna show yous the EASIEST way for you to add vagrant into your life and information technology'll take like 5 min (unless your net sucks).
Let's Get You All Vagrant-ed UP!
Step 1: Download and Install Vagrant
Footstep 2: Download and Install VirtualBox
All washed? Great!
You lot now accept more power than yous know. I envy you learning this and then early in your coding life! Let'due south power through that gorgeous command line stuff at present.
Step iii: Open that command line (and follow along ❤)
On windows, open upwardly cmd or powershell. If you tin can't figure out how to open up up those… Smh.
On Mac, open up upwards your terminal (cmd + infinite, that opens up your spotlight and then type in terminal ).
Okay now type in the post-obit.
mkdir folder_of_awesomeness
cd folder_of_awesomeness
vagrant init bento/ubuntu-xvi.04
vagrant upwardly
vagrant ssh I'll talk about the synced folders later in the post. For at present, I've only shown you how to access your shiny new Ubuntu Vagrant Box.
Note: If you lot got the mistake Timed out while waiting for the car to boot … Don't PANIC! You probably merely demand to upgrade your Virtual Box.
Notation: Windows Users use PUTTY to SSH:
protocol: SSH
Hostname: 127.0.0.i
Port 2222 (Don't you just love windows? Information technology ever has these ugly workarounds. Deplorable for these tangents but I volition brow beat yous till you lot get a Mac like a real developer.)
Here'due south roughly what you should be seeing right now:
Manifestly your folder wouldn't be called vagrant_medium_blog only folder_of_awesomeness instead.
And BOOOOOM!!!! You've merely ventured into a completely dissimilar virtual globe. I know for some people this might be confusing like… What's so special nigh this?
The Infinite Power Behind the Ugly Command Line
What that screen means is that y'all are in a completely different computer. Then, if you were on a Windows… You're not anymore! Woohoo! Just saved you lot $1,500. Y'all tin thank me subsequently.
Unfortunately, there is no way to control this calculator with your mouse to be able to drag and drop things using a beautiful user interface. All you have is the ninja control line. Just, you're literally controlling different computers in the world and can hack the ULTIMATE setups with similar three lines of code. THIS is why the command line is so powerful. (Command line, Terminal, Powershell, CMD, I utilize them interchangeably)
Using Vagrant, you could use people's pre-built boxes and go their entire systems wth few lines of lawmaking.
Now, here's all you accept to do to get your python three up & running.
sudo apt-go install python3 python3-pip
(I love Ubuntu's package manager apt-become. You install everything using this in Ubuntu).
Now do python3 and your python should exist running. Now, y'all're probably like…
THAT's not that impressive. Python3 was already running for me!
BUT, what is cool is that y'all could go and steal another virtual box using vagrant and finally follow that advanced paradigm recognition tutorial you lot couldn't follow before because y'all couldn't get all the tools installed on your reckoner.
You could go numpy library working, or that nodejs working, AND you could share your environment (box) with anyone else in the world and they could just run your python lawmaking without having to practise Any extra work or installing ANY extra things.
If you lot were having bug getting any tools working in your windows or even in your mac, you could just go here now and [ethically] steal boxes that are made to get all the things you desire working.
Now if you desire something more complicated like a postgres database, that's super like shooting fish in a barrel as well. Just do sudo apt-get install postgresql .
Allow's Break It Downwards
I'll offset off past running yous through some command line nuts as a refresher and so walking you through the vagrant lines.
-
mkdir=> creates a directory -
cd=> change directory -
vagrant init bento/ubuntu-sixteen.04=> Information technology creates a Vagrantfile in your directory. If yous type inlsy'all'll see information technology. If you practicetrue cat Vagrantfileyou'll the contents of the unabridged file. What I want yous to focus on is this; Scroll up a scrap and observe a line that readsconfig.vm.box = "bento/ubuntu-16.04". This means that when you lot run this file, information technology'll download and install the Ubuntu-16.04 image from the web automatically! -
vagrant upward=> runs the Vagrantfile + it downloads & installs the bento/ubuntu-16.04.
-
vagrant ssh=> Y'all SSH into your vagrant box.
SSH sounds deadening and lame. It should be called hack or takeover… Cause that'south what happens when y'all ssh into something. You TAKE OVER that figurer and control information technology using the ugly command line (my command line is gorgeous. Thanks ZSH ❤). I hate thinking about my college C.S. teachers at present who showtime off by maxim "And so… SSH stands for Secure Vanquish". YAWN, YAWN, followed by a delight shoot me in the head. Here's the new definition. SSH means you take over shit. alias takeover=ssh if you'd like haha.
Synced Folders — The Sexiest Secret About Vagrant
The best reason for synced folders…
- Employ Your Favorite Editor and Your Favorite Os — You get to stick with everything yous love and know (Pycharm + Mac ❤ or Windows + Sublime)… Your lawmaking but happens to live in a perfectly fake little world, a development surroundings, a box that you tin can share with anyone. Tomato, Tohmaato.
Let's get to it.
Just to recap hither are the commands yous should take typed in already:
mkdir folder_of_awesomeness
cd folder_of_awesomeness
vagrant init bento/ubuntu-16.04
vagrant up
vagrant ssh How Synced Folders in Vagrant Work
You put stuff in the /vagrant binder of your vagrant box (development environment) but it shows upward on your local figurer where your Vagrantfile is. One time it shows up on your local computer, you can just edit your file using your favorite editor. Then edit the lawmaking using your favorite editor on your favorite Os, and just run the code from your virtual box since you're already SSH'ed into it from the command line.
Okay now onto the commands!
touch on /vagrant/new_python.py
exit
ls Hither's what those commands say:
- Nosotros'll add together a new file in the
/vagrantfolder of your vagrant box callednew_python.py(doesn't matter what yous phone call information technology).affectis a command used to apace create a file (obviously the control doesn't piece of work on windows and the workaround is painful. Nonetheless, since yous are in a vagrant box… Nail! Information technology worked!!! $1500 saved.) -
exitout of your SSH and then we can enter back into your local computer -
lsto see if the file showed upwardly on your LOCAL COMPUTER! The command isdirif you are on a windows control line (i letter of the alphabet longer than the command on a linux).
And WOW! Look at that! The file is correct there on your local computer. Y'all can utilize your GUI (ways your mouse & usual stuff) to right click on it and open up it in your favorite editor or but open up that file from a command line. In one case you blazon upwardly code in that file. Save it. So just SSH into your box to run your lawmaking.
Protip: Stay SSH'ed into your device the unabridged squad, edit the code in your favorite editor, and and then but run the code from your command line.
Wrap Up
Information technology just blows my mind that you lot could do something similar decision-making a computer in a completely different role of the world and and so come right back to your ain world with just one command. Never ceases to astonish me.
If you want to dive deeper into Vagrant and learn more about it. Here's their getting started guide.
For those a trivial bit more than avant-garde users who similar Pycharm, hither's a post that shows you how to connect your Pycharm with Vagrant. Then you can open up your control line right within of your Pycharm and information technology would be ssh'ed into your box the entire time while you lot edit the files locally with Pycharm.
Hopefully you're at present at a indicate where you lot know nearly some of the benefits of Vagrant's power and flexibility, how it'due south a improve selection than getting a VMware similar Bootstrap or Parallels, how it can make your life 10x better making y'all more productive equally a software programmer, and how its cognition can help you stand up out from the crowd when you lot put information technology on your portfolio.
That'due south it for today. PEACE.
Brand sure to striking the HEART sign button beneath and share this.
Got questions? Loved it? Don't agree? Talk to me in the comments below.
Source: https://medium.com/cleverprogrammer/the-ultimate-guide-to-getting-started-with-vagrant-and-why-you-shouldve-been-using-it-like-a8116e18fdca
0 Response to "Hafter I Say Vagrant Halt How Should I Have the Vagrant Running Again"
Post a Comment