Giter VIP home page Giter VIP logo

chruby-fish's Introduction

chruby-fish

chruby re-implemented for the Fish shell. You do not need the original chruby installed.

CI

Install

wget -O chruby-fish-1.0.0.tar.gz https://github.com/JeanMertz/chruby-fish/archive/v1.0.0.tar.gz
tar -xzvf chruby-fish-1.0.0.tar.gz
cd chruby-fish-1.0.0/
sudo make install

# You might want to set this too so that fish autoloads correctly:
set -U XDG_DATA_DIRS /usr/local/share

Homebrew

chruby-fish can also be installed with homebrew:

brew install chruby-fish

Or the absolute latest chruby-fish can be installed from source:

brew install chruby-fish --HEAD

Arch Linux

chruby-fish is included in the AUR:

yay -S chruby-fish

Fish version support

This package is tested against HEAD and the latest stable version of fish.

Configuration

The chruby function is in your autoload path, so you don't need to configure it.

Homebrew uses different paths for Intel and Apple Silicon based Macs, you should configure your config.fish file accordingly. More about it here.

Auto-switching is enabled by default, set CHRUBY_AUTO_DISABLE=1 if you don't want that.

For more general instructions, see the chruby documentation.

Default Ruby

To select the default Ruby, simply edit ~/.ruby-version, e.g.:

echo "ruby-3.1.2" > ~/.ruby-version

License

Released under the MIT license.

Copyright, 2013, by Jean Mertz [email protected].

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

chruby-fish's People

Contributors

alexebird avatar andrewvos avatar b0go avatar bjeanes avatar bouk avatar databus23 avatar davidegrayson avatar dejan avatar eterps avatar ezkl avatar havenwood avatar ioquatix avatar jc00ke avatar jeanmertz avatar julienxx avatar mpapis avatar mrkcor avatar postmodern avatar pushcx avatar rosstimson avatar shireeshj avatar skorfmann avatar spastorino avatar steveklabnik avatar tenderlove avatar tmatilai avatar tsujigiri avatar waydotnet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

chruby-fish's Issues

New release?

It'd be great if a release could go out that contains 76ff28a

chruby-fish is great, thanks!

Prompt errors when no ruby version is specified for auto switching

With chruby-fish (HEAD) installed I get the following error when cd'ing to any directory which is not home or a subdirectory of home

> cd /
fish: Unknown command 'grep'
/usr/local/Cellar/fish/2.6.0/share/fish/functions/grep.fish (line 1):
command grep --color=auto $argv
        ^
in function 'grep'
	called on line 36 of file /usr/local/Cellar/fish/2.6.0/share/fish/functions/seq.fish
	with parameter list '-E ^-?[0-9]*([0-9]*|\.[0-9]+)$'

in function '__fish_fallback_seq'
	called on line 7 of file /usr/local/Cellar/fish/2.6.0/share/fish/functions/seq.fish
	with parameter list '5'

in function 'seq'
	called on line 71 of file /usr/local/share/chruby/chruby.fish
	with parameter list '5'

in command substitution
	called on line 69 of file /usr/local/share/chruby/chruby.fish

in function 'chruby_reset'
	called on line 70 of file /usr/local/share/chruby/auto.fish

in function 'chruby_auto'
	called on standard input

in event handler: handler for generic event 'fish_prompt'

/usr/local/share/chruby/chruby.fish (line 18): Invalid index value
    set -q $unset_vars[$i]; and set -e $unset_vars[$i]; or true
                        ^
in function 'chruby_reset'
	called on line 70 of file /usr/local/share/chruby/auto.fish

in function 'chruby_auto'
	called on standard input

in event handler: handler for generic event 'fish_prompt'

fish: Unknown command 'hostname'
fish:
hostname|cut -d . -f 1
^
in command substitution
	called on standard input

in command substitution
	called on standard input

My setup suddenly stopped working - won't update $PATH variable

chruby-fish suddenly stopped working for me ... I'm not sure what changed on my system or what triggered it. And I'm having a hard time debugging it! Can you help me figure out what is going wrong ?

Here is an example of what's happening using fish:

~ ruby -v
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
~ source /usr/local/share/chruby/chruby.fish
~ chruby --version
chruby: 0.3.9
chruby-fish: 0.8.1
~ chruby
   ruby-2.3.0
   ruby-2.4.4
   ruby-2.5.0
~ chruby 2.4.4
~ ruby -v
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
~ echo $PATH
/usr/local/bin /usr/bin /bin /usr/sbin /sbin 

