RVM's auto-detect Ruby version via repo files feature is not working in VSCode login shell terminal - ruby

RVM has a feature to detect and use the correct Ruby version based on e.g. a .ruby-version file in the repo. This requires a login shell which I have enabled in VSCode via:
"terminal.integrated.shell.linux": "bash",
"terminal.integrated.shellArgs.linux": ["--login"],
However the feature isn't working by default, I have to cd . every time I open the terminal as if it is not a login shell.
There's a similar issue about new tabs in a gnome shell: https://github.com/rvm/rvm/issues/2519
I wonder if anyone else ran into this and whether this might be an issue with VSCode or RVM?

The reason this doesn't work by default is because rvm hooks the cd command in the shell to setup the ruby/gem paths for your project and there's no cd issued to the shell by the VS Code terminal opening.
I was able to resolve this issue on my Linux system by adding the login setup as suggested in the question and then adding a simple cd . at the end of my ~/.bash_profile after the section where RVM is actually set up.
Doing this results in rvm properly adjusting the paths in the VS Code terminal.

This may be a workaround..
Add this in vs
"terminal.integrated.shellArgs.linux": [
"cd ."
],

Related

Bash CD commands outputting environment variables

I was trying to install ruby and makeFile along with rvm in windows but after their installation bash cd commands is outputting wired things on console.
I have uninstalled ruby and rest of the software but the issue still persist.
I deleted .rvm and .uru folder in c>Users>UserName and now the bash is working as expected.

Git Bash build doesn't work from terminal in VS Code

I have a fresh install of Windows 10 - 64bit
MinGW - To install gcc
Git 2.15.1.4 (64 bit )
VSCode 1.20 (64 bit)
The command I am using is:
g++ --version
It doesn't work from using the terminal inside VSCode.
However running bash window outside of VSCode, it works fine. Anybody know any suggestions on how to fix it?
GitBash Terminal
GitBash In VSCode
Thanks,
Ciaran
Compare the PATH from your bash outside VSCode:
echo $PATH
And make sure to get the same PATH in your bash within VSCode:
export PATH=/the/path/you/see/in/the/previous/step
Once this test is working, check in your VSCode bash where your $HOME is, and modify your ~/.bashrc in order to set that PATH, as advised in Microsoft/vscode issue 24989.
The OP adds in the comments:
after leaving and coming back to it the next day. It is now working.... Must of needed a restart or something?
This is expected: if the PATH was modified first, the existing process did not inherit immediately that change. Closing/re-oppening everything would work however.

bash __git_ps1 command not found

I am a beginner trying to setup a developer environment on my new Mac following the steps from this link: http://vanderveer.be/setting-up-my-perfect-developer-environment-on-osx-10-8-mountain-lion-10-8-2-final-edition/.
After executing the files from git, my terminal window now shows:
rbenv: version `1.9.3-p194' not installed
-bash: __git_ps1: command not found
The first line only shows when I open a new terminal window, while the second shows everytime I press return no matter what I type into the terminal.
I have read through many questions on stackoverflow and tried to mimic their solutions to no avail. I think I've made a mistake in installing the package from git as I am not so experienced and I think now I may have messed up the configurations, and was also wondering if there is any way to go back to default settings for bash?
Many thanks!
Allen
If you've not installed a newer version of Git on your Mac, start by doing that. You can grab the download from here: http://git-scm.com/download
Once it's installed, you should source git-completion.sh and git-prompt.sh from your ~/.profile (or ~/.bashrc, if you have it):
source /usr/local/git/contrib/completion/git-completion.bash
source /usr/local/git/contrib/completion/git-prompt.sh
That should fix the __git_ps1 error.
I'm not a Rubyist, but the rbenv error is coming from the fact that the setup in the dotfiles you are following is trying to set the default Ruby version to "1.9.3-p194". The rbenv tool is there to make a number of different Ruby versions available, but you have to install them first. In your case, I think you need to run this:
rbenv install 1.9.3-p194
After that, the version will be available, and you shouldn't see the warning anymore.

RVM not changing ruby version on cd (with bash-it)

I've installed bash-it recently and I noticed it broken RVM. When I enter a project directory, the ruby version is not changed (not matter if I use .rvmrc or .ruby-version). However, when I enter a project directory and then open a new tab/window in terminal, ruby version is changed. I tested it in Konsole and Gnome Terminal. I keep bash-it configuration in .bash_profile and I'm loading it in the end of .bashrc. Any ideas for the reason for such a strange behaviour?
EDIT: I tried to start bash as a login shell, but it doesn't work.

I'm getting "RVM is not a function" error on Mac OS X, and no posted solutions work

I'm on Mac OS x 10.8.2 ("Mountain Lion"), and I successfully installed RVM 1.17.8 and its dependencies. I'm able to use it to install Ruby versions using rvm install 1.9.2, but I can't execute rvm use <version> without getting this error:
RVM is not a function, selecting rubies with 'rvm use ...' will not work.
You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for a example.
I have the following in ~/.bash_profile, which I have set to run, using source ~/.bash_profile, whenever a terminal window is launched:
export SVN_EDITOR=vim
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
[ -r ~/.bashrc ] && source ~/.bashrc
I've tried running source ~/.rvm/scripts/rvm, which runs without returning an error, but I still get the "RVM is not a function" error when I try to use RVM to set the Ruby version within the terminal session.
I also tried uninstalling and reinstalling RVM using rvm implode. I've run out of ideas and I can't seem to find any more solutions online. Help?
Make sure your shell initialization files are set up properly:
rvm get head --auto-dotfiles
Then go to your terminal emulator preferences and enable login shell, sometimes it it required to use /bin/bash --login.
Also make sure to fully close terminal and open it fresh after changing the setting.
The solution ended up being on the RVM Help & Support page, in the ".bash_profile not being loaded on OSX" section. It seems that the issue was that I had my terminal set to open with the "default login shell" and when I changed it to instead open with the command "/usr/bash" in Preferences/Setup, "source ~/.rvm/scripts/rvm" started working, and rvm is now being recognized as a function.
look for .profile, if exists, remove it! loof for .zshrc, if exists, remove it! Now, use vi to edit your .bash_profile, add this line
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
Now, close all console services and open again, make a test using
$ rvm gemset use global
Work fine for me!

Resources