irb not starting - ruby

I'm running Ruby 1.9.2 w/ rbenv. I recently moved my Users directory to a different drive. Ruby and irb show up using which.
$ which ruby
/Volumes/Pig/Users/arrow/.rbenv/shims/ruby
$ which irb
/Volumes/Pig/Users/arrow/.rbenv/shims/irb
However, running irb hangs indefinitely.
I've also been running ruby files under the current config but executing $ ruby -v also hangs.

rbenv rehash can help solve these sort of problems. Anytime you modify your Ruby installation you need to rerun that command to let rbenv rebuilt its soft-links.
From the command-line output:
rehash Rehash rbenv shims (run this after installing binaries)
You might also need to tell rbenv where your binaries are again, i.e., rbenv global 1.9.2... and let it adjust things.
Remember, rbenv assumed your binaries were on a different volume so it might have gotten confused and needed you to straighten it out.
The other issue could be that Ruby bound to files on the other volume at compile time (because that's what rbenv does, it compiles Ruby for you) so when the files couldn't be found the apps crashed. Reinstalling rbenv would fix that, as telling it to reinstall a particular Ruby should have fixed it.

I uninstalled/installed rbenv and all is well.

Related

Trying to uninstall and fresh install Ruby on Ubuntu: do I still have Ruby installed?

I'm coming from Windows to Linux (Ubuntu) so I'm new to the CLI. I had issues trying to install Rails so I figured a fresh install would help. I'm following "Installing Ruby the Correct Way."
I thought I had uninstalled Ruby, but after installing 2.1.4 it still shows some Ruby folders. Have I completely uninstalled Ruby?
Downloading ruby-2.1.4.tar.gz...
-> http://dqw8nmjcqpjn7.cloudfront.net/bf9952cdeb3a0c6a5a27745c9b4c0e5e264e92b669b2b08efb363f5156549204
Installing ruby-2.1.4...
Installed ruby-2.1.4 to /home/richard/.rbenv/versions/2.1.4
richard#richard-ThinkPad-T400:~$ rbenv global 2.1.4
richard#richard-ThinkPad-T400:~$ ruby -v
The program 'ruby' can be found in the following packages:
* ruby
* ruby1.8
Try: sudo apt-get install <selected package>
richard#richard-ThinkPad-T400:~$ sudo rbenv global 2.1.4
richard#richard-ThinkPad-T400:~$ ruby -v
The program 'ruby' can be found in the following packages:
* ruby
* ruby1.8
Try: sudo apt-get install <selected package>
Are the "the following packages" on my local system? or are they online?
EDIT
I've been getting this error when I try to install RVM (and some other applications):
GPG signature verification failed for '/home/richard/.rvm/archives/rvm-1.26.0.tgz' - 'https://github.com/wayneeseguin/rvm/releases/download/1.26.0/1.26.0.tar.gz.asc'!
try downloading the signatures:
gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3
they can be compared with:
https://rvm.io/mpapis.asc
https://keybase.io/mpapis
Does this have anything to do with it? I wouldn't really think so but I'm a noob.
Don't sudo rbenv anything or you will summon Cthulhu. Use rbenv by itself.
Also, don't randomly follow guides on the internet until you're more familiar with your OS; They go stale, or start out wrong, or don't accurately apply to what you're doing. Instead, go to the source and follow the directions there.
To find out what is installed on your machine, use locate to quickly find Ruby instances. Something like:
locate /bin/ruby | grep -v .rbenv
should narrow down whether multiple Rubies are installed outside the ~/.rbenv directory.
Traditionally, you'll find a normally installed system-wide Ruby in /usr/bin/ruby. A user installed one from source will probably be in /usr/local/bin/ruby unless you specifically said otherwise, probably with a PREFIX= directive.
rbenv will default to installing Ruby in the ~/.rbenv hierarchy since it acts like a sandbox manager and will put all Rubies it installs underneath that directory. RVM, a similar application, will use ~/.rvm, and in both cases, the purpose is to keep them where the user's permissions are sufficient to install and update gems without requiring the use of sudo. For general use, avoid sudo unless you understand what you're about to do, as it can turn a computer into an under-desk heater in seconds.
The shell uses the PATH variable to figure out where to look for executable commands. It sounds like your PATH isn't set correctly. If you followed the directions on the rbenv site, they say how to enable rbenv by modifying your ~/.bash_profile script. Doing that, then closing and reopening your shell should bring rbenv to life.
Following that blog post, you are installing Ruby using a tool called rbenv, and if you only uninstalled one Ruby, that doesn't mean that all Rubies are uninstalled.
The message that you posted shows that it is a local install: Installed ruby-2.1.4 to /home/richard/.rbenv/versions/2.1.4 which is a copy of the 4th line of your message.
You can find out from whence your Ruby executable is being invoked by issuing at the command line:
which ruby
You will then know if the program is available and which it is. Using ruby -v if it is there will tell you the version.
You have done some of these steps and are finding out that your system does not know how to get to the Ruby, if it is indeed installed.
Right now, it is effectively uninstalled, as it is unavailable to your environment.

Accidentally deleted many hidden files with "git clean -fd" and now I cannot install Ruby

So I really messed up on this one.....
I was working on a rails application and wanted to revert back to a previous commit. I opened a new shell and forgot to cd into my projects folder, so I ran "git reset --hard" and then "git clean -fd" in my user directory. I noticed before everything was gone, but here is what got deleted:
bash-3.2$ git clean -fd
Removing .CFUserTextEncoding
Removing .Trash/
Removing .Xauthority
Removing .adobe/
Removing .bash_history
Removing .bash_profile
Removing .bundle/
Removing .config/
Removing .cups/
Removing .dropbox/
Removing .fontconfig/
Removing .gem/
Removing .gitconfig
Removing .guard_history
Removing .heroku/
Removing .irb-history
Removing .irb_history
Removing .lesshst
Removing .macports/
^C
I was able to save my project in that shell, but I (now realized stupidly) thought restarting my computer would be best once I realized my rails and bundle commands were not working in another shell. Unfortunately I lost that working shell which I through researching realize would have helped.
What is done is done, and I am trying to fix everything, but something I cannot get right is installing ruby. I am using rbenv to install ruby but even after installing it, it won't register with in any shell:
-bash-3.2$ rbenv local
2.1.1
-bash-3.2$ ruby -v
-bash: ruby: command not found
I am a bit inexperienced when it comes to the terminal and I am freaking out. I am wondering if I should restore factory settings. My important pictures and documents are backed up but I don't use time machine.
I don't know if it is just ruby which is the problem, so far nothing else has been an issue, but I would appreciate any help solving the problem!
EDIT
So I realize now that the issue was deleting my bash_profile which has had all sorts of knock on effects. I really don't know how to fix or reset it....I am trying to uninstall everything and reinstall it but I am having trouble figuring out what. I tried installing ruby via mac ports, which worked, but it was not sending the message to rbenv.
I suggest HomeBrew to install rbenv. It has worked better for me than MacPorts did.
This older post Modern Ruby Development (on Mac) is still very helpful.
The install for HomeBrew needs ruby, which will be a problem for you as you have lost ruby.
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
The rbenv lines you need in your .bash_profile, according to the rbenv install docs, are,
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
Do not forget to say, source .bash_profile after editing the profile, or open a new terminal.
If your rbenv command is no longer available, you can install it directly from git with,
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
That is assuming the git command still works.
With the rbenv lines restored to your .bash_profile, you might be able to install a ruby with,
rbenv install 2.1.1
(rbenv install -l will list available versions. Any of the lines output from there can go after rbenv install.)
Finally, use rbenv global to set the default ruby to one of the rbenv installed ones.
rbenv global 2.1.1
You can view the current global ruby set for rbenv with,
rbenv global
As you know,
ruby -v
will get the version of the ruby that runs by default. You might not know that,
which ruby
will tell you where the shell finds that ruby command in your path.

does rbenv set the PATH variable to point to the correct ruby?

I installed rbenv and it seems and copied 2 versions of ruby to ~/.rbenv/versions, it shows
them both correctly.
When I run
rbenv global 1.8.7-p72
It says ok and also points to it. However when I run--
ruby --version
I get ruby not found. Basically, the ruby executable is not found in the path. Can anyone help me with this problem?
My .bash_profile is
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
rbenv versions outputs --
1.8.7-p72
*1.9.3-p448 ( set by /home/user/.rbenv/version)
Also my ~/.rbenv/shims directory doesn't have a ruby executable. It has erb, gem,irb , rake, rdoc , ri and testrb. Could this be the issue?
I'm sorry I'm completely clueless
Did you execute all the step in the installation instructions https://github.com/sstephenson/rbenv? I.e. did you add the required snippets to your shell startup (.bash_profile) and so forth?
If you followed the instructions, could you provide the output of rbenv versions and which -a ruby for a start?
EDIT:
rbenv rehash seems to be what generates the shims. This must be executed every time you install a new ruby version. How did you install the rubies? With ruby-build, as recommended in the installation instructions?
When I encountered this error, all I had to do was to make sure that $PATH had shims prior to system version of ruby like so:
~/.rbenv/shims:/usr/local/bin:/usr/bin:/bin

How do I uninstall an old version of Ruby, and is it a wise thing to do?

When logged in as root and I type ruby -v centOS server reports 'ruby 1.9.3p392'. This is what I want.
But if I put rvmsudo ruby -v then I get 'ruby 1.8.7'. I do not want to use this older version, it is causing problems for my gitlab install.
I would like to remove it and make sure only v1.9 is used, how can I do this? Or should I leave it there but try and require certain users to use a different version?
Also, in case doing this messes anything up, is it possible to either;
a.see if anything on the server requires v1.8?
b.reverse the uninstall if it causes a problem?
Before uninstalling, take note of the patch level of 1.8.7 just in case. rvmsudo ruby -v should return something like ruby 1.8.7p234. The p#{num} is your patch level.
You should be able to uninstall 1.8.7 with rvm uninstall 1.8.7 (or possibly rvmsudo uninstall 1.8.7). This version of Ruby shouldn't be used by anything on the system other than code you've written, so it should only affect your applications and scripts.
The best way to tell what else would be using 1.8.7 is to look for scripts and crontabs that are owned by the user that rvm is running under. I'm not sure there's a tool that can evaluate it for you.
The best way to roll back in case of an emergency is rvm install 1.8.7-p#{num_from_above}. Alternatively, if you're on a platform like AWS or have rsync backups enabled, you might consider taking a snapshot that you can roll back to if you get in over your head.
Hope that's helpful!
Try setting default
$ rvm --default use 1.9.2
$ ruby -v
#ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.4.0]
to remove you can use:
sudo apt-get remove ruby 1.8.7
Docs here & here
As you mentioned the ruby version output for root is ruby 1.9.3p392 in my understanding you will not have any problems.
Sure, you can have more than one version of ruby installed and find them under ~/.rvm/rubies. Also there you can find out the default version which is used. For more information you can have a look here: set default ruby where it explains how to set a default ruby and how to reset to the systems default.
You can uninstall cocoapods and install cocapods in the right directory.
sudo gem uninstall cocoapods
sudo gem install -n /usr/local/bin cocoapods

rbenv clobbering my gem INSTALLATION DIRECTORY when using system

I want to use rbenv for setting ruby versions on a project per project basis. Otherwise, I want to use my default system ruby setup for everything else.
The problem I am having is the even though rbenv version returns system, gem command still uses the rbenv shim (.rbenv/shims/gem). So when I do gem environment my INSTALLATION DIRECTORY is '/Library/Ruby/Gems/1.8'. I would rather it remains ~/.gem/. I can see it still is that when I run /usr/bin/gem enviroment. I can't figure out where the rbenv shim gem is getting its settings from.
I've tried modifying my GEM_HOME both in my shell, and changing it in ~/.gemrc but that has no effect. I've been searching around with no luck. Hopefully someone here can help. Just some pointers to where the rbenv gem shim is pulling its values from would be helpful.
thanks
Since rbenv shims are pretty high in your PATH, their purpose is to intercept any invocation of ruby, gem, and similar, even if the currently selected Ruby version is "system". You shouldn't be worried about that.
Now, the default installation path for your system Ruby will always be /Library/Ruby/Gems/1.8. Here's my RBENV_VERSION=system gem env:
- GEM PATHS:
- /Library/Ruby/Gems/1.8
- /Users/mislav/.gem/ruby/1.8
- /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
However, if you don't use sudo (and you shouldn't), gem install won't have write access to that directory, and will install the gems in the next writeable path, which is ~/.gem/ruby/1.8. That seems to be the behavior you want.

Resources