As you can see above the environmental variables are not being updated -- when I switch my shell to bash, however, everything works as expected.

here is an example using bash

:~$ ruby -v
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
:~$ source /usr/local/share/chruby/chruby.sh
:~$ chruby --version
chruby: 0.3.9
:~$ chruby
   ruby-2.3.0
   ruby-2.4.4
   ruby-2.5.0
:~$ chruby 2.4.4
:~$ ruby -v
ruby 2.4.4p296 (2018-03-28 revision 63013) [x86_64-darwin17]
:~$ echo $PATH
/Users/damon/.gem/ruby/2.4.4/bin:/Users/damon/.rubies/ruby-2.4.4/lib/ruby/gems/2.4.0/bin:/Users/damon/.rubies/ruby-2.4.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

workaround

For now I've had to copy the $PATH output from the bash shell and create an alias in fish to load the correct ruby $PATH -- this allows me to use the different rubies ... however, as you can imagine, this is not ideal.

Any ideas about how I can go about sorting what went wrong ? I've tried removing and reinstalling view homebrew but no luck.

Thanks.

PS - I think the only thing I installed between when it was and was not working is VMWare Fusion; which did add a line to the $PATH ... but it was in both bash and fish so I'm not sure why one would work and the other not.

chruby cannot successfully switch to mruby-3.0.0 under Fish

Description

chruby cannot successfully switch to mruby-3.0.0 under Fish, but seems to work as expected under Bash in spite of raising a Ruby NoMethodError exception when attempting to change rubies. The latter issue was raised upstream with chruby.

Steps To Reproduce

Steps to reproduce the bug:

  1. ruby-install mruby-3.0.0
  2. exec fish --login, which is required for chruby to pick up the newly installed Ruby
  3. chruby mruby or chruby mruby-3.0.0
  4. chruby, which shows that the selected Ruby hasn't changed

Expected Behavior

chruby-fish should not halt execution or report a different exit status than chruby itself. If the Ruby exception is not a show-stopper, then chruby-fish should not halt execution when the Bash version of chruby continues, and should change to the requested Ruby under the same circumstances that the Bash version of chruby does.

Actual Behavior

My default Ruby is currently set to Ruby 3.1.2. ruby-install mruby-3.0.0 succeeds without error. Under Bash, the following error still occurs:

$ bash --version | head -1
GNU bash, version 5.1.16(1)-release (x86_64-apple-darwin20.6.0)

$ chruby mruby
trace (most recent call last):
-:1: undefined method 'defined?' (NoMethodError)

but the current Ruby is changed to mruby-3.0.0, RUBY_ROOT is set correctly, and mirb is executable. However, under Fish, the script exits non-zero. This error stops chruby from switching the current Ruby, and RUBY_ROOT and other variables remain unchanged.

~> bash -c 'echo $BASH_VERSION'
5.1.16(1)-release

~> echo $FISH_VERSION 
3.4.1

~> chruby mruby
trace (most recent call last):
-:1: undefined method 'defined?' (NoMethodError)

[I] user@localhost ~ [1]> chruby
   jruby-9.3.4.0
   mruby-3.0.0
   ruby-2.7.0
   ruby-2.7.5
   ruby-3.0.3
   ruby-3.0.4
   ruby-3.1.0
   ruby-3.1.1
 * ruby-3.1.2
   ruby-3.2.0-preview1
   truffleruby-22.1.0
   truffleruby-graalvm-22.1.0

~> chruby --version
chruby: 0.3.9
chruby-fish: 0.8.2

 ~> gem env | sed "s/$(id -un)/\$LOGNAME/g"
