Installing RVM with space in $USER - ruby

So I've run into a bit of a problem. I've found many similar problems with spaces in $HOME, but the fixes do not apply to spaces in $USER - so I'm posting a question here.
Due to regulations at work my username for my workstation consists of +space+ (cannot be changed), for instance: John Doe
This is my $USER:
$ echo $USER
john doe
When I try to install rvm I get the following error:
It looks you are one of the happy *space* users(in home dir name),
RVM is not yet fully ready for it, use this trick to fix it:
sudo ln -s "/Users/john doe/.rvm/" /john doe.rvm
echo "export rvm_path=/john doe.rvm" >> "/Users/john doe/.rvmrc"
However, when I try to run the first command I get the following error:
ln: doe.rvm: No such file or directory
And if I attempt to run
sudo ln -s "/Users/john doe/.rvm/" "/john doe.rvm"
I get:
ln: /john doe.rvm: File exists
Any help would be tremendously appreciated :-)
Edit
sudo ln -s "/Users/john doe/.rvm/" /john\ doe.rvm
yields
ln: /john doe.rvm: File exists
Edit 2
Okay, thanks to platzhirsch I no longer get an error message when running the ln command. Now the problem is following:
When I run
echo "export rvm_path=/john\ doe.rvm" >> "/Users/john doe/.rvmrc"
or
echo "export rvm_path="/john doe.rvm"" >> "/Users/john doe/.rvmrc"
I get the following error when trying to re-install:
usage: dirname path
Edit 3
I've also tried manually editing the .rvmrc file. This is what it looks like:
export rvm_path="/john doe.rvm"
I've also tried
export rvm_path=/john\ doe.rvm
With no luck, I still get:
usage: dirname path
When I try to run
\curl -L https://get.rvm.io | bash -s stable --ruby

this message is fixed with https://github.com/wayneeseguin/rvm/issues/2140 - just start again and now it will propose the directory with _ (underscore) instead of (space)

why don't try to escape the white space ?!
sudo ln -s "/Users/john\ doe/.rvm/" "/john\ doe.rvm"
See this pst about escaping in linux shell. It is (almost) the same if you are using a terminal on a mac

Related

Why does typing $ in fish shell show the error "Unknown command: bind_dollar"?

I am running fishshell 3.5.1 on MacOS Monterey 12.5.1
I can work most all commands just fine but whenever I try to type in the dollar sign (even before pressing Return) I get the error: "Unknown command: bind_dollar"
I've tried:
Reinstalling w/Homebrew
Confirming that fish is in PATH
Deleting my fish.config
Below is the output of my issue and setup:
This happens as soon as I type a dollar sign:
$ fish: Unknown command: bind_dollar
Fish config directory:
~/.config/fish
$ ls
completions/ conf.d/ config.fish fish_variables functions/
Using /bin/sh to examine my $PATH:
$ /bin/sh
sh-3.2$ echo $PATH
/usr/local/bin:/usr/local/git/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin
Ensuring fish is located in PATH:
sh-3.2$ whereis fish
fish: /usr/local/bin/fish
Viewing the contents of my fish.config (which is the default version):
sh-3.2$ cat config.fish
if status is-interactive
# Commands to run in interactive sessions can go here
end
Thanks to Glenn's comment, I was able to track down the issue:
Running:
grep -r bind_dollar ~/.config/fish
Returned:
~/.config/fish/functions/fish_user_key_bindings.fish
Which contained:
function fish_user_key_bindings
### bang-bang ###
bind ! bind_bang
bind $ bind_dollar # <-- removing this line fixed the issue
### bang-bang ###
end
Removing the "bind_dollar" line fixed the issue.

source /.bash_profile command provide error

I run the command source ~/.bash_profile and get the following error:
$ source ~/.bash_profile
-sh: /Users/chaklader/.sdkman/contrib/completion/bash/sdk: line 37: syntax error near unexpected token `<'
-sh: /Users/chaklader/.sdkman/contrib/completion/bash/sdk: line 37: ` done < <(curl --silent "${SDKMAN_CANDIDATES_API}/candidates/all")'
The login shell that I use is bin/sh:
Whats the issue here and how to solve it?
This is how I solved the issue with the provided steps:
Install Homebrew from the docs on their homepage
Install Git using Homebrew (optional, but nice to have a more up-to-date git)
brew install git
Now install bash:
brew install bash
Add this install of bash to the allowed shells list:
echo '/usr/local/bin/bash' | sudo tee -a /etc/shells;
Homebrew installs things to /usr/local/Cellar/ by default, then symlinks any binaries to /usr/local/bin, so you've now got the latest bash sitting at /usr/local/bin/bash
Finally, change your shell to use this new one:
chsh -s /usr/local/bin/bash
Open a new terminal window/tab, and run these commands to double-check your work:
$ echo $SHELL
/usr/local/bin/bash
$ echo $BASH_VERSION
5.1.8(1)-release
This also solved the issue for running the source ~/.bash_profile whenever I open a new window in the terminal.
Reference:
The answer is from here How do I install Bash >= 3.2.25 on Mac OS X 10.5.8? by user jeffbyrnes

Linux: Curl installed but -bash: :curl: command not found

