chruby icon indicating copy to clipboard operation
chruby copied to clipboard

Auto switching does not work with latest release of elementary OS

Open AndrewVos opened this issue 7 years ago • 10 comments

Elementary comes with some setup in .bashrc which sets up it's own hooks.

I've included the part of the .bashrc where the hooks are setup, and added chruby_auto in there as a workaround.

https://gist.github.com/AndrewVos/4ec760fbef47760547ba8e8e6a9958c2

AndrewVos avatar Nov 21 '16 14:11 AndrewVos

preexec_functions is a zsh special variable and doesn't work under bash unless there's a trap DEBUG setup which emulates that behavior.

(Might want to post output of echo $SHELL)

skull-squadron avatar Nov 29 '16 01:11 skull-squadron

Please paste the output of the bug_report.sh script so we can get some diagnostics.

postmodern avatar Dec 04 '16 06:12 postmodern

@postmodern, thanks:

## System

    Linux vos 4.4.0-47-generic #68-Ubuntu SMP Wed Oct 26 19:39:52 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
    GNU bash, version 4.3.46(1)-release (x86_64-pc-linux-gnu) [/bin/bash]
    ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-linux] [/home/vos/.rubies/ruby-2.3.3/bin/ruby]
    Bundler version 1.13.6 [/home/vos/.gem/ruby/2.3.3/bin/bundle]
    chruby version 0.3.9 [/usr/local/bin/chruby-exec]

## Environment

    CHRUBY_VERSION=0.3.9
    SHELL=/bin/bash
    PATH=/home/andrew/Nim/bin:/usr/local/heroku/bin:/home/vos/gopath/bin:/home/vos/.gem/ruby/2.3.3/bin:/home/vos/.rubies/ruby-2.3.3/lib/ruby/gems/2.3.0/bin:/home/vos/.rubies/ruby-2.3.3/bin:/home/andrew/Nim/bin:/usr/local/heroku/bin:/home/vos/gopath/bin:/home/vos/bin:/home/vos/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/local/go/bin:/home/vos/dotfiles/scripts:/home/vos/dotfiles/git-scripts:/usr/local/go/bin:/home/vos/dotfiles/scripts:/home/vos/dotfiles/git-scripts
    HOME=/home/vos
    RUBIES=(/home/vos/.rubies/ruby-2.1.10 /home/vos/.rubies/ruby-2.3.1 /home/vos/.rubies/ruby-2.3.3)
    RUBY_ROOT=/home/vos/.rubies/ruby-2.3.3
    RUBY_VERSION=2.3.3
    RUBY_ENGINE=ruby
    RUBY_AUTO_VERSION=ruby-2.3.3
    RUBYLIB=
    RUBYOPT=
    RUBYPATH=
    RUBYSHELL=
    GEM_ROOT=/home/vos/.rubies/ruby-2.3.3/lib/ruby/gems/2.3.0
    GEM_HOME=/home/vos/.gem/ruby/2.3.3
    GEM_PATH=/home/vos/.gem/ruby/2.3.3:/home/vos/.rubies/ruby-2.3.3/lib/ruby/gems/2.3.0

## Hooks

    trap -- '' SIGTSTP
    trap -- '' SIGTTIN
    trap -- '' SIGTTOU
    trap -- '[[ "$BASH_COMMAND" != "$PROMPT_COMMAND" ]] && chruby_auto' DEBUG

## .ruby-version

    ruby-2.3.3

## Aliases

    alias b='bundle exec'
    alias ll='ls -ahlF --color=auto'
    alias ls='ls -1 -G --color=auto'

AndrewVos avatar Dec 04 '16 20:12 AndrewVos

@steakknife This is not bash.

AndrewVos avatar Dec 04 '16 20:12 AndrewVos

Worth noting that there's a workaround in that gist I added ^

AndrewVos avatar Dec 04 '16 20:12 AndrewVos

I am also having problems. I need to run exec bash all the time. chruby does not even recognize I have set a value to a .ruby-version file. First I need to exec shell or manually choose the ruby version I want to use.

Works fine on my Mac, though. I also am researching what is going on and started a stackexchange thread. https://elementaryos.stackexchange.com/questions/11439/i-need-to-run-exec-bash-to-accsess-jekyll-or-ruby-for-example

@danrabbit could lend a hand maybe?

bigfatbird avatar Apr 15 '17 20:04 bigfatbird

@bigfatbird Have you tried my workaround?

AndrewVos avatar May 22 '17 09:05 AndrewVos

@steakknife whoops just read my comment above... I meant to say "this is not zsh".

AndrewVos avatar May 22 '17 09:05 AndrewVos

[~] ∞ echo $SHELL
/bin/bash

AndrewVos avatar May 22 '17 09:05 AndrewVos

This also works as a workaround in .bashrc

preexec_functions+=(chruby_auto)                                                                                                                                                                                                           

AndrewVos avatar May 22 '17 09:05 AndrewVos