RubyGems Environment:
  - RUBYGEMS VERSION: 3.3.7
  - RUBY VERSION: 3.1.2 (2022-04-12 patchlevel 20) [x86_64-darwin20]
  - INSTALLATION DIRECTORY: /Users/$LOGNAME/.gem/ruby/3.1.2
  - USER INSTALLATION DIRECTORY: /Users/$LOGNAME/.gem/ruby/3.1.0
  - RUBY EXECUTABLE: /Users/$LOGNAME/.rubies/ruby-3.1.2/bin/ruby
  - GIT EXECUTABLE: /usr/local/bin/git
  - EXECUTABLE DIRECTORY: /Users/$LOGNAME/.gem/ruby/3.1.2/bin
  - SPEC CACHE DIRECTORY: /Users/$LOGNAME/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /Users/$LOGNAME/.rubies/ruby-3.1.2/etc
  - RUBYGEMS PLATFORMS:
     - ruby
     - x86_64-darwin-20
  - GEM PATHS:
     - /Users/$LOGNAME/.gem/ruby/3.1.2
     - /Users/$LOGNAME/.rubies/ruby-3.1.2/lib/ruby/gems/3.1.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - :sources => ["https://rubygems.org"]
     - :concurrent_downloads => 4
     - "gem" => "--env-shebang --minimal-deps --no-document --patch --suggestions --wrappers"
  - REMOTE SOURCES:
     - https://rubygems.org
  - SHELL PATH:
     - /Users/$LOGNAME/.gem/ruby/3.1.2/bin
     - /Users/$LOGNAME/.rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/bin
     - /Users/$LOGNAME/.rubies/ruby-3.1.2/bin
     - /Users/$LOGNAME/bin
     - /Users/$LOGNAME/perl5/bin
     - /usr/local/bin
     - /usr/local/sbin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /opt/puppetlabs/pdk/bin
     - /opt/X11/bin
     - /opt/puppetlabs/bin
     - /Library/Apple/usr/bin
     - /Users/$LOGNAME/bin
     - /Users/$LOGNAME/perl5/bin
     - /usr/local/sbin
     - /usr/local/opt/openssl/bin
     - /usr/local/Cellar/[email protected]/3.9.12/libexec/bin
     - /usr/local/opt/[email protected]/bin
     - /usr/local/opt/openssl@3/bin
     - /Users/$LOGNAME/.local/bin/jetbrains
     - /usr/local/opt/[email protected]/bin
     - /usr/local/opt/gcc/bin
     - /Users/$LOGNAME/node_modules/bin
     - /Users/$LOGNAME/go/bin

fish-specific PATH changes get lost when changing ruby versions

My PATH variable is not being properly maintained when chruby-fish changes ruby versions. In particular, anything added to the PATH variable in config.fish gets lost.

In the example below, /home/tbass/chruby_test/bin is an empty dir that I added to my path just to illustrate the problem.

tbass@stardust ~> env | grep "^PATH="
PATH=/home/tbass/chruby_test/bin:/usr/local/sbin:/usr/local/bin:/usr/bin
tbass@stardust ~> chruby 2.4.0
tbass@stardust ~> env | grep "^PATH="
PATH=/home/tbass/.gem/ruby/2.4.0/bin:/home/tbass/.rubies/ruby-2.4.0/lib/ruby/gems/2.4.0/bin:/home/tbass/.rubies/ruby-2.4.0/bin:/usr/local/sbin:/usr/local/bin:/usr/bin
tbass@stardust ~> chruby system
tbass@stardust ~> env | grep "^PATH="
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin
tbass@stardust ~> 

Not that after changing to 2.4.0, /home/tbass/chruby_test/bin is no longer in the PATH, nor is it there after returning to system ruby.

Here is my config.fish:

source /usr/local/share/chruby/chruby.fish
source /usr/local/share/chruby/auto.fish

set -x PATH /home/tbass/chruby_test/bin $PATH

I played around a bit and I believe the problem is that when the bchruby function invokes bash, it invokes a login shell, which resets the PATH according to the bash login process instead of using the PATH that was passed in as part of the environment. So when it extracts the PATH back out, it has done more than just apply chruby's modification to the current PATH. Instead, it has applied chruby's modification to whatever the bash login PATH is, abandoning the original PATH altogether.

When I remove the -l option to the bash call, it seems to work fine for me, but I don't know if there are any other implications for removing it.

Unknown commands with 0.7.1

I just upgraded to 0.7.1 from 0.6.0 after seeing #13 was fixed by #23, but now I'm seeing a bunch of Unknown command errors 😦

fish: Unknown command 'string trim -r -c/ /home/jesse/.rubies/rbx'
/usr/local/share/chruby/chruby.fish (line 1): string trim -r -c/ "$dir"
                                              ^
in command substitution
    called on line 126 of file /usr/local/share/chruby/chruby.fish

in function “chruby”
    called on line 38 of file ~/.config/fish/config.fish
    with parameter list “2.2.3”

from sourcing file ~/.config/fish/config.fish
    called during startup

fish: Unknown command 'string split -m1 -r /'
/usr/local/share/chruby/chruby.fish (line 1): string split -m1 -r / $dir | tail -n1
                                              ^
