terlar / fry Goto Github PK
View Code? Open in Web Editor NEWSimple ruby version manager for fish
License: MIT License
Simple ruby version manager for fish
License: MIT License
I have my config/fish/config.fish
file set to use ruby-install
and auto switching. This means every new shell I open up echoes configuration:
Auto-Switch: on
Installer: ruby-install
It would be nice if there were some sort of quiet flag for this; I would PR this for you but I wasnt sure how to cleanly implement it though, as fry config
just looks through argv
instead of doing option parsing.
Is there a way to fry won't add ruby path at the beginning ?
Right after fry use ...
I have to set PATH ./bin $PATH
to make spring works.
Cheers.
can you add a tag that includes the new license file and the command
fix?
That way I have a link to a fixed version for packaging :)
while coming from chruby
with frustration i tried fry
with fun but had to revert back to my direnv
script due to the lack of support for the above. or am i missing something?
part of my .direvnrc
:
rb_version="2.3.1"
use_ruby() {
local ruby_ver=$1
local ruby_dir=$HOME/.rubies/ruby-$ruby_ver
local gem_dir=$HOME/.gem/ruby/$ruby_ver
export GEM_HOME="$gem_dir"
export GEM_PATH="$gem_dir"
export BUNDLE_BIN="$ruby_dir/bin"
path_add MANPATH "$ruby_dir/share/man"
PATH_add "$HOME/.rubies/ruby-$ruby_ver/bin"
PATH_add "$GEM_HOME/bin"
PATH_add "$BUNDLE_BIN"
}
if [ -f ".ruby-version" ]; then
use ruby "$(cat .ruby-version)"
else
use ruby $rb_version
fi
if [ -n "$GEM_HOME" ]; then
echo "ruby gems at: $GEM_HOME"
fi
while it works well and is kinda POSIX
portable i'd still prefer something fishy because i use that shell heavily.
another thought is that bloating up fry
might not be good so i'll consider https://github.com/jamesob/desk as it kinda closely resembles direnv
.
If fry install
is a wrapper for ruby-build
, I'd expect options I give it to be passed to ruby-build
. For example, while I realize there is a fry ls
command, I'd still expect something like fry install --list
to work. However, this ends up being the output:
git/fry master % fry install -l
contains: Unknown option '-l'
/usr/local/share/fry/functions/fry-install.fish (line 17): if not contains $name (ruby-build --definitions)
^
in function 'fry-install',
called on line 2 of file '/usr/local/share/fry/functions/fry.fish',
with parameter list '-l'
in . (source) call of file '-',
called on line 22 of file '/usr/local/share/fry/functions/fry.fish',
in function 'fry',
called on standard input,
with parameter list 'install -l'
contains − contains ‐ test if a word is present in a list
contains ‐ test if a word is present in a list
Synopsis
contains [OPTIONS] KEY [VALUES...]
contains: Type 'help contains' for related documentation
fry-install: Unknown ruby '-l'
Available rubies:
1.8.6-p383
1.8.6-p420
1.8.7-p249
1.8.7-p302
1.8.7-p334
1.8.7-p352
1.8.7-p357
1.8.7-p358
1.8.7-p370
1.8.7-p371
1.8.7-p374
1.9.1-p378
1.9.1-p430
1.9.2-p0
1.9.2-p180
1.9.2-p290
1.9.2-p318
1.9.2-p320
1.9.3-dev
1.9.3-p0
1.9.3-p125
1.9.3-p194
1.9.3-p286
1.9.3-p327
1.9.3-p362
1.9.3-p374
1.9.3-p385
1.9.3-p392
1.9.3-p429
1.9.3-p448
1.9.3-preview1
1.9.3-rc1
2.0.0-dev
2.0.0-p0
2.0.0-p195
2.0.0-p247
2.0.0-preview1
2.0.0-preview2
2.0.0-rc1
2.0.0-rc2
2.1.0-dev
jruby-1.5.6
jruby-1.6.3
jruby-1.6.4
jruby-1.6.5
jruby-1.6.5.1
jruby-1.6.6
jruby-1.6.7
jruby-1.6.7.2
jruby-1.6.8
jruby-1.7.0
jruby-1.7.0-preview1
jruby-1.7.0-preview2
jruby-1.7.0-rc1
jruby-1.7.0-rc2
jruby-1.7.1
jruby-1.7.2
jruby-1.7.3
jruby-1.7.4
maglev-1.0.0
maglev-1.1.0-dev
maglev-2.0.0-dev
mruby-dev
rbx-1.2.4
rbx-2.0.0-dev
rbx-2.0.0-rc1
ree-1.8.6-2009.06
ree-1.8.7-2009.09
ree-1.8.7-2009.10
ree-1.8.7-2010.01
ree-1.8.7-2010.02
ree-1.8.7-2011.03
ree-1.8.7-2011.12
ree-1.8.7-2012.01
ree-1.8.7-2012.02
topaz-dev
Hiya! I just noticed that the latest version of fry ends up spitting out the contents of functions
when . /usr/local/share/fry/fry.fish
and fry config installer ruby-install
are called. For example, with the following in my ~/.config/fish/config.fish
file:
. /usr/local/share/fry/fry.fish
fry config auto on
fry config installer ruby-install
This happens when I open a new shell:
Last login: Wed Aug 27 01:19:16 on ttys002
., N_, alias, c, cd, contains_seq, delete-or-exit, dirh, dirs, down-or-search, eval, fish_config, fish_default_key_bindings, fish_indent, fish_prompt, fish_right_prompt, fish_sigtrap_handler, fish_title, fish_update_completions, fry, fry-config, fry-current, fry-find, fry-help, fry-install, fry-installer-ruby-build, fry-installer-ruby-install, fry-installers, fry-ls, fry-rubies, fry-use, fry-version, funced, funcsave, git, grep, help, history, hostname, isatty, la, ll, ls, man, math, mimedb, nextd, nextd-or-forward-word, open, popd, prevd, prevd-or-backward-word, prompt_pwd, psub, pushd, seq, setenv, sgrep, trap, type, umask, up-or-search, vared,
Auto-Switch: on
., N_, alias, c, cd, contains_seq, delete-or-exit, dirh, dirs, down-or-search, eval, fish_config, fish_default_key_bindings, fish_indent, fish_prompt, fish_right_prompt, fish_sigtrap_handler, fish_title, fish_update_completions, fry, fry-config, fry-current, fry-find, fry-help, fry-install, fry-installer-ruby-build, fry-installer-ruby-install, fry-installers, fry-ls, fry-rubies, fry-use, fry-version, funced, funcsave, git, grep, help, history, hostname, isatty, la, ll, ls, man, math, mimedb, nextd, nextd-or-forward-word, open, popd, prevd, prevd-or-backward-word, prompt_pwd, psub, pushd, seq, setenv, sgrep, trap, type, umask, up-or-search, vared,
Installer: ruby-install
Order in $PATH in subshell is wrong:
✓ ~ ➜ echo $PATH [ruby:2.1.2]
/Users/fazibear/.rubies/2.1.2/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin ./node_modules/.bin /usr/local/share/npm/bin /usr/X11/bin
✓ ~ ➜ fish [ruby:2.1.2]
✓ ~ ➜ echo $PATH [ruby:2.1.2]
/usr/local/bin /usr/bin /bin /usr/sbin /sbin ./node_modules/.bin /Users/fazibear/.rubies/2.1.2/bin ./node_modules/.bin /usr/local/share/npm/bin /usr/X11/bin
✓ ~ ➜
Add the command fry env
which would output something like:
export PATH="$(fish -c 'fry current --path'):$PATH"
This could then be piped into things like praxrc
, praxconfig
and powenv
:
fry env > .paxrc
Also it might be a good idea to let it take a specific ruby version:
fry env 2.1.3
I'd like to package fry as an archlinux package.
If that's ok, what license are you planning to use?
I've been trying to set the fry installer to ruby-build, but it does not seem to work.
fry config installer ruby-build
fry config
usage: fry config <name> [<value>]
Available configuration:
auto [on|off|1|0] switch ruby on directory change
prepend [on|off|1|0] prepend ruby path when used
path, rubies [<path>] path where fry looks for rubies
installer [<installer>] switch ruby installer to use
Current configuration:
Auto-Switch: off
Prepend Path: off
Path: /Users/jord/.rubies
Installer:
Am I doing something wrong? Quite possible as I've just started using both fry and fish.
If you don't have a global .ruby-version
file and are using auto-switch. You will always end up with the last projects ruby version when you switch folders.
One way to solve this problem is to have some kind of memory which ruby version was used before the auto-switch. This could then allow to manually set a ruby version, switch to a project and the ruby switches and when you switch away from this project and you are back with the ruby version you manually switched to.
It would be nice for fry-install
to also support ruby-install
if that's present instead of ruby-build
. I was actually working on implementing this myself, but the way that ruby-install
handles the directory structure made it difficult to set the correct installation directory without doing some ugly $argv parsing and manipulation.
However, the newly added --rubies-dir, -r
option in ruby-install
basically solves this and would allow the final command from fry-install
to be something like ruby-install -r $fry_rubies $argv
. However, the option will not be available until version 0.4.0 of ruby-install is released and, if we want to check the version and output an error if it's too low, that requires yet more ugly string parsing which I'm not sure you want in here.
Add better support for build systems. Right now we only support ruby-build
, but there are many other ways to install ruby.
I suggest creating a matrix that looks for build-systems and having them being pluggable. I'm thinking about having an interface that fry
works against and then the specific build system-code could be isolated inside a function.
Draft:
function __fry_installer_ruby-build
function __fry_install_ruby
ruby-build $argv $fry_rubies/$argv
end
function __fry_install_rubies
ruby-build --definitions
end
end
should read fisher terlar/fry
using fisherman returns, fish: Unknown command 'fisherman'
This has been a tough one to try and track down, and I'm still not sure why this is happening. But if auto switching is enabled and you enter a Tmux session, the $PATH handling starts to break down...
Outside of Tmux:
~ % cat .ruby-version
2.2.0
~ % echo $PATH
/Users/david/bin /Users/david/.rubies/2.2.0/bin /usr/local/bin /usr/local/sbin /Users/david/.local/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin /usr/local/share/npm/bin /usr/local/share/go/bin
~ % cd Documents/Code/davidcelis.github.io/
~Code/davidcelis.github.io master! % echo $PATH
/Users/david/Documents/Code/davidcelis.github.io/bin /Users/david/.rubies/2.0.0-p481/bin /usr/local/bin /usr/local/sbin /Users/david/.local/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin /usr/local/share/npm/bin /usr/local/share/go/bin
~Code/davidcelis.github.io master! %
In Tmux:
~ % cat .ruby-version
2.2.0
~ % echo $PATH
/Users/david/bin /Users/david/.rubies/2.2.0/bin /usr/local/bin /usr/local/sbin /Users/david/.local/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin /usr/local/share/npm/bin /usr/local/share/go/bin
~ % cd Documents/Code/davidcelis.github.io/
~Code/davidcelis.github.io master! % echo $PATH
/Users/david/Documents/Code/davidcelis.github.io/bin /Users/david/.rubies/2.0.0-p481/bin /Users/david/.rubies/2.2.0/bin /usr/local/bin /usr/local/sbin /Users/david/.local/bin /usr/local/share/npm/bin /usr/local/share/go/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin
So as you can see, for some reason while in Tmux, Fry doesn't replace $fry_rubies/(fry current)/bin
with the newly found ruby version. It instead simply prepends it onto the path. The only thing I've thought to try is putting this in my config.fish
if [ -n "$TMUX" ]
__fry_auto_switch
end
But simply invoking the __fry_auto_switch
function isn't enough it seems
.ruby-version should conform to the way rvm and rbenv expect this file.
Right now using ruby-2.0.0-p0
correctly works with fry, but raises this warning
warning: ignoring extraneous `ruby-' prefix in version `ruby-2.0.0-p0'
On the other and using what rvm expects like 2.0.0-p0
doesn't work with fry.
# For Fry ruby version manager
if test -f /usr/local/share/fry/fry.fish
source /usr/local/share/fry/fry.fish
# Set default version of ruby
fry use 2.0.0-p648
end
I have this in my fish.config
and I have fry config prepend on
. Whenever I source ~/.config/fish/config.fish
it looses the fry path from $PATH and defaults to the system ruby. Any help would be very appreciated.
$ fry use rbx-2
Switched to ruby 'rbx-2.4.1'
$ fry current
gems
$ fry version
0.1.2
It would be cool, if gemsets and .ruby-gemset
would be supported at some point.
$ uname -a
Darwin host.local 15.5.0 Darwin Kernel Version 15.5.0: Fri Apr 22 18:59:34 PDT 2016; root:xnu-3248.50.21~19/RELEASE_X86_64 x86_64
$ make
install -D -m644 man/man1/fry.1 "/usr/share/man/man1/fry.1"
install: illegal option -- D
usage: install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]
[-o owner] file1 file2
install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]
[-o owner] file1 ... fileN directory
install -d [-v] [-g group] [-m mode] [-o owner] directory ...
make: *** [install] Error 64
works when the -D
flag is removed, guess it's not POSIX
. additionally, sudo
is required to have it installed.
When sourcing fry.fish
I get the following:
grep: warning: recursive search of stdin
/usr/local/Cellar/fish/2.1.1/share/fish/functions/type.fish (line 3): standard input
^
in command substitution
called on line 3 of file '/usr/local/Cellar/fish/2.1.1/share/fish/functions/type.fish',
in . (source) call of file '-',
called on line 36 of file '/usr/local/Cellar/fish/2.1.1/share/fish/functions/type.fish',
in function 'type',
called on line 21 of file '/usr/local/share/fry/fry.fish',
with parameter list '-f (standard input):ruby-build'
in . (source) call of file '/usr/local/share/fry/fry.fish',
called on line 1 of file '/Users/mrak/.config/rcm/dotfiles/tag-mac/config/fish/os.fish',
in . (source) call of file '/Users/mrak/.config/rcm/dotfiles/tag-mac/config/fish/os.fish',
called on line 3 of file '/Users/mrak/.config/rcm/dotfiles/config/fish/config.fish',
in . (source) call of file '/Users/mrak/.config/rcm/dotfiles/config/fish/config.fish',
called on standard input,
/usr/local/Cellar/fish/2.1.1/share/fish/functions/type.fish (line 3): standard input
^
in command substitution
called on line 3 of file '/usr/local/Cellar/fish/2.1.1/share/fish/functions/type.fish',
in . (source) call of file '-',
called on line 36 of file '/usr/local/Cellar/fish/2.1.1/share/fish/functions/type.fish',
in function 'type',
called on line 21 of file '/usr/local/share/fry/fry.fish',
with parameter list '-f (standard input):ruby-install'
in . (source) call of file '/usr/local/share/fry/fry.fish',
called on line 1 of file '/Users/mrak/.config/rcm/dotfiles/tag-mac/config/fish/os.fish',
in . (source) call of file '/Users/mrak/.config/rcm/dotfiles/tag-mac/config/fish/os.fish',
called on line 3 of file '/Users/mrak/.config/rcm/dotfiles/config/fish/config.fish',
Line 1 of my os.fish
is source /usr/local/share/fry/fry.fish
I source os.fish
from my config.fish
On my machine, I have various versions of ruby compiled against different versions of libraries like libyaml and openssl. So, with that in mind:
~ % fry ls
system
2.1.2
2.1.2-yaml-015
~ % fry use 2.1.2
% fry use 2.1.2
Switched to ruby '2.1.2-yaml-015'
This should prefer 2.1.2
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.