[LRUG] Deleted the contents of ~/.zshrc and ~/.bashrc, system can't find rubygems.

Josh McMillan josh at joshmcmillan.co.uk
Fri Mar 10 01:40:26 PST 2017


Assuming you're using OS X – which based on the `/Library` in your GEM_PATH
you likely are, here's some attempts at answering those questions inline.
I'm by no means a shell scripting master and some of this could be utter
cobblers, so don't take my word for it – I'd appreciate correction /
refinement on any of this points.

Hope this helps in some way.

Josh

On Thu, Mar 9, 2017 at 5:26 PM, Jesse Waites <jesse.waites at gmail.com> wrote:

> Yesterday, because I'm an idiot, I deleted the content of my ~/.zshrc and
> ~/.bashrc files. Now, I can't start my rails server, console, anything - it
> says it cant find my gems. Can someone PLEASE answer a few questions. I
> have been struggling with this for over 12 hours and unable to do the work
> at my job since my system is down. I have tried putting the paths from 'gem
> environment' into bashrc
>
> "export GEM_PATH=/Library/Ruby/Gems/1.8/:${GEM_PATH}"
>
> but it doesn't work.
>
>
> 1) Why do I even have both ZSH and Bash? Did homebrew install one?
>

Bash is the default shell that's installed on your system. If you've got
zsh running you'll have installed it – either through Homebrew or some
other mechanism.


> 2) Why did my terminal (iTerm) seem to switch between zsh and bash
> depending on what program I'm running?
>

You can have multiple shells installed on a single machine, however the
shell that's run when you open a terminal is your "login shell". This is
nothing more than the program that your terminal runs when it's launched –
that could be bash, or it could be zsh, or it could be any executable.
You'll have set this at some point by using the chsh
<https://en.wikipedia.org/wiki/Chsh> command, which sets your login shell.
If you run `finger $USER` you should see a section marked "Shell" which
will tell you which login shell you're using – mine looks like "Shell:
/usr/local/bin/zsh", as I use zsh.

Your terminal won't switch between shells unless you explicitly tell it to,
but some programs might run shell scripts using bash as it's fairly
ubiquitous and has a standard syntax (zsh and bash scripts do not have
exactly the same syntax, and some people aren't running either as their
login shell). If, for example, you install a program by copying and pasting
a `curl` command into your terminal, it will likely run as a bash script
for compatibility purposes (usually via a shebang
<https://en.wikipedia.org/wiki/Shebang_(Unix)>) which will cause "bash" to
show up in the title bar of iTerm.

3) Should I delete bash or zsh and focus on fixing the path to my gems?
>

I'd stick to whatever you were using before – you shouldn't need to delete
either of them, but either your .bashrc or .zshrc was likely doing
something to set up your Ruby environment which it isn't doing any more.
Were you using a Ruby version manager like rbenv or RVM?

Run `which rbenv` and `which rvm` to find out if you were. You'll see a
path returned if the command after the "which" was installed.

If you have rbenv installed, run `rbenv init` and follow the instructions
given. I'm less familiar with RVM so can't give useful advice there. If you
have both installed, it's probably sensible to remove the one you weren't
using.


> 4) How do I FIND the path to my gems? I have tried 'gem environment' and
> pasting the output from there (4 lines? 4 environments?) but it doesnt seem
> to work. I just want my system to work how it did 2 days ago :(
>

This will depend on whether or not you're using a Ruby version manager –
see the previous point.

5) How could this have happened to me? Are most devs not stupid enough to
> delete these files? Im shocked this simple thing has had such devastating
> consequences. This must be why devs back up their dotfiles on github?
>

As other people have mentioned, a lot of people store their dotfiles on
GitHub – it'll save you when this kind of thing happens.


> 6) Should I focus on installing rails, gems, etc where it IS looking? I
> keep getting 'cant build for this or that reason' so thats a nonstarter as
> well.
>

Again, this is likely because your .zshrc / .bashrc was altering your Ruby
environment which isn't happening any more.

7) Can someone email me a gist of their ~/.zshrc and ~/.bashrc or
> ~/.bash_profile?
>

For the most part using other people's shell profiles will cause more
trouble than it's worth – they'll likely be dependent on software that's
not installed on your machine and just result in further confusion.


> 8) Is there a "stock" one I can use? I can't find an unmodified one on
> github.
>

If you're using zsh, then oh-my-zsh
<https://github.com/robbyrussell/oh-my-zsh> is good for this. There's also
a plethora of personal dotfiles at https://dotfiles.github.io/, though none
of these will work with your machine off the bat – they'll be dependent on
software that you likely don't have installed.


>
> This whole situation is like, every thread I pull on, something else falls
> apart. I cannot believe it. Complete disaster. Please help me or kill me
> and put me out of my misery. I am pulling my hair out here.
>
> --
> Jesse Waites
> Web Developer
> JesseWaites.com
>
> _______________________________________________
> Chat mailing list
> Chat at lists.lrug.org
> Archives: http://lists.lrug.org/pipermail/chat-lrug.org
> Manage your subscription: http://lists.lrug.org/options.cgi/chat-lrug.org
> List info: http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20170310/2ce454c5/attachment.html>


More information about the Chat mailing list