in command substitution
    called on line 126 of file /usr/local/share/chruby/chruby.fish

in function “chruby”
    called on line 38 of file ~/.config/fish/config.fish
    with parameter list “2.2.3”

from sourcing file ~/.config/fish/config.fish
    called during startup

fish: Unknown command 'string match -qi *2.2.3* '
/usr/local/share/chruby/chruby.fish (line 19):           string match -qi "*$argv[1]*" "$ruby"; and set match "$dir"
                                                         ^
in function “chruby”
    called on line 38 of file ~/.config/fish/config.fish
    with parameter list “2.2.3”

from sourcing file ~/.config/fish/config.fish
    called during startup

fish: Unknown command 'string trim -r -c/ /home/jesse/.rubies/rubinius'
/usr/local/share/chruby/chruby.fish (line 1): string trim -r -c/ "$dir"
                                              ^
in command substitution
    called on line 126 of file /usr/local/share/chruby/chruby.fish

in function “chruby”
    called on line 38 of file ~/.config/fish/config.fish
    with parameter list “2.2.3”

from sourcing file ~/.config/fish/config.fish
    called during startup

fish: Unknown command 'string split -m1 -r /'
/usr/local/share/chruby/chruby.fish (line 1): string split -m1 -r / $dir | tail -n1
                                              ^
in command substitution
    called on line 126 of file /usr/local/share/chruby/chruby.fish

in function “chruby”
    called on line 38 of file ~/.config/fish/config.fish
    with parameter list “2.2.3”

from sourcing file ~/.config/fish/config.fish
    called during startup

fish: Unknown command 'string match -qi *2.2.3* '
/usr/local/share/chruby/chruby.fish (line 19):           string match -qi "*$argv[1]*" "$ruby"; and set match "$dir"
                                                         ^
in function “chruby”
    called on line 38 of file ~/.config/fish/config.fish
    with parameter list “2.2.3”

from sourcing file ~/.config/fish/config.fish
    called during startup

fish: Unknown command 'string trim -r -c/ /home/jesse/.rubies/ruby-2.1.2'
/usr/local/share/chruby/chruby.fish (line 1): string trim -r -c/ "$dir"
                                              ^
in command substitution
    called on line 126 of file /usr/local/share/chruby/chruby.fish

in function “chruby”
    called on line 38 of file ~/.config/fish/config.fish
    with parameter list “2.2.3”

from sourcing file ~/.config/fish/config.fish
    called during startup

fish: Unknown command 'string split -m1 -r /'
/usr/local/share/chruby/chruby.fish (line 1): string split -m1 -r / $dir | tail -n1
                                              ^
in command substitution
    called on line 126 of file /usr/local/share/chruby/chruby.fish

in function “chruby”
    called on line 38 of file ~/.config/fish/config.fish
    with parameter list “2.2.3”

from sourcing file ~/.config/fish/config.fish
    called during startup

fish: Unknown command 'string match -qi *2.2.3* '
/usr/local/share/chruby/chruby.fish (line 19):           string match -qi "*$argv[1]*" "$ruby"; and set match "$dir"
                                                         ^
in function “chruby”
    called on line 38 of file ~/.config/fish/config.fish
    with parameter list “2.2.3”

from sourcing file ~/.config/fish/config.fish
    called during startup

fish: Unknown command 'string trim -r -c/ /home/jesse/.rubies/ruby-2.1.5'
/usr/local/share/chruby/chruby.fish (line 1): string trim -r -c/ "$dir"
                                              ^
in command substitution
    called on line 126 of file /usr/local/share/chruby/chruby.fish

in function “chruby”
    called on line 38 of file ~/.config/fish/config.fish
    with parameter list “2.2.3”

from sourcing file ~/.config/fish/config.fish
    called during startup

fish: Unknown command 'string split -m1 -r /'
/usr/local/share/chruby/chruby.fish (line 1): string split -m1 -r / $dir | tail -n1
                                              ^
in command substitution
    called on line 126 of file /usr/local/share/chruby/chruby.fish

in function “chruby”
    called on line 38 of file ~/.config/fish/config.fish
    with parameter list “2.2.3”

from sourcing file ~/.config/fish/config.fish
    called during startup

fish: Unknown command 'string match -qi *2.2.3* '
/usr/local/share/chruby/chruby.fish (line 19):           string match -qi "*$argv[1]*" "$ruby"; and set match "$dir"
                                                         ^
