我使用rvm已经一年半了。
每次调用命令时都会出现rvm路径警告,但其他情况下rvm仍然正常工作。我可能已经用这个链接的说明修正了这个警告:StackOverflow - Getting “Warning! PATH is not properly set up” when doing rvm use 2.0.0 --default
这涉及到将[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"放入一个与我的bash相关的shell配置文件中。
添加一个,或者在调用链中的其他可用文件中添加太多,可能会导致这种奇怪(主要是?)美学错误:SuperUser - Why am I having / how can I fix this error: “shell_session_update: command not found”
再次开始获取rvm路径错误。我当时并不这么认为,但是回顾这个问题,我想知道我是否刚刚将fishshell从大约2.2.0更新到2.5.0,这可能会导致我进一步的实际路径错误(不是警告)……
执行rvm reset没有帮助。
执行rvm get stable --auto-dotfiles似乎对当前终端有帮助,但对其他终端没有帮助,即使在重启时也是如此。决定重新安装。
运行rvm implode。删除或注释掉所有shell配置文件中的所有rvm行。
运行RVM - Integration - Fish Shell,这里也介绍了StackOVerflow - Can't get RVM to switch rubies,其中包括先执行一些RVM - Installing RVM - Quick (guided) Install
使用这种组合:curl -sSL https://get.rvm.io | bash -s stable --rails --with-default-gems="rails haml" --with-gems="hirb"
下载了rvmfish函数。
rvm default配置添加到config.fish
问题
我的可执行文件版本错误:

⋊> ~ ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]

它是系统ruby,而不是rvm set版本:
⋊> ~ which ruby
/usr/bin/ruby

我没有bundle命令:
⋊> ~ which bundle
⋊> ~ bundle
fish: Unknown command 'bundle'
⋊> ~ functions bundle

因此,如果没有bundle帮助我安装gem,我就无法使用rails:
⋊> ~ 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.

我的rubyPATH变量似乎没有更新,如下所示。
我的问题是如何更新这些变量?类似于此链接的内容:StackOverflow - RVM doesn't set correct gem path
更多背景
⋊> ~ 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's 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/[email protected]/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/[email protected]'
export GEM_PATH='/Users/username/.rvm/gems/[email protected]:/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/[email protected]
⋊> ~ cat /Users/username/.rvm/environments/[email protected]
export PATH="/Users/username/.rvm/gems/[email protected]/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/[email protected]'
export GEM_PATH='/Users/username/.rvm/gems/[email protected]:/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/[email protected]
  - RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/username/.rvm/gems/[email protected]/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - universal-darwin-16
  - GEM PATHS:
     - /Users/username/.rvm/gems/[email protected]
     - /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/[email protected]

⋊> ~ ls /Users/username/.rvm/gems/[email protected]/
bin
cache
environment
wrappers

⋊> ~ ls /Users/username/.rvm/gems/[email protected]/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/[email protected]:/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: http://stackoverflow.com/questions/18276701/getting-warning-path-is-not-properly-set-up-when-doing-rvm-use-2-0-0-defaul
.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: http://stackoverflow.com/questions/18276701/getting-warning-path-is-not-properly-set-up-when-doing-rvm-use-2-0-0-defaul
.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-102.3
ITERM2 3.0.15标准
Fish,2.5.0版
其他东西
GEM_PATH更相关,但可能仍然适用,因为bashfish函数在内部使用bash:StackOVerflow - Need to Fix PATH in my bashrc File for RVM
简单的方法,但我需要rvm动态特性工作:StackOverflow - How to set up path for gems with the Fish shell?

最佳答案

某种解决方案
到目前为止,我几乎没有工作,通过作出改变:
grep -E '^rvm|^GEM_PATH|^GEM_HOME'
到:
grep -E '^rvm|^[^=]*PATH|^GEM_HOME'
不知道会导致什么副作用,但从rvm.fish代码来看,这似乎是缺失的。
旁白
旧版本中有^[^=]*PATH\术语,就像我的系统以前的版本一样,也可以在这里随机找到:GitHub Gist - ToniRib/rvm.fish
这是为了转义管道()字符,但我不明白为什么在单引号中需要它。我的修复特别有效,没有反斜杠,只是简单的管道字符。
非功能替代品
我也尝试了一个没有其他代码的补丁,比如这个:

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

我正在继续添加行,但仍然看到各种错误。首先,我需要“rubies”目录以获得正确版本的ruby,然后用空格修改两个gem路径以获得fish,但我仍然有问题,因此批量使用bashPATH环境变量并让rvm脚本自行完成工作是目前为止我拥有的最好的方法。

关于ruby-on-rails - RVM没有在`fish`中设置我的PATH,但是应该,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44574382/

10-16 20:29