Running Debian Stretch on an r710. Using the non-free/contrib build for driver support.
When I try to use packages that I've installed (curl, zpool, etc), I have to include the path to the package... Which is a pain when I don't always know where packages install to.
Two questions:
How do I remedy the path issue in the short term?
How do I amend Debian so that when packages are installed, their paths update/install automatically?
Just install it by:
apt install curl
or sudo apt install curl
Find where the command is stored by
which <command>
Either you can try run curl from the output above for example /usr/bin/curl then try execute this:
/usr/bin/curl
For a temporary fix until you solve the real problem you can do:
cd /usr/local/bin; ln -s $(which curl) curl
Or you can just set an alias:
echo "alias curl='$(which curl)'" >> ~/.bashrc; . ~/.bashrc
Troubleshoot your problem:
Check so PATH folder has the correct paths exported:
printf "%s\n" $PATH
Modify current PATH
Use the export command to add new paths and see if that works you can then update your ~/.bashrc or ~/.bash_profile, but first you can try in shell without adding it permanent to $PATH
export PATH=$PATH:/missed/bin/folder
To format your PATH variable for easy viewing in future you can add below function to your .bashrc
function path(){
old=$IFS
IFS=:
printf "%s\n" $PATH
IFS=$old
}

Automatic RVM installation

I am trying to have RVM and ruby installed in an Ubuntu 12 virtual machine without human interaction apart from the password prompts.
I created a shell script to do this that works pretty fine until I need to use RVM itself.
I am using multi-user installation.
#!/bin/bash -l
mainUser=`whoami`
echo "Installing as '${mainUser}'"
echo "Installing git..."
sudo -S apt-get install --yes curl git-core
echo "Installing RVM..."
\curl -L https://get.rvm.io | sudo bash -s stable
echo "Adding ${mainuser} to RVM group..."
sudo adduser $mainUser rvm
newgrp rvm
From here things get weird.. I need to load dvm as a source. I want both my script to have this source and my user's bash_profile / bashrc. Anyway.. I know how to do it manually, but I can't have this done from the script. This is the last code I tried:
. "/usr/local/rvm/bin/rvm"
rvm use ruby-head
rubyVersion=`rvm list | awk '/ruby-head/{print x;print};{x=$0}' | sed -n '/ruby-head/{g;1!p;};h' | awk -F ' ' '{print $1}'`
rubyTest=${rubyVersion}#test
rvm use $rubyTest --create --default
The error I get is this:
test.sh: 7: /usr/local/rvm/bin/rvm: Syntax error: "(" unexpected (expecting "fi")
If I simply try to use the full path, like this:
rvm=/usr/local/rvm/bin/rvm
$rvm use ruby-head
rubyVersion=`$rvm list | awk '/ruby-head/{print x;print};{x=$0}' | sed -n '/ruby-head/{g;1!p;};h' | awk -F ' ' '{print $1}'`
rubyTest =${rubyVersion}#test
$rvm use $rubyTest --create --default
I get this error instead:
RVM is not a function, selecting rubies with 'rvm use ...' will not work.
I am clueless. Why can't I use /usr/local/rvm/bin/rvm?
Is there a way to execute source /etc/profile.d/rvm.sh for this user from the script?
I am not so good at shell script and Linux, so I appreciate any references and examples you could give.
Thanks!
UPDATE
I also tried:
source "/usr/local/rvm/scripts/rvm"
... and all it's variants. Same error: "RVM is not a function".
rvm is actually implemented as a shell function rather than an executable, which is why you can't just call /usr/local/rvm/bin/rvm itself.
Quoting you, "Is there a way to execute source /etc/profile.d/rvm.sh for this user from the script?"
Have you tried doing that? I had a somewhat similar install once where it didn't work properly from crontab (they have instructions on the site for that scenario, but we couldn't make them work), and I had to do almost exactly that -- source part of the profile.d for rvm.
RVM is not a function, selecting rubies with 'rvm use ...' will not work.
Above error is generated when rvm is not running and hence your terminal is not able to recognize it, as it tries to run it as a system command.
You may want to try this to run rvm through your shell script before calling rvm methods:
source ~/.rvm/scripts/rvm
I found out what is causing the issue.
I realised before that I would get errors in the lines with conditions in the script files, so I came across this page:
https://superuser.com/questions/552016/bash-script-not-found
As it happens, I was executing the script with the following command:
sh script.sh
Which means I was getting Dash instead of Bash.
To fix the issue I changed my code to have this:
PATH=$PATH:/usr/local/rvm/bin # Add RVM to PATH for scripting
[[ -s "/usr/local/rvm/scripts/rvm" ]] && . "/usr/local/rvm/scripts/rvm" # Load RVM function
And then I executed like this:
bash script.sh
And voilĂ ... RVM works again!

Is there a way to fix this error in terminal: -bash: HOME/.rvm/scripts/rvm: No such file or directory?

I'm new to Ruby and just installed it following the instructions on this website.
I'm not sure why, but now whenever I open terminal, I get the following error message:
-bash: HOME/.rvm/scripts/rvm: No such file or directory
Is there something I'm missing? As far as I can tell, Ruby is installed correctly and is running fine.
It looks like you put HOME in your .bash_profile instead of $HOME. You should also verify that your .rvm directory exists in your home directory. You could also check the value of $HOME by running echo $HOME in a shell, and it should return something like /home/yourname.
Note: You could change "$HOME" to "~".
This maybe solve your problem:
Before you install RVM, you can input this in your terminal to check server key:
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
Then you can input the following command to install rvm
curl -L https://get.rvm.io | bash -s stable
Just have a try~
You must source the rvm scripts so that they are available to your terminal session
source /usr/local/rvm/scripts/rvm
source ~/.rvm/scripts/rvm
You may want to add it to your .bash_profile or .bashrc file so that they are executed every time you load a terminal window like so:
$ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"' >> .bashrc

Resources