in function “chruby”
    called on line 38 of file ~/.config/fish/config.fish
    with parameter list “2.2.3”

from sourcing file ~/.config/fish/config.fish
    called during startup

fish: Unknown command 'string trim -r -c/ /home/jesse/.rubies/ruby-2.2.2'
/usr/local/share/chruby/chruby.fish (line 1): string trim -r -c/ "$dir"
                                              ^
in command substitution
    called on line 126 of file /usr/local/share/chruby/chruby.fish

in function “chruby”
    called on line 38 of file ~/.config/fish/config.fish
    with parameter list “2.2.3”

from sourcing file ~/.config/fish/config.fish
    called during startup

fish: Unknown command 'string split -m1 -r /'
/usr/local/share/chruby/chruby.fish (line 1): string split -m1 -r / $dir | tail -n1
                                              ^
in command substitution
    called on line 126 of file /usr/local/share/chruby/chruby.fish

in function “chruby”
    called on line 38 of file ~/.config/fish/config.fish
    with parameter list “2.2.3”

from sourcing file ~/.config/fish/config.fish
    called during startup

fish: Unknown command 'string match -qi *2.2.3* '
/usr/local/share/chruby/chruby.fish (line 19):           string match -qi "*$argv[1]*" "$ruby"; and set match "$dir"
                                                         ^
in function “chruby”
    called on line 38 of file ~/.config/fish/config.fish
    with parameter list “2.2.3”

from sourcing file ~/.config/fish/config.fish
    called during startup

fish: Unknown command 'string trim -r -c/ /home/jesse/.rubies/ruby-2.2.3'
/usr/local/share/chruby/chruby.fish (line 1): string trim -r -c/ "$dir"
                                              ^
in command substitution
    called on line 126 of file /usr/local/share/chruby/chruby.fish

in function “chruby”
    called on line 38 of file ~/.config/fish/config.fish
    with parameter list “2.2.3”

from sourcing file ~/.config/fish/config.fish
    called during startup

fish: Unknown command 'string split -m1 -r /'
/usr/local/share/chruby/chruby.fish (line 1): string split -m1 -r / $dir | tail -n1
                                              ^
in command substitution
    called on line 126 of file /usr/local/share/chruby/chruby.fish

in function “chruby”
    called on line 38 of file ~/.config/fish/config.fish
    with parameter list “2.2.3”

from sourcing file ~/.config/fish/config.fish
    called during startup

fish: Unknown command 'string match -qi *2.2.3* '
/usr/local/share/chruby/chruby.fish (line 19):           string match -qi "*$argv[1]*" "$ruby"; and set match "$dir"
                                                         ^
in function “chruby”
    called on line 38 of file ~/.config/fish/config.fish
    with parameter list “2.2.3”

from sourcing file ~/.config/fish/config.fish
    called during startup

fish: Unknown command 'string trim -r -c/ /home/jesse/.rubies/ruby-2.3.0'
/usr/local/share/chruby/chruby.fish (line 1): string trim -r -c/ "$dir"
                                              ^
in command substitution
    called on line 126 of file /usr/local/share/chruby/chruby.fish

in function “chruby”
    called on line 38 of file ~/.config/fish/config.fish
    with parameter list “2.2.3”

from sourcing file ~/.config/fish/config.fish
    called during startup

fish: Unknown command 'string split -m1 -r /'
/usr/local/share/chruby/chruby.fish (line 1): string split -m1 -r / $dir | tail -n1
                                              ^
in command substitution
    called on line 126 of file /usr/local/share/chruby/chruby.fish

in function “chruby”
    called on line 38 of file ~/.config/fish/config.fish
    with parameter list “2.2.3”

from sourcing file ~/.config/fish/config.fish
    called during startup

fish: Unknown command 'string match -qi *2.2.3* '
/usr/local/share/chruby/chruby.fish (line 19):           string match -qi "*$argv[1]*" "$ruby"; and set match "$dir"
                                                         ^
in function “chruby”
    called on line 38 of file ~/.config/fish/config.fish
    with parameter list “2.2.3”

from sourcing file ~/.config/fish/config.fish
    called during startup

I'm using chruby 0.3.9

Thanks for your work and your help!

JRuby Is Slow

Generally the startup time of JRuby is slow. But I noticed that with chruby-fish it is even slower. I am running OSX 10.9.2, fish 2.1.0, and chruby 0.3.8, and chruby-fish 0.5.4. I have uploaded a video to better demonstrate the difference - https://dl.dropboxusercontent.com/u/1701851/Switching%20Ruby%20Versions.mov. If you think that the problem comes from the git data in the prompt, I have also tried it with the "Just a Dollar" prompt - still the same slow behaviour. Any suggestions?

