Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

__rvm_unload obliterates PATH #4759

Closed
signe opened this issue Aug 19, 2019 · 1 comment · Fixed by #4760
Closed

__rvm_unload obliterates PATH #4759

signe opened this issue Aug 19, 2019 · 1 comment · Fixed by #4760

Comments

@signe
Copy link
Contributor

signe commented Aug 19, 2019

Description

Calling __rvm_unload in a script severely munges the environment, namely PATH, which makes further commands in the script impossible

Steps to reproduce

  1. rvm get master
    also occurs in 1.29.9 — regression from 1.29.8
  2. create script:
#!/bin/bash

source ~/.rvm/scripts/rvm
echo "---- BEFORE ----"
echo $PATH
echo "---- BEFORE ----"
__rvm_unload
echo "---- AFTER ----"
echo $PATH
echo "--- AFTER ----"

env
  1. run script

Expected behavior

  • Current path displayed between 'BEFORE'

  • Same path, minus the ruby-specific entries, displayed between 'AFTER'

  • Output using 1.29.8:

---- BEFORE ----
/home/user/.rvm/gems/ruby-2.6.3/bin:/home/user/.rvm/gems/ruby-2.6.3@global/bin:/home/user/.rvm/rubies/ruby-2.6.3/bin:/home/user/bin:.:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/home/user/.rvm/bin
---- BEFORE ----
---- AFTER ----
/home/user/bin:.:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
--- AFTER ----
LC_ALL=C.UTF-8
[...]

Actual behavior

$ ./test.sh
---- BEFORE ----
/home/user/.rvm/gems/ruby-2.6.3/bin:/home/user/.rvm/gems/ruby-2.6.3@global/bin:/home/user/.rvm/rubies/ruby-2.6.3/bin:/home/user/bin:.:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/home/user/.rvm/bin
---- BEFORE ----
/home/user/.rvm/scripts/functions/support: line 277: awk: command not found
/home/user/.rvm/scripts/functions/env: line 187: sort: command not found
/home/user/.rvm/scripts/functions/env: line 187: cat: command not found
/home/user/.rvm/scripts/functions/support: line 277: awk: command not found
/home/user/.rvm/scripts/functions/support: line 277: awk: command not found
/home/user/.rvm/scripts/functions/support: line 260: grep: command not found
/home/user/.rvm/scripts/functions/env: line 187: sort: command not found
/home/user/.rvm/scripts/functions/env: line 187: cat: command not found
/home/user/.rvm/scripts/functions/env: line 234: sort: command not found
/home/user/.rvm/scripts/functions/support: line 277: awk: command not found
/home/user/.rvm/scripts/functions/support: line 260: grep: command not found
/home/user/.rvm/scripts/functions/env: line 187: sort: command not found
/home/user/.rvm/scripts/functions/env: line 187: cat: command not found
---- AFTER ----
.
--- AFTER ----
./test.sh: line 12: env: command not found

Environment info

$ rvm info

ruby-2.6.3:

  system:
    uname:        "Linux dev 4.15.0-1045-aws #47-Ubuntu SMP Fri Aug 2 13:50:30 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux"
    name:         "Ubuntu"
    version:      "18.04"
    architecture: "x86_64"
    bash:         "/bin/bash => GNU bash, version 4.4.20(1)-release (x86_64-pc-linux-gnu)"
    zsh:          "/usr/bin/zsh => zsh 5.4.2 (x86_64-ubuntu-linux-gnu)"
    remote_path:  "ubuntu/18.04/x86_64"

  rvm:
    version:      "1.29.9-next (master)"
    updated:      "11 minutes 37 seconds ago"
    path:         "/home/user/.rvm"
    autolibs:     "[enable] Allow RVM to use package manager if found, install missing dependencies, install package manager (only OS X)."

  ruby:
    interpreter:  "ruby"
    version:      "2.6.3p62"
    date:         "2019-04-16"
    platform:     "x86_64-linux"
    patchlevel:   "2019-04-16 revision 67580"
    full_version: "ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]"

  homes:
    gem:          "/home/user/.rvm/gems/ruby-2.6.3"
    ruby:         "/home/user/.rvm/rubies/ruby-2.6.3"

  binaries:
    ruby:         "/home/user/.rvm/rubies/ruby-2.6.3/bin/ruby"
    irb:          "/home/user/.rvm/rubies/ruby-2.6.3/bin/irb"
    gem:          "/home/user/.rvm/rubies/ruby-2.6.3/bin/gem"
    rake:         "/home/user/.rvm/gems/ruby-2.6.3/bin/rake"

  environment:
    PATH:         "/home/user/.rvm/gems/ruby-2.6.3/bin:/home/user/.rvm/gems/ruby-2.6.3@global/bin:/home/user/.rvm/rubies/ruby-2.6.3/bin:/home/user/bin:.:/home/user/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/home/user/bin:/home/user/.rvm/bin"
    GEM_HOME:     "/home/user/.rvm/gems/ruby-2.6.3"
    GEM_PATH:     "/home/user/.rvm/gems/ruby-2.6.3:/home/user/.rvm/gems/ruby-2.6.3@global"
    MY_RUBY_HOME: "/home/user/.rvm/rubies/ruby-2.6.3"
    IRBRC:        "/home/user/.rvm/rubies/ruby-2.6.3/.irbrc"
    RUBYOPT:      ""
    gemset:       ""
@signe
Copy link
Contributor Author

signe commented Aug 19, 2019

Caused by 913b407

If there is no rvm_gems_path, then "/*" gets passed to __rvm_remove_from_path.
Needs a guard to ensure that rvm_gems_path is set before calling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants