Skip to content

Instantly share code, notes, and snippets.

@JoshCheek
Last active September 13, 2015 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoshCheek/2a6e5741d3ab56ba0886 to your computer and use it in GitHub Desktop.
Save JoshCheek/2a6e5741d3ab56ba0886 to your computer and use it in GitHub Desktop.
Debugging Shannon's Atom / Seeing Is Believing issue

Debugging Shannon's Atom not running Seeing Is Believing correctly

Summary

  • Atom's config file had the SiB configuration in the wrong spot, we put it in the right spot
  • We made a wrapper program, sib_ruby through rvm to run on rvm's Ruby 2.2.2
  • We changed the Atom's config to run through rvm's sib_ruby instead of the one in your dotfiles that ultimately uses chruby.
  • We installed SiB 3.0.0.beta.6 in rvm's sib_ruby

The actual issue

The thing was blowing up saying it couldn't find SiB. The way it finds SiB is via the ruby-command in the seeing-is-believing setting, under the * settings in the file ~/.atom/config.cson The actual problem was that the seeing-is-believing setting was in the wrong place, so it was the same as if it had no settings and was just using the default. The key it is under is based on indentation (the first key above it that has less indentation than it)

It's probably been wrong for a while, but if you launch Atom from your shell (typing atom in shell), then you inherit the environment of the shell, which is set up correctly because Fish sets it up correctly. The default, if you haven't set it up, is to just use whatever ruby would be run by default, and since the environment is set up correctly, it finds the chruby one. But if you launch it through spotlight or something, then you don't get your shell's environment, so it is not set up correctly, and thus finds the default ruby that comes on mac, that knows nothing about SiB. This behaviour of working / not working based on how you launch Atom is super confusing (will seem completely nondeterministic), which is why it allows you to configure it to tell it how to locate Ruby. So the real solution was to fix the configuration, so that it finds the one we told it to use, not whichever Ruby happens to win based on how Atom was launched.

We also had to move fontSize and showIndentGuide, because they became settings of seeing-is-believing after we outdented it, but they should have been settings of editor.

The possibly irrelevant other shit we did

Initially we looked at what command we'd told it to use, because the error was saying it couldn't find SiB, and we wanted to go make sure we could get that working without Atom (when things are difficult, remove complexity, reduce the number of things that can fuck it up, so we remove Atom from the equation here). Looking at ~/.atom/config.cson, we saw the ruby-command was set to the sib_ruby in your dotfiles that you cloned from me (we didn't realize this key wasn't being used due to being in the wrong location). So we looked in that file, and saw that it was just turning around and handing it off to chruby, saying to run under ruby version 2.2.2

So we first verified that was a valid version of Ruby, as far as chruby was concerned, by running chruby to see which versions it knew about. It said that 2.2.2 was installed, so we ran the command /usr/local/bin/chruby-exec 2.2.2 -- ruby -v to make sure it was successfully locating the expected Ruby. It was, so the sib_ruby wrapper program was somehow fucking it up, we ran /Users/shannonpaige/code/dotfiles/bin/sib_ruby -v to see what it said, and it blew up in some wonky ass way.

I've debugged enough of these issues to know that it's because the core of chruby runs in a bash environment, and it probably means the bash environment is not set up correctly. So we checked which files affect the bash environment with ls -al ~ | grep bash (list all files in long format, and filter the output to just lines that include the word "bash"), where we saw that the ~/.bashrc and ~/.bash_profile were our candidates. We looked at both of those files using the cat program, and saw that they didn't do anything with chruby, and instead had a bunch of rvm setup stuff. So we verified that rvm was installed with ls -al ~ | grep rvm and saw that it was. So I decided the easiest way to fix it with a low risk of fucking other shit up is to set up atom to use rvm's Ruby instead of chruby's ruby.

To work with rvm, we need to be in bash, so we launched a bash shell with bash -l (the -l means "login", which will run bash with settings for a human rather than for a computer... shells are actually programming languages, and when you're typing commands in the shell, you're actually programming, think of it like pry except with the intent of being a command-line interface to the operating system). Once in bash, we could see what versions of Ruby it knew about rvm list strings, and it knew about 2.2.2, so we knew we could tell Atom to use that Ruby. We want a program is just set up right and doesn't depend on all the crap in the ~/.bashrc and ~/.bash_profile, and rvm provides a way to make such a program, called a "wrapper" (because it wraps all the setup into an executable so that you don't have to think about it). We do have to give the wrapper a name, and since it's for Seeing Is Believing, we name it "sib" rvm wrapper 2.2.2 sib. This successfully creates the wrapper program, named sib_ruby, that will run under rvm's Ruby 2.2.2

Now we need to figure out where it put that program, so we use which -a sib_ruby the which program tells us where programs are located by looking through the places they can be (determined by a variable in the environment named $PATH, you can see which directories it knows about and looks in by running ruby -e 'puts ENV["PATH"].split(":")'), the -a tells it to list all the programs with that name, not just the first one (the first one is the one that will be run, here's another fun example which -a ruby will probably list 2 or 3 rubies you could run, the first one is the one you're actually running). This command told us about the sib_ruby in your dotfiles, and also about the new sib_ruby that rvm just created.

We took the path to the rvm one and edited the ~/.atom/config.cson, setting the ruby-command to that value so that Atom will use rvm's wrapper instead of the one in your dotfiles that uses chruby.

Then we needed to make sure the rvm one was able to run SiB. So we ran /Users/shannonpaige/.rvm/bin/sib_ruby -S gem list seeing which says to run our wrapper Ruby, and tell it that we want to execute the command gem list seeing, we do it this way so that the gem program is looking at our wrapper Ruby, not whatever Ruby we happen to be using at the moment. The seeing in gem list seeing tells gem to filter the gems its listing to just ones whose names match "seeing" (so we don't have to search through tons of gems). It didn't list SiB in its gems, so we install it with /Users/shannonpaige/.rvm/bin/sib_ruby -S gem install seeing_is_believing -v 3.0.0.beta.6 the version thing is because Rubygems won't install beta versions by default since they're seen as unstable, and I (probably stupidly) haven't released a non-beta SiB as version 3 yet (for reasons).

Once this was finished, we should have been able to run it in Atom successfully, but we couldn't, so we restarted Atom, because I've seen it get confused when its ~/atom/config.cson file is edited. That didn't fix it either, so we looked into it more and realized the config file was fucked up, and then did the actual solution as proposed above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment