RVM not found, after installing RVM - ruby-on-rails

I've found a couple similar posts regarding this same problem, but none of the solutions seem to apply, here.
On a fresh Ubuntu 10.10 install, I follow the instructions for installing RVM:
$ bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
Then I create .bash_profile and add the following line:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
I restart the terminal and check RVM:
$ type rvm | head -1
-bash: type: rvm: not found
As the RVM installation guide explains to do so, I replaced the first line (below) in .bashrc with the second one, then indented everything in the rest of the file and added a fi.
[ -z "$PS1" ] && return # original
if [[ -n "$PS1" ]]; then # replaced with this
Restarted terminal and still, no luck.
Then, I removed the line I added to .bash_profile in the beginning and added it to .bashrc, even though that isn't what the guide said to do. Still, no luck. I also entered it directly on the command line, with no change in behavior. When I run .rvm from ~/.rvm/bin/rvm it complains that there is no such file or directory as /.rvm/scripts/rvm and that the command was not fund.
Of course, there isn't any such "scripts" directory inside of ./rvm, either -- so I'm not sure why it's looking for one? The only directories inside of .rvm are
archives
bin
config
gems
gemsets
log
man
rubies
src
tmp
user
The only thing I've found while googling for answers are other people complaining of similar problems and people telling them to add the instructed line to .bash_profile (which I obviously already did). At this point, I have nothing more to go on and am at an impasse.
Regards.
Resolution:
As Andrew Marshall advised in his comments, below, I did an 'rm -rf .rvm' and reinstalled rvm. I had actually attempted this two times before posting here, with the same results every time. No odd messages in the install log, but no /scripts/ directory, either. Just so I could say I had, I did it a third time at Andrew's urging. This time, I checked and the /scripts/ directory existed. Running 'type rvm | head -1' confirmed it as a 'function' and I can now move on.

Make sure that you restart a session after reinstalling, so that rvm is in your path.
You can try to logout/login.
You can also open your shell as a login shell. Under ubuntu 12.04:
Open a terminal
Edit > Profile Preferences
Under tab Title and Command, check run Command as a login shell
Open new terminal (ctrl+alt+t) and type rvm

If there's no scripts directory inside .rvm, it would seem that RVM failed to successfully complete installation. Delete the .rvm directory, try reinstalling, and look at the installation output closely to see if it's complaining about anything.

Related

Adding homebrew to $PATH without sudo privileges

I've been trying to install homebrew without admin privileges on my school MacBook (Mojave 10.14.6) for the past 2 weeks. I've seen many things on the internet, saw some scripts, tutorials, but nothing seems to help.
I used this script (did some tweaking to it like changing to a new repository and setting absolute path)
https://gist.github.com/skyl/36563a5be809e54dc139
the repository I used is
https://github.com/Homebrew/brew
my path to brew is
/Users/as.gurban-zade/Desktop/homebrew/usr/local/bin/brew
I added this to the $PATH using
echo "export PATH=/Users/as.gurban-zade/Desktop/homebrew/usr/local/bin:$PATH" >> ~/.bash_profile && source ~/.bash_profile
also tried
echo "export PATH=/Users/as.gurban-zade/Desktop/homebrew/usr/local/:$PATH" >> ~/.bash_profile && source ~/.bash_profile
After everything I did, I still get
-bash: brew: command not found
Updating OS to Catalina is possible if that would help

'Zsh: command not found: valet' - unable to install Valet

I just tried installing valet for a very long time, - and I couldn't find any help anywhere. No matter what I tried, then it kept saying:
Zsh: command not found: valet
I'm running Zshell (instead of Bash) and OSX. I've had Brew installed for quite a while.
I'll answer this myself, - so hopefully people in the same situation can find this in the future.
I had a very similar problem under Zsh, but my solution was easier. Rather than adding ~/.composer/vendor/bin to my $PATH, I needed to use the full directory name; i.e., /Users/[your-user-name]/.composer/vendor/bin.
Everywhere it says to 'Check that your path is right'. And yup - if you haven't done that, then you should start there. The easiest way is to go to your terminal and write:
echo $PATH
... And then you should see ~/.composer/vendor/bin in between two colons in there. If that isn't there, then you should go to your ~/.bashrc-file (or ~/.zshrc-file) and add this line:
export $PATH=~/.composer/vendor/bin:$PATH
And then it may be fixed.
My problem had deeper roots, though. Even though my path was right, then I still got the error:
Zsh: command not found: valet
And if I wrote: which valet - then it (obviously) just responded with valet not found.
Removal of Composer
What fixed it was to remove all my composer-installations. Composer can be located in several different locations (and installed by brew). So in order to remove it, then do this (inspired by this post, but it lacks a couple of steps):
Remove your composer- or -composer.phar-file. You can find them by running which composer and/or which composer.phar.
Remove your .composer-folder (usually located here: ~/.composer).
Then make sure that there isn't an installation done with Homebrew (this was what I think made the collision for me). You do it by running brew unlink composer followed by brew remove composer.
Then, - if you want to be 100% sure that it's all gone, then go to your root (cd /) and run this command: find ./* -name 'composer.phar' and this find ./* -name 'composer'. That should tell you of all the locations where the Composer-installation can be installed.
When all that's removed, then you should be rid of Composer (entirely).
... Then install it again, - and see if you can get valet to work (it did for me).
The solution was adding composer bin to the path. You can use the following commands
From the terminal
export PATH="$PATH:$HOME/.composer/vendor/bin"
echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.bash_profile
source ~/.bash_profile
valet install
Issue Ubuntu: no command valet
Valet on Ubuntu:
sudo apt install libnss3-tools jq xsel
composer global require cpriego/valet-linux
.composer/vendor/cpriego/valet-linux/valet install
Now command valet should work, but if still not:
sudo cp .composer/vendor/cpriego/valet-linux/valet /usr/local/bin/

