gpt4 book ai didi

ruby-on-rails - RVM 没有在 `fish` 中设置我的 PATH,但应该是

转载 作者:数据小太阳 更新时间:2023-10-29 08:06:58 24 4
gpt4 key购买 nike

我已经使用 RVM 一年半了。

每个命令调用都有 RVM PATH 警告表面,但除此之外 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 PATH 错误。我当时并没有想到这一点,但回过头来看这个问题,我想知道我是否刚刚将我的 fish shell 从 2.2.0 左右更新到 2.5.0,这可能导致我进一步 < strong>actual PATH 错误(不是警告)...

执行 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".
  • 下载了 rvm fish 函数。
  • rvm default 配置添加到 config.fish

问题

我的 ruby 可执行文件版本错误:

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

它是系统 ruby​​,而不是 RVM-set 版本:

⋊> ~ which ruby
/usr/bin/ruby

我没有捆绑命令:

⋊> ~ 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.

我的 PATHGEM_PATH 变量似乎没有更新,如下所示。

我的问题是如何让这些变量更新?类似于此链接的内容: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/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: 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 10.12.3

iTerm2 3.0.15

fish ,版本 2.5.0

其他内容

最佳答案

某种解决方案

到目前为止,我几乎无法通过以下方式进行更改:

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

我继续向其中添加行,但仍然看到各种错误。首先,我需要正确版本的 ruby 的“rubies”目录,然后用 fish 的空格修改了两个 gem 路径,但我仍然遇到问题,所以采用 bashPATH 环境变量批发并让 rvm 脚本完成自己的工作是我迄今为止最好的。

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

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com