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

So I really messed up this ... I was working on a rail application and wanted to go back to the previous commit. I opened a new shell and forgot cd in my projects folder, so I ran "git reset --hard" and then "git clean -fd" in my user directory. I noticed before everything went away, but here is what was 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 managed to save my project in this shell, but I (now understood stupidly) thought that rebooting my computer would be better if I realized that my rails and package commands do not work in another shell. Unfortunately, I lost this working shell, which through research I would understand would have helped.

What has been done, and I'm trying to fix everything, but something that I can’t get is setting the ruby. I use rbenv to install ruby, but even after installing it, it will not be registered in any shell:

 -bash-3.2$ rbenv local 2.1.1 -bash-3.2$ ruby -v -bash: ruby: command not found 

I'm a little inexperienced when it comes to the terminal, and I'm worried. I am wondering if I should restore factory settings. My important images and documents are backed up, but I do not use a time machine.

I do not know if this is just a ruby, that the problem, so far nothing else has been a problem, but I would appreciate any help in solving this problem!

EDIT

So, now I understand that the problem was removing my bash_profile, which had all kinds of effects strikes. I really don’t know how to fix or reset it .... I try to uninstall everything and reinstall it, but it’s hard for me to understand that. I tried to install ruby ​​through Mac ports that worked, but it did not send a message to rbenv.

+5
source share
1 answer

I suggest HomeBrew install rbenv. It worked better for me than MacPorts.

This old article Modern Ruby Development (on Mac) is still very useful.

Installation for HomeBrew needs a ruby, which will be a problem for you because you have lost a ruby.

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

The rbenv lines you need in your .bash_profile, according to 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 

This means that the git command is still working.

If rbenv strings are restored to your .bash_profile, you can install ruby ​​with

 rbenv install 2.1.1 

( rbenv install -l lists the available versions. Any line output from it can follow rbenv install .)

Finally, use rbenv global to set the ruby ​​by default to one of the installed rbenvs.

 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 ruby ​​version, which runs by default. You may not know this,

 which ruby 

will tell you where the shell finds the ruby ​​team in your path.

+1
source

Source: https://habr.com/ru/post/1200794/


All Articles