RVM does not set my PATH to `fish`, but it should be
I've been using RVM for a year and a half now.
Each command invocation contained the RVM PATH warning surface, but otherwise the RVM was still functioning as expected. I may have set this warning with instructions from this link: https://stackoverflow.com/a/5999497/This
involved posting [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
to one of my configuration profiles related to bash
.
Adding this or too many of the other available files in the call chain can lead to this strange (mostly?) Aesthetic error: SuperUser - Why am I having / how can I fix this error: "shell_session_update: command not found"
RVM PATH error worked again. I didn't think about it at the time, but looking back at the problem, I wonder if I only updated my shell fish
at a speed from 2.2.0 to 2.5.0, which could lead to further actual PATH (no warnings) as well ...
Execution rvm reset
didn't help.
Executing rvm get stable --auto-dotfiles
seemed to help the current terminal, but not others, even on restart. Decided to reinstall.
Ran rvm implode
. Removed or commented out all RVM lines in all shell config files.
Ran via RVM - Integration - Fish Shell , which is also covered here for a StackOverflow question , which involves doing some RVMs - Install RVM first - Quick (guided by) Install .
- Use this combination:
curl -sSL https://get.rvm.io | bash -s stable --rails --with-default-gems="rails haml" --with-gems="hirb"
. - Loaded the function
rvm
fish
. - Added
rvm default
config toconfig.fish
.
Problem
My ruby
executable is the wrong version:
⋊> ~ ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]
This is a system ruby, not a version of the RVM set:
⋊> ~ which ruby
/usr/bin/ruby
I don't have a bundle command:
⋊> ~ which bundle
⋊> ~ bundle
fish: Unknown command 'bundle'
⋊> ~ functions bundle
Thus, I cannot use Rails without the package, helping me install the gem:
⋊> ~ rails
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
My variables PATH
and GEM_PATH
don't seem to update as shown below.
My question would be to ask how to get these variables to update? Something similar to this link: StackOverflow question.
More background
⋊> ~ which rails
/usr/bin/rails
⋊> ~ functions rails
⋊> ~ ⨯
⋊> ~ head /usr/bin/rails
#!/usr/bin/ruby
# Stub rails command to load rails from Gems or print an error if not installed.
require 'rubygems'
version = ">= 0"
if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
version = $1
ARGV.shift
end
⋊> ~ which rvm
⋊> ~ ⨯
⋊> ~ ls ~/.config/fish/functions/rvm.fish
/Users/username/.config/fish/functions/rvm.fish
⋊> ~ functions rvm|head
function rvm --description 'Ruby enVironment Manager'
# run RVM and capture the resulting environment
set --local env_file (mktemp -t rvm.fish.XXXXXXXXXX);
# echo "DEBUG: env_file: $env_file"
# This finds where RVM root directory is and sources scripts/rvm from within it. Then loads RVM in a clean environment and dumps the environment variables it generates out for us to use.
bash -c 'PATH=$GEM_HOME/bin:$PATH;RVMA=$(which rvm);RVMB=$(whereis rvm | sed "s/rvm://");source $(if test $RVMA;then echo $RVMA | sed "s/\/bin\//\/scripts\//";elif test $RVMB; then echo $RVMB | sed "s/rvm/rvm\/scripts\/rvm/"; else echo ~/.rvm/scripts/rvm; fi); rvm "$@"; status=$?; env > "$0"; exit $status' $env_file $argv
# apply rvm_* and *PATH variables from the captured environment
and eval (grep -E '^rvm|^GEM_PATH|^GEM_HOME' $env_file | grep -v '_clr=' | sed '/^[^=]*PATH/s/:/" "/g; s/^/set -xg /; s/=/ "/; s/$/" ;/; s/(//; s/)//')
# needed under fish >= 2.2.0
⋊> ~ bash -c 'which rvm'
⋊> ~ bash -c 'whereis rvm'
⋊> ~ bash -c 'echo ~/.rvm/scripts/rvm;'
/Users/username/.rvm/scripts/rvm
⋊> ~ head /Users/username/.rvm/scripts/rvm
#!/usr/bin/env bash
# rvm : Ruby enVironment Manager
# https://rvm.io
# https://github.com/rvm/rvm
# partial duplication marker dkjnkjvnckbjncvbkjnvkj
# prevent from loading in sh shells
if
builtin test -n "${BASH_VERSION:-}" -o -n "${ZSH_VERSION:-}" -o -n "${KSH_VERSION:-}"
⋊> ~ rvm use
Using /Users/username/.rvm/gems/ruby-2.1.5 with gemset ux-rails3.2
⋊> ~ rvm list
rvm rubies
=* ruby-2.1.5 [ x86_64 ]
# => - current
# =* - current && default
# * - default
⋊> ~ ls /Users/username/.rvm/rubies/
default@ ruby-2.1.5/
⋊> ~ ls /Users/username/.rvm/rubies/ruby-2.1.5/
bin/ config include/ lib/ share/
⋊> ~ rvm env
export PATH="/Users/username/.rvm/gems/ruby-2.1.5@ux-rails3.2/bin:/Users/username/.rvm/gems/ruby-2.1.5@global/bin:/Users/username/.rvm/rubies/ruby-2.1.5/bin:$PATH"
export GEM_HOME='/Users/username/.rvm/gems/ruby-2.1.5@ux-rails3.2'
export GEM_PATH='/Users/username/.rvm/gems/ruby-2.1.5@ux-rails3.2:/Users/username/.rvm/gems/ruby-2.1.5@global'
export MY_RUBY_HOME='/Users/username/.rvm/rubies/ruby-2.1.5'
export IRBRC='/Users/username/.rvm/rubies/ruby-2.1.5/.irbrc'
unset MAGLEV_HOME
unset RBXOPT
export RUBY_VERSION='ruby-2.1.5'
⋊> ~ rvm env --path
/Users/username/.rvm/environments/ruby-2.1.5@ux-rails3.2
⋊> ~ cat /Users/username/.rvm/environments/ruby-2.1.5@ux-rails3.2
export PATH="/Users/username/.rvm/gems/ruby-2.1.5@ux-rails3.2/bin:/Users/username/.rvm/gems/ruby-2.1.5@global/bin:/Users/username/.rvm/rubies/ruby-2.1.5/bin:$PATH"
export GEM_HOME='/Users/username/.rvm/gems/ruby-2.1.5@ux-rails3.2'
export GEM_PATH='/Users/username/.rvm/gems/ruby-2.1.5@ux-rails3.2:/Users/username/.rvm/gems/ruby-2.1.5@global'
export MY_RUBY_HOME='/Users/username/.rvm/rubies/ruby-2.1.5'
export IRBRC='/Users/username/.rvm/rubies/ruby-2.1.5/.irbrc'
unset MAGLEV_HOME
unset RBXOPT
export RUBY_VERSION='ruby-2.1.5'
⋊> ~ rvm 2.1.5 do rvm env --path
/Users/username/.rvm/environments/ruby-2.1.5
⋊> ~ cat /Users/username/.rvm/environments/ruby-2.1.5
export PATH="/Users/username/.rvm/gems/ruby-2.1.5/bin:/Users/username/.rvm/gems/ruby-2.1.5@global/bin:/Users/username/.rvm/rubies/ruby-2.1.5/bin:$PATH"
export GEM_HOME='/Users/username/.rvm/gems/ruby-2.1.5'
export GEM_PATH='/Users/username/.rvm/gems/ruby-2.1.5:/Users/username/.rvm/gems/ruby-2.1.5@global'
export MY_RUBY_HOME='/Users/username/.rvm/rubies/ruby-2.1.5'
export IRBRC='/Users/username/.rvm/rubies/ruby-2.1.5/.irbrc'
unset MAGLEV_HOME
unset RBXOPT
export RUBY_VERSION='ruby-2.1.5'
⋊> ~ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.0.14.1
- RUBY VERSION: 2.0.0 (2015-12-16 patchlevel 648) [universal.x86_64-darwin16]
- INSTALLATION DIRECTORY: /Users/username/.rvm/gems/ruby-2.1.5@ux-rails3.2
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
- EXECUTABLE DIRECTORY: /Users/username/.rvm/gems/ruby-2.1.5@ux-rails3.2/bin
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-16
- GEM PATHS:
- /Users/username/.rvm/gems/ruby-2.1.5@ux-rails3.2
- /Users/username/.rvm/gems/ruby-2.1.5@global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
⋊> ~ gem list
bigdecimal (1.2.0)
bundler (1.7.6)
bundler-unload (1.0.2)
executable-hooks (1.3.2)
gem-wrappers (1.2.7)
hirb (0.7.3)
io-console (0.4.2)
json (1.7.7)
minitest (4.3.2)
psych (2.0.0)
rake (0.9.6)
rdoc (4.0.0)
rubygems-bundler (1.4.4)
rvm (1.11.3.9)
test-unit (2.0.0.0)
⋊> ~ rvm gemset list
gemsets for ruby-2.1.5 (found in /Users/username/.rvm/gems/ruby-2.1.5)
(default)
global
=> ux-rails3.2
⋊> ~ rvm gemset dir
/Users/username/.rvm/gems/ruby-2.1.5@ux-rails3.2
⋊> ~ ls /Users/username/.rvm/gems/ruby-2.1.5@ux-rails3.2/
bin
cache
environment
wrappers
⋊> ~ ls /Users/username/.rvm/gems/ruby-2.1.5@ux-rails3.2/bin/
⋊> ~
⋊> ~ ls /Users/username/.rvm/gems/ruby-2.1.5@global/bin/
bundle
bundler
executable-hooks-uninstaller
ruby_executable_hooks
⋊> ~ ls /Users/username/.rvm/gems/ruby-2.1.5/bin/
haml
ruby_executable_hooks
tilt
⋊> ~ echo $PATH
/usr/local/mysql/bin /usr/local/opt/coreutils/libexec/gnubin /usr/local/opt/findutils/bin /Users/username/bin /usr/local/mysql/bin /usr/local/opt/coreutils/libexec/gnubin /usr/local/opt/findutils/bin /Users/username/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin /usr/local/munki /opt/puppetlabs/bin /Applications/Wireshark.app/Contents/MacOS
⋊> ~ echo $GEM_PATH
/Users/username/.rvm/gems/ruby-2.1.5@ux-rails3.2:/Users/username/.rvm/gems/ruby-2.1.5@global
⋊> ~ cat .ruby-gemset .ruby-version
ux-rails3.2
ruby-2.1.5
⋊> ~ grep "rvm" .config/fish/config.fish .bashrc .bash_profile .profile .zshrc .mkshrc .zlogin /etc/profile /etc/bashrc
.config/fish/config.fish:# Source: /questions/77514/getting-warning-path-is-not-properly-set-up-when-doing-rvm-use-200-default
.config/fish/config.fish:rvm default;
.bashrc:# From running the command 'rvm get head ...'. Needs to be at the bottom, so no other PATH entries can change the order.
.bashrc:# Source: /questions/77514/getting-warning-path-is-not-properly-set-up-when-doing-rvm-use-200-default
.bashrc:# export PATH="$PATH:$HOME/.rvm/bin"
.bash_profile:# [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
.profile:# export PATH="$PATH:$HOME/.rvm/bin"
.profile:# [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
grep: .zshrc: No such file or directory
grep: .mkshrc: No such file or directory
grep: .zlogin: No such file or directory
⋊> ~ ls .gemrc
ls: cannot access '.gemrc': No such file or directory
⋊> ~ rvm -v; ruby -v; rails -v; echo "gem version "(gem -v); rake -V; bundle -v;
rvm 1.29.1 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io/]
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
gem version 2.0.14.1
rake, version 0.9.6
fish: Unknown command 'bundle'
Mac 10.12.3
iTerm2 3.0.15
fish version 2.5.0
Other things
- More to do with
bash
, but can still be used, because the functionfish
rvm
uses a bash inside: qaru.site/questions/2416013 / ... - Simplified approach, but I need a dynamic RVM function: stack overflow
source to share
Some solution
So far I have barely worked making the change:
grep -E '^rvm|^GEM_PATH|^GEM_HOME'
in
grep -E '^rvm|^[^=]*PATH|^GEM_HOME'
Not sure what side effects are causing, but from looking at the code rvm.fish
that seems to be missing.
Relatively
The older version had the term ^[^=]*PATH\
in it, just like the previous version of my system, and can also be found by accident here: GitHub Gist - ToniRib / rvm.fish
This means you are avoiding the pipe (|) character, but I can't see why it is needed inside single quotes. My fix works on purpose without backslashes and just characters in the string.
Non-functional alternative
I also tried the patch without any other code like this:
and set -xg GEM_PATH (echo $GEM_PATH | sed 's/ /:/g')
and set -xg PATH (echo $GEM_PATH | sed 's/:/ /g') $MY_RUBY_HOME/bin $PATH
I keep adding lines to it, but I still see various errors. First I needed the "rubies" directory for the correct version ruby
, then both gem paths were changed with spaces for fish
, and yet I am having problems, so using an environment variable bash
PATH
and rvm
script do their job better than I have so far.
source to share