wishlist: support for gem_home

I am trying out fish shell for the first time and was so happy to run across your project. I use chruby, and ruby-install. I also use gem_home which is currently not supported. In a perfect world, @postmodern would add fish support to his projects. Fish shell seems like a nice alternative to zsh. Thanks again for creating this project.

Install instructions not working

The wget -O file is different than the input file to tar, causing tar to fail. Once past that, cd doesn't work when the auto.fish script is sourced. This seems to be fixed in master and I installed from a git clone with no problems. Could the install instructions be updated to reflect what was fixed?

Thanks for your work on this project!

chruby-exec seems to be broken

I am running OSX 10.9.3, along with the following:

~ $ chruby --version
chruby: 0.3.8
chruby-fish: 0.6.0
~ $ fish --version
fish, version 2.1.0
~ $

However, when trying to execute chruby-exec, I get the following error:

~ $ chruby
   jruby-1.7.12
 * ruby-2.1.2
~ $ chruby-exec jruby-1.7.12 -- gem env
fish: Expected a command name, got token of type 'Run job in background'. Did you mean 'COMMAND; and COMMAND'? See the help section for the 'and' builtin command by typing 'help and'.
Standard input: chruby jruby-1.7.12 && gem env
                                     ^
~ $

Any ideas?

Warnings when changing ruby versions

When changing ruby versions, I get a bunch of warnings. I'm on the latest chruby-fish and fish 2.1.0.

$ chruby 2.1.2
set: Warning: path component /Users/jip/.gem/ruby/2.1.2/bin may not be valid in PATH.
set: No such file or directory
set: Warning: path component /Users/jip/.rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/bin may not be valid in PATH.
set: No such file or directory
$ fish -v
fish, version 2.1.0
$ chruby -v
chruby: unknown Ruby: -v
chruby-fish: 0.6.0

Add tests?

If you are interested in adding tests I could offer some help using Fishtape.

Ruby is unselected when cd'ing out of a directory with a .ruby-version file

With chruby version 1.0.0:

user@xxx-dev-2022 ~/d/r/other  $ chruby
   ruby-3.0.5
 * ruby-3.2.0
user@xxx-dev-2022 ~/d/r/other  $ cd test/
user@xxx-dev-2022 ~/d/r/o/test  $ chruby
   ruby-3.0.5
 * ruby-3.2.0
user@xxx-dev-2022 ~/d/r/o/test  $ cat .ruby-version
3.2.0
user@xxx-dev-2022 ~/d/r/o/test  $ cd ..
user@xxx-dev-2022 ~/d/r/other  $ chruby
   ruby-3.0.5
   ruby-3.2.0

Very confusing. Is there a way to fix this?

Consider using an org for this repo.

I've created an org and invited @bouk and @postmodern - perhaps @tenderlove can be part of that too.

https://github.com/ruby-shell

Not sure where we can go with this but I'd love to see a central place for collaboration on ruby shell related tooling, including:

  • ruby-install
  • chruby
  • chruby-fish
  • other command line tooling

I often find myself recommending people to install these tools together so it will look a bit more professional to have a central org rather than several different user accounts.

Providing a centralised org for maintainers and users has many advantages, but there are some disadvantages too - like naming things, ownership and responsibility needs to be considered, etc.

In any case, it would be awesome to start the ball rolling by considering moving this repo to a shared org, like ruby-shell. If that name doesn't work can we propose one that does? Thanks for your consideration!

Listing rubies also prints version

Note the version printed at the end:

$ chruby
   jruby-1.7.12
   jruby-1.7.16
   mruby-1.0.0
   rbx-2.5.0
   rbx-2.5.2
   rbx-2.5.7
   ruby-1.8.7-p374
   ruby-1.9.3-p545
   ruby-2.0.0-p451
 * ruby-2.1.1
   ruby-2.1.2
   ruby-2.1.5
   ruby-2.1.6
   ruby-2.2.0
   ruby-2.2.1
   ruby-2.2.2
chruby-fish: 0.6.0

This is because the condition for this is placed after the condition for help and version, but the empty $argv causes grep to always match.

$ echo -h --help -V --version | grep -qe ""
$ echo $status
0

