Rvm: RVM removes traps in bash

Created on 29 Jun 2018  路  3Comments  路  Source: rvm/rvm

Description

Being sourced in RVM it removes traps set on EXIT, HUP, INT, QUIT, TERM signals.

Steps to reproduce

  1. source rvm in your bash session if it not sourced already.
  2. set trap on EXIT signal (or any other affected signal) like trap 'echo EXITING!' EXIT
  3. run trap to make sure it was set.
  4. run rvm or any of cd, popd, pushd commands (those commands was substituted with rvm's functions)
  5. run trap again to check that your trap is still set.

Expected behavior

Trap set on step 2 should remain after any rvm or cd, popd, pushd commands.

Actual behavior

trap set on step 2 dissapear.

Debug mode:

Environment info

Ubuntu 1604:

ruby-2.0.0-p648:

  system:
    uname:        "Linux appveyor-vm 4.13.0-43-generic #48~16.04.1-Ubuntu SMP Thu May 17 12:56:46 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux"
    name:         "Ubuntu"
    version:      "16.04"
    architecture: "x86_64"
    bash:         "/bin/bash => GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)"
    zsh:          " => not installed"
    remote_path:  "ubuntu/16.04/x86_64"

  rvm:
    version:      "1.29.3 (master)"
    updated:      "17 minutes 47 seconds ago"
    path:         "/home/appveyor/.rvm"
    autolibs:     "[4] Allow RVM to use package manager if found, install missing dependencies, install package manager (only OS X)."

  ruby:
    interpreter:  "ruby"
    version:      "2.0.0p648"
    date:         "2015-12-16"
    platform:     "x86_64-linux"
    patchlevel:   "2015-12-16 revision 53162"
    full_version: "ruby 2.0.0p648 (2015-12-16 revision 53162) [x86_64-linux]"

  homes:
    gem:          "/home/appveyor/.rvm/gems/ruby-2.0.0-p648"
    ruby:         "/home/appveyor/.rvm/rubies/ruby-2.0.0-p648"

  binaries:
    ruby:         "/home/appveyor/.rvm/rubies/ruby-2.0.0-p648/bin/ruby"
    irb:          "/home/appveyor/.rvm/rubies/ruby-2.0.0-p648/bin/irb"
    gem:          "/home/appveyor/.rvm/rubies/ruby-2.0.0-p648/bin/gem"
    rake:         "/home/appveyor/.rvm/rubies/ruby-2.0.0-p648/bin/rake"

  environment:
    PATH:         "/usr/lib/jvm/java-9-openjdk-amd64/bin:/home/appveyor/.rvm/gems/ruby-2.0.0-p648/bin:/home/appveyor/.rvm/gems/ruby-2.0.0-p648@global/bin:/home/appveyor/.rvm/rubies/ruby-2.0.0-p648/bin:/home/appveyor/.gvm/bin:/home/appveyor/bin:/home/appveyor/.local/bin:/home/appveyor/.gvm/bin:/home/appveyor/.nvm/versions/node/v4.9.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/appveyor/.dotnet/tools:/home/appveyor/.rvm/bin:/home/appveyor/.rvm/bin:/opt/mssql-tools/bin"
    GEM_HOME:     "/home/appveyor/.rvm/gems/ruby-2.0.0-p648"
    GEM_PATH:     "/home/appveyor/.rvm/gems/ruby-2.0.0-p648:/home/appveyor/.rvm/gems/ruby-2.0.0-p648@global"
    MY_RUBY_HOME: "/home/appveyor/.rvm/rubies/ruby-2.0.0-p648"
    IRBRC:        "/home/appveyor/.rvm/rubies/ruby-2.0.0-p648/.irbrc"
    RUBYOPT:      ""
    gemset:       ""

Also reproducible on Mac with bash-3.2:

system:

  system:
    uname:        "Darwin MacBook-Pro-Vasily.local 17.6.0 Darwin Kernel Version 17.6.0: Tue May  8 15:22:16 PDT 2018; root:xnu-4570.61.1~1/RELEASE_X86_64 x86_64"
    name:         "OSX"
    version:      "10.13"
    architecture: "x86_64"
    bash:         "/bin/bash => GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin17)"
    zsh:          "/bin/zsh => zsh 5.3 (x86_64-apple-darwin17.0)"
    remote_path:  "osx/10.13/x86_64"

  rvm:
    version:      "1.29.3 (master)"
    updated:      "30 seconds ago"
    path:         "/Users/wasa/.rvm"
    autolibs:     "[4] Allow RVM to use package manager if found, install missing dependencies, install package manager (only OS X)."

  homes:
    gem:          "not set"
    ruby:         "not set"

  binaries:
    ruby:         "/usr/bin/ruby"
    irb:          "/usr/bin/irb"
    gem:          "/usr/bin/gem"
    rake:         "/usr/bin/rake"

  environment:
    PATH:         "/Users/wasa/google-cloud-sdk/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Xamarin Workbooks.app/Contents/SharedSupport/path-bin:/Users/wasa/bin/:/Users/wasa/.rvm/bin:/Users/wasa/.rvm/bin"
    GEM_HOME:     ""
    GEM_PATH:     ""
    MY_RUBY_HOME: ""
    IRBRC:        ""
    RUBYOPT:      ""
    gemset:       ""

Most helpful comment

@mpapis i can still repro this issue using the steps mentioned in my previous comment, both inside a docker container and on an Ubuntu 16.04 host. Is there a workaround that can be used here? Also, is this issue marked resolved ?

All 3 comments

@mpapis @Wasapl is this fix available in the master version of rvm. This is still giving the same results for me. The only difference is that im trying out the exact steps inside of a docker container, not sure if that really matters here.

Steps to repro

  • docker run -it library/ruby:2.3.7 /bin/bash
  • install rvm using \curl -sSL https://get.rvm.io | bash
$ rvm version
rvm 1.29.4 (master) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
$ trap 'echo EXITING!' EXIT
$ trap
trap -- 'echo EXITING!' EXIT
$ cd .
$ trap
< nothing here>

thanks in advance

@mpapis i can still repro this issue using the steps mentioned in my previous comment, both inside a docker container and on an Ubuntu 16.04 host. Is there a workaround that can be used here? Also, is this issue marked resolved ?

Hi
Any updates on this ?

Was this page helpful?
0 / 5 - 0 ratings