zsh command not found: zeus, mailcatcher, etc? - shell

I've been going over this for awhile now and can't seem to get it permanently resolved. Was hoping someone could clarify for me.
I'm pretty familiar with setting up my PATH and working with ZSH. I have a ton of custom helpers, plugins, etc. going on nicely.
But for some reason, when I do gem install gemname and attempt to use it globally, it occassionally says gem not found. I found this happening recently with zeus:
tmtm|master⚡ ⇒ gem which zeus
/Users/andrewmartin/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/zeus-0.13.3/lib/zeus.rb
tmtm|master⚡ ⇒ zeus
zsh: correct 'zeus' to '_zeus' [nyae]? n
zsh: command not found: zeus
I had the same problem recently with mailcatcher and was never really able to get it installed or working. I had a couple really good Rails buddies take a look, they were confused as well.
Here's my PATH:
tmtm|master⚡ ⇒ echo $PATH
/Users/andrewmartin/.rbenv/bin:/usr/local/share/npm/bin:/usr/local/bin/npm:/Users/andrewmartin/.rbenv/shims:/Users/andrewmartin/.rbenv/:/Users/andrewmartin/.rbenv/bin:/usr/local/bin:/usr/bin:/Users/andrewmartin/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin:/usr/local/opt/ruby/bin:/Users/andrewmartin/Dropbox/Favorites/dotfiles/bin
Any idea why some of these common, global gems are simply not found in the zsh shell? Happy to share any other information that would make this helpful. I am using rbenv.

I figured it out!
Simple!
Whenever you install a new gem with rbenv, you have to use the rbenv rehash command. It said it found one, so I just deleted the one that existed, then typed it again. When I opened a new terminal, both mailcatcher and zeus were magically available to me.
Awesome! Thanks to this post by the way.

Related

RVM: Use Ruby everytime?

I have installed Ruby 2.1.2 using RVM on Ubuntu 14.04. It works the first time, but then I restarted the terminal and it didn't work anymore. I figured out that I had to type rvm use ruby-2.1.2 every time.
I have researched and found out that I had to set a default. I did that, but it stil doesn't work. I also checked that the .bash_profile and .profile files look right.
Can anyone help me with that?
I figured this out myself and now post this for future reference:
I had to check the setting 'use as login shell' in the gnome terminal. See "RVM can't set ruby as default" for reference.

Why doesn't rails.vim recognize any gems that I install?

I'm a ruby and vim newbie. I recently installed the rails.vim plugin and all the commands work fine apart from the commands to create a new Rails project. Every time I do this it says rails is not installed on my system, but it is! It also acts up when I create a class that requires a gem that I've installed. Can anyone help with this?
Did you rvm use system before building / brew install-ing macvim? I didn't and got many errors. Doing rvm use system beforehand fixed things up for me.

RVM causing path issues with installed gems on Ruby 1.9.2 - unable to annotate, etc, do I need to reinstall RVM?

I'm on Mac OSX Snow Leopard. I tried to post a similar question to the RVM Google group but it did not seem to get posted.
I'm worried that I've done something fundamentally wrong with my RVM install that's causing these errors, that seems to be related to paths, at each step of the way. Have any of you seen this behavior before?
I started to teach myself Rails programming as of about two months ago with a working environment of Ruby 1.9.1 and Rails 3.0.3, based on a hivelogic install tutorial that had me modify my ~/.profile file and install the relevant bits to ~/usr/local/src/. For reference, the line in my ~/.profile file was this when I installed RVM, if that makes any difference:
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/local/src:$PATH"
In my terminal I installed RVM as a user using the standard user github bash script.
I tried to install Ruby 1.9.2, which kept running into a weird error about a libfile somewhere. After much Googling I found someone on Stack Overflow that recommended renaming the ~/usr/local directory while performing the Ruby install -- I did this, and the install complete.
Then I did gem install rails and tried to do bundle install in my app, which gave an error when trying to install the SQLite3 gem (even though I already had SQLite3 installed and working). Again, I spent a day Googling this and eventually found "Unable to install sqlite3-ruby gem" that said if I used Macports to sudo port install sqlite3 it would work.
I tried that from the base directory, and Macports did its thing but it didn't fix the problem. Then I did the same thing from my app directory and it fixed the SQLite3 error I was getting.
Now I am able to run rails server and rails generate again, which is great, but then I tried to "annotate" my new model, and I get this error: http://pastie.org/1481570
I have not yet solved this issue, and have looked at many threads of similar issues. This, for example, did not solve my problem: https://github.com/james2m/annotate_models/commit/5997da9692c9b222e8d1be22dfad6ed8638c16a1
I even tried copying my source code directly into the rvm/user/ directory in case that relative path was causing problems, but it doesn't seem to have fixed anything. Maybe I need to uninstall RVM and re-install it as root instead of a user-level thing?
What do you think is the best way to get annotate to work and hopefully get RVM to play nice with my gems going forward?
I'm unfortunately REALLY new to terminal, code, etc, so any help would be much appreciated.
On Snow Leopard you should modify either ~/.bashrc or ~/.bash_profile, preferably the later. Also, RVM will not need anything in ~/usr/local since it's entirely self-contained in ~/.rvm.
RVM uses a nice little shell function to sense the needed directories and desired default Ruby. I suspect either the instructions you followed were very out of date, or poor recommendations. The current RVM installation requests you add:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
to your ~/.bash_profile
The RVM site has lots of troubleshooting tips for things like MySQL. I'd strongly recommend backing out of the things those other tutorials had you do, and refer to the instructions on RVM's site. It is very easy to get things working right if you do it the RVM-way.
Download and install Apple's latest version of XCode from their Developer site if you haven't already. There have been some broken versions shipped on the DVDs.
Install. In particular follow the "Post Installation" section.
Following that, do whatever rvm notes says to do as far as libraries. Following that, you should be able to use rvm info to gather useful info about your installation. It is your best friend.
Database integration will point you to how to fix MySQL's wagon.
RVM development happens fast. Keep it updated, at least once a week using rvm get head.
At that point you should be in a good place to start reinstalling gems.

Upgrading Ruby on Mac OS X

I am reading the book Programming Ruby and am looking to upgrade the version of Ruby on my computer. I run Mac OS X Snow Leopard and doing ruby -v in the command line shows I am running Ruby 1.8.7.
I installed MacPorts and ran the sudo port install ruby19 command but whenever I type ruby -v, it still shows Ruby 1.8.7.
Could anyone help with this? Thank you.
The tool "rvm" is pretty good. It stands for Ruby Verson Manager I think, and the developer is good at support in the irc channels. You can install multiple versions of ruby along side each other pick the ones you want to use.
http://rvm.io
You have to use ruby19 to run ruby if you installed it that way. You can also use irb19, and ri19.
I updated the link to RVM in one of the answers, but also a quick poll of some friends doing Ruby dev currently revealed a preference for rbenv as a ruby environment manager: http://github.com/sstephenson/rbenv/
As mentioned in hvgotcodes answer, RVM seems to be a great way of handling this.
I recently started learning Ruby (and Rails) myself, and this[1] tutorial has a great section on using RVM. I'd highly recommend you give it a go, it's especially handy so that you can follow different tutorials on different versions of Ruby if you wish.
[1] http://railstutorial.org/book#sec:rubygems
As #Andrew Grimm eluded, the problem you are having is likely due to a problem in your $PATH variable. Since macports typically installs stuff in /opt, modifying your $PATH variable to:
$ export PATH=/opt/local/bin:$PATH
Will most likely help. However, I would urge you to look into RVM as #hvgotcodes recommends.

Passenger installation with nginx fails

I'm running an ubuntu 9.10 server on an amd-64 platform. Everything's pretty much standard, and I've got Sinatra 0.94 running on a ruby 1.8 installation. I want to install passenger in order to easily configure ssl.
The problem is, it fails to find the installer.
I run
sudo gem install passenger
or
sudo gem install -r passenger
and then the next line,
passenger-install-nginx-module
or
passenger-install-apache2-module
both fail because the path isn't found.
Is there something I'm forgetting here? Shouldn't it just work, straight up, once the gem is installed?
A bit late for an answer I guess, but actually, the correct way of running the Phusion Passenger installer for nginx, when using RVM, is to use rvmsudo as in:
rvmsudo passenger-install-nginx-module
Credits go to this blog post,
I got it working with
rvmsudo `which passenger-install-nginx-module`
according to this issue on github: https://github.com/wayneeseguin/rvm/issues/1307
seems like you have to do full path:
this worked for me:
which passenger-install-nginx-module
rvmsudo ~/.rvm/gems/ruby-1.9.3-p327-new/gems/passenger-3.0.18/bin/passenger-install-nginx-module
apparently, the gem is installed in a place that's off the path, according to
http://groups.google.com/group/phusion-passenger/browse_thread/thread/78ca12c4838034a6/b5a3c7a00a871283?lnk=gst&q=ubuntu+9.10#b5a3c7a00a871283
Frustrating error, which is why I leave this question rather than delete it (and, with the upvote, I think I'm not the only one with the problem).
I had a similar issue. You need to add gems to your system PATH, paste this into your shell:
export PATH=$PATH:$HOME/bin:/var/lib/gems/1.8/bin
or, to make it permanent add it to your bashrc, usually here: ~/.bashrc
You can also execute just passenger-install-nginx-module by going to the directory at: /var/lib/gems/1.8/bin
Good luck!
I know you already answered the question, but figured I'd chime in with a cent or two.
I recently did a similar nginx install, but chose to go with RVM for managing Ruby versions, which requires us to NOT use sudo.
I recommend this route because all versions of Ruby and all your gems are organized neatly in your home directory. Doing so will also require you to compile nginx manually, which certainly helps understand the pipes a little.
You can compile nginx manually using the "--add-module=/home/user/path_to_passenger_gem/ext," but you'll want to read up RVM's instructions very carefully...really, don't skip a line as they are very concise.
Here's a link to RVM's instructions:
http://rvm.beginrescueend.com/passenger/
and to the Nginx manual instructions (which you probably already skimmed).
http://www.modrails.com/documentation/Users%20guide%20Nginx.html#_installing_phusion_passenger_for_nginx_manually
I have got a bit of information on my blog regarding setting up nginx with passenger (and ssl in this case). Perhaps it is of use since it goes through the whole process of recompiling nginx with options.

Resources