Was going to submit a PR, but tests are failing for me (might be b/c I just upgraded to fish 2.2.0)

Issue with GEM_PATH when using emacs robe

I am using the spacemacs configuration layer with emacs. However, I am getting the following error when running M-x robe-start:

/home/immortalin/.rubies/ruby-2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/dependency.rb:318:in `to_specs': Could not find 'bundler' (>= 0.a) among 9 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=/home/immortalin/.gem/ruby/2.2.0:/home/immortalin/.rubies/ruby-2.2.3/lib/ruby/gems/2.2.0', execute `gem env` for more information
    from /home/immortalin/.rubies/ruby-2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/dependency.rb:327:in `to_spec'
    from /home/immortalin/.rubies/ruby-2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_gem.rb:64:in `gem'
    from /home/immortalin/.gem/ruby/2.2.3/bin/bundle:22:in `<main>'

Process rails exited abnormally with code 1

Running gem env gives the following:

RubyGems Environment:
  - RUBYGEMS VERSION: 2.5.0
  - RUBY VERSION: 2.2.3 (2015-08-18 patchlevel 173) [i686-linux]
  - INSTALLATION DIRECTORY: /home/immortalin/.gem/ruby/2.2.3
  - USER INSTALLATION DIRECTORY: /home/immortalin/.gem/ruby/2.2.0
  - RUBY EXECUTABLE: /home/immortalin/.rubies/ruby-2.2.3/bin/ruby
  - EXECUTABLE DIRECTORY: /home/immortalin/.gem/ruby/2.2.3/bin
  - SPEC CACHE DIRECTORY: /home/immortalin/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /home/immortalin/.rubies/ruby-2.2.3/etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-linux
  - GEM PATHS:
     - /home/immortalin/.gem/ruby/2.2.3
     - /home/immortalin/.rubies/ruby-2.2.3/lib/ruby/gems/2.2.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /home/immortalin/.gem/ruby/2.2.3/bin
     - /home/immortalin/.rubies/ruby-2.2.3/lib/ruby/gems/2.2.0/bin
     - /home/immortalin/.rubies/ruby-2.2.3/bin
     - /home/immortalin/bin
     - /usr/local/sbin
     - /usr/local/bin
     - /usr/sbin
     - /usr/bin
     - /sbin
     - /bin
     - /usr/games
     - /usr/local/games
     - /usr/local/go/bin
     - /home/immortalin/Development/Go/bin
     - ~/bin
     - /opt/apache-maven-3.3.3/bin
     - ~/npm-global/bin
     - 
     - /usr/lib/jvm/java-8-oracle/bin
     - /usr/lib/jvm/java-8-oracle/db/bin
     - /usr/lib/jvm/java-8-oracle/jre/bin

This is my config.fish:

fish_vi_mode
source /usr/local/share/chruby/chruby.fish
chruby 2.2.3
source ~/.fishmarks/marks.fish

test suite no longer working on latest macOS releases

It looks like RVM is no longer updating their binaries for newer OS versions:

chruby-fish ❯ make test

./test/setup
>>> Downloading https://rvm.io/binaries/osx/10.13/x86_64/ruby-2.2.5.tar.bz2 ...
--2018-09-15 10:23:47--  https://rvm.io/binaries/osx/10.13/x86_64/ruby-2.2.5.tar.bz2
Resolving rvm.io (rvm.io)... 151.101.130.49, 151.101.194.49, 151.101.2.49, ...
Connecting to rvm.io (rvm.io)|151.101.130.49|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2018-09-15 10:23:47 ERROR 404: Not Found.

!!! Download failed
make: *** [test/opt/rubies] Error 255

The CI still works, as it uses an older version of macOS. Unfortunately, I don't have the time to investigate and solve this issue. If anyone wants to tackle this issue, I'm willing to help them.

Failed to execute process ''.

This is OSX Mavericks, running fish shell installed via brew install https://raw.githubusercontent.com/JeanMertz/chruby-fish/master/homebrew/chruby-fish.rb. Inside the ~/.config/fish/config.fish I have:

source /usr/local/share/chruby/chruby.fish
source /usr/local/share/chruby/auto.fish

After loading a new session, I get the following error:

Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
Failed to execute process ''. Reason:
The file '' does not exist or could not be executed.
set: Warning: path component /Users/dimitar/.rubies/2.1.1/lib/ruby/gems/2.1.0/bin may not be valid in PATH.
set: No such file or directory
~ $