Atom linter-erb failing with "Error: /usr/bin/env: ruby: No such file or directory"

I have the linter set to check on save and it throws this error every time I save a .erb file. In the settings for the package I have both the following settings specified:
Erb Executable Path
/home/jason/.rvm/rubies/ruby-2.3.0/bin/erb
Ruby Executable Path
/home/jason/.rvm/rubies/ruby-2.3.0/bin/ruby
I was having a similar issue with the linter-ruby package, but setting the ruby executable path seemed to fix it. Here's what my path looks like:
$ echo $PATH
/home/jason/.nvm/versions/node/v5.10.0/bin:/home/jason/.rvm/gems/ruby-2.3.0/bin:/home/jason/.rvm/gems/ruby-2.3.0#global/bin:/home/jason/.rvm/rubies/ruby-2.3.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/jason/.rvm/bin:/home/jason/.rvm/bin
Here's the full output of the error.
Error: /usr/bin/env: ruby: No such file or directory
at parameters.exit (/home/jason/.atom/packages/linter-erb/node_modules/atom-linter/lib/helpers.js:47:27)
at triggerExitCallback (/opt/atom/resources/app.asar/src/buffered-process.js:213:47)
at /opt/atom/resources/app.asar/src/buffered-process.js:220:18
at Socket.<anonymous> (/opt/atom/resources/app.asar/src/buffered-process.js:98:18)
at emitOne (events.js:82:20)
at Socket.emit (events.js:169:7)
at Pipe._onclose (net.js:469:12)
It seems even though I've specified where it should be looking for ruby, it's still looking in /usr/bin/env.
Here's a bit more output that's hopefully helpful:
$ which erb
/home/jason/.rvm/rubies/ruby-2.3.0/bin/erb
$ which ruby
/home/jason/.rvm/rubies/ruby-2.3.0/bin/ruby
I'm not sure this would have any effect, but for the sake of trying to cover all my bases, I also have this in ~/.bashrc
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
Ubuntu: 15.10
kernel: 4.2.0-34
Atom: 1.6.0
linter-erb: 1.0.2
I've restarted Atom several times but the error keeps popping up. Any help would be much appreciated.
EDIT
I found that if I start Atom from the terminal, I don't have this problem, but when I launch it from the icon in the launcher, the issue crops up again.
Try pointing the linter to RVM wrappers instead of direct binaries in RVM which work OK only in interactive shells. RVM wrappers make the binaries run correctly even in other environments and shells.
Simply choose a wrapper directory under $HOME/.rvm/wrappers/ for your desired version of ruby and gemset and use the binaries from there.
See this answer for more explanation.

How to remove the existing environment variable in Linux?

This is my machine path :
~$ echo $PATH
/home/sam/.rvm/gems/ruby-2.1.2/bin:/home/sam/.rvm/gems/ruby-2.1.2#global/bin:/home/sam/.rvm/rubies/ruby-2.1.2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/sams/.rvm/bin:/usr/local/bin
Here, I want to remove all the paths related to rvm
I removed all the above lines from .bashrc and .bash_profile but still it exists in the GEM_PATH where else it is erased from the common PATH
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
check:
echo $PATH
you can add the export code inside .bashrc
The first place to look for alternations in the $PATH variable would be your .bashrc file. Look for something like:
export PATH=/your/homefolder/.rvm:$PATH
Another thing worth asking, do you have this behaviour on startup of the system or is it just in one local shell window? If it's only in the current shell session (and not in the .bashrc or something similar), it will not stick/be permanent.
You can manually overwrite your PATH through exporting it again, but that only affects the current session.
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
If you want the change to last, you have to find where the rvm parts are added to the PATH variable. That's probably at the end of the ~/.bashrc (or ~/.profile, or ~/.bash_profile, or /etc/profile, .. it depends on how you installed rvm) file. You can safely remove those lines that add rvm to the path.
In case you also want to uninstall rvm (which I suspect if you go the second route), do a
rvm implode
To remove Rvm, run
$ rvm implode
Are you SURE you wish for rvm to implode?
This will recursively remove /Users/gaurish/.rvm and other rvm traces?
(anything other than 'yes' will cancel) > yes
Removing rvm-shipped binaries (rvm-prompt, rvm, rvm-sudo rvm-shell and rvm-auto-ruby)
Removing rvm wrappers in /Users/gaurish/.rvm/bin
Hai! Removing /Users/gaurish/.rvm
This will remove RVM & its entire from your path.
ANd if you want to keep rvm or have already removed it manually. Now, just want to get rid of the rvm related entries from PATH. find this line which is responsible for adding rvm to your path:
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
using grep
$ grep -nr 'PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting' ~
Now, you will have the list of files along with line number that contain this line. you can ignore any entries in history. Mainly focus on entires in ~/.bashrc, ~/.profile, ~/.zshrc and other config files. And remove each of those

Bash profile messed up?

When trying to install Ruby on Rails using railsinstaller.org they messed up my system a bit after I uninstalled it and now my terminal prints this every time I start a new terminal up:
Last login: Fri Mar 1 15:01:45 on console
-bash: /etc/profile.d/sm.sh: No such file or directory
-bash: /etc/profile.d/rvm.sh: No such file or directory
I checked my .bash_profile and it doesn't reference anything like that. Any ideas of what's up and how to fix it?
I'm running Mac OS X by the way...
Usually the shell sources a lot of files during startup and these are common locations that come to my mind:
~/.bashrc
~/.profile
/etc/profile
/etc/profile.d/*

Resources