• 5 Feb, 2024

    How I Use ChatGPT To Get Unstuck

    A robot conducting an orchestra.
    Photo attribution here.

    Ideally, when we have questions about a piece of code, we'd always have a man or help entry (or some other official, canonical resource) to guide us. Failing that, we could plug our question into Google and get an answer from StackOverflow or (worst-case scenario) someone's blog.

    But some questions aren't conducive to that. Some questions are specific to our unique situation, and it's unlikely we'll find a resource already written which addresses our issue.

    In these cases, we can unblock ourselves by asking ChatGPT our preliminary question, and using its response to refine, rephrase, or completely change our question into something which will help us figure out our next steps.

  • 4 Feb, 2024

    Why I Read Code, Then Write About It

    Image of a cookbook.
    Death found an author writing his life.. Designed & done on stone by E. Hull. Printed by C. Hullmandel. London, Dec. 1827. Photo attribution here.

    The times when my impostor syndrome is most diminished are the times when I know my set of tools inside and out.

    By "tools", I mean languages, frameworks, databases, and any other component of the tech stack in front of me. If I can predict how they'll behave in a given situation, teach how they work to others, and use them in new and novel ways, then my inner critic usually keeps quiet. So it stands to reason that the more of my team's tools I understand, the more confident a developer I'll be.

  • 25 Jan, 2024

    How Do File Permissions Work?

    A protest sign that says 'Civil disobedience requires no permission slip'.
    Photo attribution here.

    Throughout my write-up on how RBENV works, I perform multiple experiments where I create an executable file which replicates specific behavior in the codebase. But in order to actually run the program I've written, I first have to modify the program's file to be executable, since it's not executable by default.

    I did this by using the chmod terminal command, for example chmod +x (filename). This was a necessary step every time I created a new file that I planned to execute.

    After doing this enough times, I started to ask myself why it's even necessary to do this. After all, I'm the person who created this file. Shouldn't I be able to execute my own file on my own laptop? I couldn't find an answer to this question from Google, so I did some research to find out.

  • 23 Jan, 2024

    The "$PATH" Variable

    The PATH train between New York City and New Jersey.
    The PATH train between NYC and New Jersey. Photo attribution here.

    One of the most important environment variables that we use in shell scripting is the "PATH" variable. Whenever we type a command into the terminal, the shell will use the list of directories contained in $PATH to locate the file associated with that command. So it's worth spending some time understanding how $PATH works.

  • 21 Jan, 2024

    How I Use Github To Beat Impostor's Syndrome

    Random fence in a field, which apparently serves little to no purpose.
    Surely Chesterton would be fine with tearing down this fence? Photo attribution here.

    I recently wrote a line-by-line walk-through of the RBENV shim for the bundle command (actually, the RBENV shim for every gem, since they're all the same code). The goal was to be able to explain what the syntax of each line of code does.

    But there's an order-of-magnitude difference between knowing what a piece of code does, vs. knowing how and why it got to that point. Reading the repo's git history is one way to reach that 2nd level of understanding.

  • 19 Jan, 2024

    How To Use The `man` Command

    Image of a cookbook.
    Photo attribution here.

    In our examination of the RBENV shim, we encountered the set command. At that point, we hadn't yet encountered that command, and so we had to look it up in the docs.

    In many cases, we can find the manual for various terminal commands using the man command (short for "manual"). If we fail to find what we're looking for using man, we can try checking StackOverflow or another source. But the quality of those sources can vary widely, so a useful habit is to stick to official docs when we can.

    Also note that set is a builtin command and therefore we have to access its docs via the help command. Typically, we'd start our docs search with the man command and switch to help if we discover that the command in question is a builtin. A bit later in this post, we'll look at how to tell whether a command is a builtin command or not.

    man entries can be hard-to-parse if you've never encountered one before. Let's learn how to read them.

  • 16 Jan, 2024

    Configuring The `help` Command In Zsh

    Cover of the Beatles' 'Help' album.
    Photo attribution here.

    The purpose of this post is to set up the help command for folks who are using the Zsh shell (like I am). If you're using Bash or another shell, feel free to skip this one.

    Up until 2019, the default shell for Mac was Bash. When Apple released macOS Catalina, Apple started shipping Zsh as the default shell instead. This was possibly done because Bash changed its software license from GPL2 to GPL3. The difference between the two is that GPL3 requires that "code built with GPL3-licensed packages must open-source that code". This is likely not something that was compatible with Apple's business model.

    As a result, we as Mac-using shell students now have to spend a few mental cycles on the subtle but sometimes important differences between Bash and Zsh. One of those differences is with the help command, which is usable out-of-the-box in Bash but which has a few hurdles in Zsh.

  • 16 Jan, 2024

    What Are Dotfiles?

    Adding dots of sauce to a plate of food.
    Adding dots of sauce to a plate. Photo attribution here.

    In my deep-dive write-up of how RBENV works, my first step was to find out where (i.e. in which file) the command's logic lived. It turned out that it lived in a shim file, which in turn lived inside the ~/.rbenv directory. But I didn't explain what the ~/.rbenv directory is, and more specifically, why it starts with a . character.

    This post will try to answer that question, i.e. why do some files and directories start with a dot?

  • 14 Jan, 2024

    Comparing RBENV with similar tools

    A place setting at a dining table, with many similar-looking utensils.
    Start at the outside and work your way in. Photo attribution here.

    A little while ago, I wrote a thing called "The Impostor's Guide To The Shell", where I describe how I taught myself the basics of shell scripting by reading the codebase of a program called RBENV.

    RBENV is a version manager for the Ruby programming language. It's a popular choice for managing Ruby versions, but it's not the only choice. Others include rvm, chruby, asdf, or other programs.

  • 12 Jan, 2024

    What Is A Shim?

    Book cover- 'The Art of the Shim: Low-Alcohol Cocktails To Keep You Level'
    Apparently, a shim is also a low-alcohol cocktail, especially one served at breakfast. Photo attribution here.

    RBENV ensures that we're using the version of Ruby that our current environment depends on. It does this by:

    • intercepting your call to the ruby command,
    • deciding which Ruby version to use based on the information available to it, and then
    • passing the command you entered to the correct Ruby interpreter based on that version.

    This behavior (intercepting a message, handling it in some way, and then passing it on to its intended receiver) is a common pattern in software. A file, program, or library which does this is sometimes known as a "shim".

  • 11 Jan, 2024

    What is a version manager?

    Artistic rendition of Taylor Swift's '1989 (Taylor's Version)' album cover.

    When I describe RBENV as a "version manager", I mean it helps developers switch between Ruby versions without too much hassle.

    If we have multiple versions of Ruby installed, that means there are multiple programs on our machine which respond to the ruby command in our terminal. Without a Ruby version manager to help us switch between versions, our OS will just pick the first of these programs that it finds, which may or may not be the version our program depends on.

  • 8 Jan, 2024

    What Are Processes?

    Picture of a food processor making pesto, because it has the word 'process' in it and because I'm hungry right now.
    Picture of a food processor making pesto, because it has the word 'process' in it, and because I'm hungry right now. Photo attribution here.

    In my post about RBENV's use of the exec command, I briefly touched on the concept of processes. I didn't go deep into what those are, because there's a lot to talk about on that topic and I wanted to keep the focus on RBENV and its shim file.

    In this blog post, I circle back and address the questions that I still had after writing the earlier post. These include questions like:

    • What is a process, in plain English?
    • What's the difference between a process and a program?
    • How are processes created and destroyed?
    • When should we use exec vs. forking?

  • 5 Jan, 2024

    Installing Libraries (Like RBENV) From Source

    Running 'git clone' in order to install the RBENV codebase from source.

    In my walk-through of the RBENV codebase, we do a lot of experiments which involve modifying the code and then running it. The goal is sometimes to break the code intentionally for educational purposes, and other times just to log what's happening as it happens.

    If you'd like to follow along with those, the first step is to install RBENV on your machine.