Configure RVM to print notice when using .ruby-version and .ruby-gemset - rvm

When cding into a directory containig an .rvmrc, RVM usually prompts the user about the change in ruby/gemset. For example:
Using /Users/USERNAME/.rvm/gems/ruby-2.2.1 with gemset GEMSETNAME
However, when using the preferred .ruby-version and .ruby-gemset, RVM does not print this notice, and silently changes the ruby version and gemset.
How can one configure RVM to print the typical ruby/gemset switching message when only a .ruby-version and .ruby-gemset exist in a project directory? The similar question "Not getting info message after converting rvm from .rvmrc to .ruby-version" specifies a solution that requires the presence of .rvmrc. Doing something similar with a $HOME/.rvmrc is close, but this question is asking how to get the notice without this approach, which feels like a bit of a hack.

Try this :
echo rvm_use_flag=2 >> ~/.rvmrc

Related

~RVM_PROJECT_PATH in oh-my-zsh prompt

Recently installed .oh-my-zsh on a new machine on which RVM was already installed.
Noticed that in several of my Rails project directories, I now see this instead of the actual name of the project directory:
➜ ~RVM_PROJECT_PATH git:(master)
All other behavior seems normal, but I'm finding it difficult to pin down the cause in the .oh-my-zsh configuration.
it is a bug in your Zsh, to avoid it use %1/ in PROMPT instead of %. or %C or %1~
more info: https://github.com/wayneeseguin/rvm/issues/3091
this bug should be fixed in zsh 5.0.7 ... or with this https://github.com/robbyrussell/oh-my-zsh/pull/3252
oh-my-zsh has been updated to fix this issue. Forcing an upgrade of oh-my-zsh fixed the problem for me.
$ source ~/.oh-my-zsh/tools/upgrade.sh
So, I was really struggling with this for a while. I'm not using oh-my-zsh, just straight zsh, but had the same issues. Upgraded a lot of stuff. After digging through this huge script and trying lots of suggestions, this finally worked for me:
hash -rd
I just put this before I set my variable holding the directory. My config now looks like this:
30 hash -rd
31 local promptsize=${#${():---(${PR_GEMSET}${PR_BRANCH})---()--}}
32 local pwdsize=${#${(%):-%~}}
Note that the issue was with the %~. Just thought I'd share what worked for me.
You can write this on console, my problem is solved.
PROMPT='%F{green}%1/ ${vcs_info_msg_0_}$ '

Rvm on beagleboneblack disable posix

I'm trying to run rvm on Angstrom linux on BBB.
When i try to launch rvm, i obtain:
RVM can not be run with set -o posix, please turn it off and try again.
Someone know about this?
This is a check to prevent running RVM from pure Sh shells, for proper functioning RVM requires Arrays(along other features) which are only available in Bash and Zsh.
Answer shared by #mapapis was useful to understand the reason (thanks) but I think precise steps to change the default login shell complement this and are useful.
As stated here you may need to change the login shell for your user in order to use the shell of your preference by default, in my case is bash so I made some changes the way I launch my terminal.
chsh is advised but in my particular case I'm using ConEmu Windows Terminal with Cygwin in a Windows 10 environment; sh.exe is used by default thus this RVM warning...
chsh is not available in Cygwin, so I followed this reccomendation that states that:
it is just a matter of changing (...) whatever shortcut you
are using to start cygwin to call {prefered shell here} instead
I hope this is useful. Gretings!

Unable to open the gem file on textmate "bundle open gem_name"

I want to open the gem with textmate.
So I am using following commands:
export BUNDLER_EDITOR=mate
bundle open unicorn
Error:
Could not find gem 'unicorn' in the current bundle.
Note:
1)This commands used to work perfectly and it opened the whole gem with its contents, but suddenly some thing went wrong.
2) I am using rvm to manage my gems, & when i do : $gemset list, I do see the list of gems.
3) I also tried to automate the process by putting "export BUNDLER_EDITOR=mate" inside the ~/.profile file inside my user folder.
4) When i do -> echo $EDITOR , I dont get any output
I also faced the similar problem. Although i am not a pro, but you should try to use another rvm gemset, Instructions are listed here http://beginrescueend.com/gemsets/using/

How do I ensure my jruby command line options are used when running "rails", "rake", "rspec" etc?

I currently run my Rails app using:
jruby --1.9 -J-XX:+CMSClassUnloadingEnabled -J-XX:+UseConcMarkSweepGC -J-XX:MaxPermSize=256m -S rails server
This is getting pretty old now. How can I set my Rails project up so that just running
rails server
has the same effect?
(Note: bash aliases and the like are not what I'm looking for here. I want to make the project work right, not fix my local settings)
When using RVM and a project .rvmrc, the canonical way is to set PROJECT_JRUBY_OPTS in the project .rvmrc. A bug prevented this from working for me, so use rvm head.
If not using rvm then use JRUBY_OPTS, which is the built-in way of doing it that JRuby checks (in fact, the PROJECT_JRUBY_OPTS thing ends up being converted to JRUBY_OPTS by rvm).

rvm install fails with or without rvmrc

I'm using rvmrc with the following text:
rvm_path=/local/rvm
(on Ubuntu 11.10) but trying to install gives an obscure error:
$ bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
Successfully checked out branch ''
Current branch master is up to date.
Successfully pulled (rebased) from origin
: No such file or directory
Any ideas?
You have no need at all to set $rvm_path. You're using a multi-user install. Please follow the explicit instructions for the Multi-User install at https://rvm.io and remove any existing installations, remove /etc/rvmrc, /etc/profile.d/rvm.sh, and $HOME/.rvmrc. Comment out any RVM sourcing lines in your .bash_profile, and .bashrc and log out of the machine then back in. Then reinstall correctly. Setting the rvm_path has never been a requirement of the installer UNLESS you already have a Multi-User working installation in place, and you want to attempt to use a per-user install with it. THEN you would preset the $rvm_path to $HOME/.rvm in your own $HOME/.rvmrc, log out then back in and then attempt the install again. BUT, that is not a supported installation type. Which is why 99.999% of users will not need to set rvm_path at all.
The real problem was that the git configuration for auto-converting line endings was not set correctly which prevented any installation from working. It had nothing to do with using rvmrc settings.
The fix for this is simple (and comes straight from the github help page):
$ git config --global core.autocrlf input
Line endings are important in linux and by forgetting that setting, everything the rvm-install script was pulling from github had \r\n endings. I made that change so long ago on my work machine, I didn't even remember it -- but it was not set on my home system.
I'll leave it up in case someone else has the same problem.