The PATH error is present, because the bin folder does not exist. However, what is the reason behind the first error? If I remove the source /usr/local/share/chruby/auto.fish line, then the first error is gone. Any suggestions?

Permission issues on macosx

I installed this with brew. and added the source lines to config.fish . But I am getting these errors everytime I start a new shell:

mkdir: /nix/var/nix/profiles/per-user/: Operation not permitted
WARNING: bad ownership on /nix/var/nix/profiles/per-user/
mkdir: /nix/var/nix/gcroots/per-user/: Operation not permitted
WARNING: bad ownership on /nix/var/nix/gcroots/per-user/
mkdir: /nix/var/nix/profiles/per-user/: Operation not permitted
WARNING: bad ownership on /nix/var/nix/profiles/per-user/
mkdir: /nix/var/nix/gcroots/per-user/: Operation not permitted
WARNING: bad ownership on /nix/var/nix/gcroots/per-user/
mkdir: /nix/var/nix/profiles/per-user/: Operation not permitted
WARNING: bad ownership on /nix/var/nix/profiles/per-user/
mkdir: /nix/var/nix/gcroots/per-user/: Operation not permitted
WARNING: bad ownership on /nix/var/nix/gcroots/per-user/
mkdir: /nix/var/nix/profiles/per-user/: Operation not permitted
WARNING: bad ownership on /nix/var/nix/profiles/per-user/
mkdir: /nix/var/nix/gcroots/per-user/: Operation not permitted
WARNING: bad ownership on /nix/var/nix/gcroots/per-user/

not sure why these permissions are needed

"path component may not be valid" warning

$> cd ~/projects/foo/
set: Warning: path component /home/jesse/.rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/bin may not be valid in PATH.
set: No such file or directory
$> cat .ruby-version
2.1.5
$> chruby --version
chruby: 0.3.9
chruby-fish: 0.6.0

chruby-fish is actuall HEAD as of e8f2803

Ideas on how to suppress the warning? There's definitely no bin/ in that path above.

chruby-fish executing .bash_profile when changing ruby

After enabling chruby-fish .bash_profile is executed for each ruby load. Is this intended behaviour?

I am not sourcing .bash_profile in my config.fish so it is only loaded when chruby-fish is changing rubies.

I would like to keep my . bash_profile for bash and not load this file when changing rubies in fish.

Fully set RUBIES doesn't match chruby output

config.fish

set -x EDITOR vim
set -x RBX_HOME $HOME/projects/rubinius/rubinius

set -x MAGLEV_OPTS "-q"
set -x MAGLEV_HOME $HOME/projects/maglev/maglev
set -x GEMSTONE $MAGLEV_HOME/gemstone
set -x GEMSTONE_GLOBAL_DIR $MAGLEV_HOME
set -e GEMSTONE_NRS_ALL

. /usr/local/share/chruby/chruby.fish
. /usr/local/share/chruby/auto.fish

set -x RUBIES $RUBIES ~/.rubies/*
set -x RUBIES $RUBIES $RBX_HOME
set -x RUBIES $RUBIES $MAGLEV_HOME
set -x RUBIES $RUBIES ~/projects/jruby

chruby 2.1.2
$> echo $RUBIES
/home/jesse/.rubies/jruby-1.7.12 /home/jesse/.rubies/rbx-1.3.x /home/jesse/.rubies/ruby-1.8.7 /home/jesse/.rubies/ruby-1.9.3-p545 /home/jesse/.rubies/ruby-2.1.0 /home/jesse/.rubies/ruby-2.1.2 /home/jesse/.rubies/ruby-2.2.0-preview1 /home/jesse/.rubies/jruby-1.7.12 /home/jesse/.rubies/rbx-1.3.x /home/jesse/.rubies/ruby-1.8.7 /home/jesse/.rubies/ruby-1.9.3-p545 /home/jesse/.rubies/ruby-2.1.0 /home/jesse/.rubies/ruby-2.1.2 /home/jesse/.rubies/ruby-2.2.0-preview1 /home/jesse/projects/rubinius/rubinius /home/jesse/projects/maglev/maglev /home/jesse/projects/jruby

$> chruby
   jruby-1.7.12
   rbx-1.3.x
   ruby-1.8.7
   ruby-1.9.3-p545
   ruby-2.1.0
 * ruby-2.1.2
   ruby-2.2.0-preview1

What am I doing incorrectly that Rubinius, MagLev and JRuby aren't being detected?

/c @postmodern

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.