Commit graph

636 commits

Author SHA1 Message Date
Jason Karns
258e4413b1 create hook: version-name
Expose a `version-name` hook.

It is invoked *after* the traditional `RBENV_VERSION` lookup. Which means hook scripts can interrogate `$RBENV_VERSION_FILE` and/or `$RBENV_VERSION` (or use the executables).

The hooks are then run, giving plugins a chance to alter `RBENV_VERSION`. Once the hooks have run, we now have (in `$RBENV_VERSION`) the actual version we want to use (or it's empty which defaults to `system` per normal). Lastly, the same logic remains for checking if the version exists, or trimming the `ruby-` prefix.

Prime example: the ruby-bundler-ruby-version plugin can select a ruby by using the `ruby` directive from the `Gemfile` if a local `.ruby-version` doesn't exist.
2015-12-23 17:22:30 +01:00
Mislav Marohnić
a62a75369e Merge branch 'rbenv-local-respects-ancestry' 2015-12-23 15:30:18 +01:00
Mislav Marohnić
ba072adcb9 Have rbenv local read version from parent directories as well
Fixes #807
2015-12-23 15:21:24 +01:00
Mislav Marohnić
ca25259900 Allow explicit target directory argument to rbenv-version-file
Can be used for `.ruby-version` file lookup in the ancestry of a
specific directory. In this mode of operation, global version files
aren't taken into consideration, and the command fails unless a local
version file was found.
2015-12-23 15:19:54 +01:00
Mislav Marohnić
90373d78b9 Add test for not including current directory in PATH search
Confirms #836
2015-12-14 11:59:01 +01:00
Mislav Marohnić
dc23ef10b6 Merge pull request #836 from eagletmt/fix-path
Remove leading `:`
2015-12-12 15:22:36 +01:00
Kohei Suzuki
3c7a13d81f Remove leading : 2015-12-12 15:28:34 +09:00
Mislav Marohnić
20755cfc15 Merge pull request #833 from chulkilee/fix-url
update urls to rbenv
2015-12-07 20:47:06 +01:00
Chulki Lee
df4c16ecb4 update urls to rbenv 2015-12-07 11:03:07 -08:00
Mislav Marohnić
f0e8bdcdaf Merge pull request #830 from ReadmeCritic/master
Update README URLs based on HTTP redirects
2015-11-25 19:49:54 +01:00
ReadmeCritic
f85c41b14f Update README URLs based on HTTP redirects 2015-11-25 10:08:28 -08:00
Mislav Marohnić
75a1dd25cd Merge pull request #828 from jasonkarns/formatting
indentation
2015-11-24 17:22:33 +01:00
Jason Karns
a1ef9efc80 use PWD var over pwd command 2015-11-23 09:13:31 -05:00
Jason Karns
87dd5fe2c0 indentation 2015-11-23 09:13:31 -05:00
Mislav Marohnić
5fb9c84e14 Merge pull request #822 from jasonkarns/completion
Add --help and tab completion to rbenv-versions
2015-11-20 18:37:54 +01:00
Mislav Marohnić
d138f5f5e4 Merge pull request #826 from jasonkarns/fail-helper
Extract `fail` helper function
2015-11-20 18:29:34 +01:00
Jason Karns
3ddedc021a Extract abort helper function
fail helper prints message to stderr and exits 1
(prefixes 'rbenv: ' if given a string arg)
2015-11-20 10:25:46 -05:00
Mislav Marohnić
a22adc77eb Merge pull request #827 from jasonkarns/fix-exec-test
Fix leftover .ruby-version file from exec.bats
2015-11-20 16:00:49 +01:00
Jason Karns
a3ff3adc39 create local .ruby-version file in test dir
This new test was creating an (intentionally invalid) .ruby-version file
in current working directory; typically the rbenv project dir.
Immediately after test runs, I had a leftover .ruby-version file.

The version-file tests create and cd into the RBENV_TEST_DIR as part of
setup(). I'm using the same directory for this test fix, but am only
using it for this particular test. None of the other exec tests seem to
need to be in a temp test dir, so no use putting it in setup().
2015-11-20 09:51:44 -05:00
Jason Karns
2dcb9d0611 completions for rbenv-init 2015-11-20 09:20:01 -05:00
Jason Karns
a6cb4b6317 consistent completions for rbenv-help 2015-11-20 09:15:06 -05:00
Jason Karns
2f917312f1 completions for rbenv-completions 2015-11-20 09:12:53 -05:00
Jason Karns
d1f8081d1c completions for rbenv-versions 2015-11-20 09:12:47 -05:00
Mislav Marohnić
63671a1479 Merge pull request #824 from jasonkarns/help-completion
Handle --help flag for subcommands
2015-11-20 14:28:39 +01:00
Jason Karns
d7ca2aba2a add --help to subcommand completions
ensure subcommand exists, then include --help in its completion output
2015-11-19 12:05:19 -05:00
Jason Karns
2c4dd63f77 handle --help for subcommands
If subcommand is provided (and exists) and its first arg is -h/--help,
go ahead and intercept the call; redirecting to rbenv-help <subcommand>

This means subcommands and plugins need not handle --help flag
themselves
2015-11-19 12:05:18 -05:00
Jason Karns
06e4f1b682 explicit --version flag
Without it, it falls back to `--version` being executed as a subcommand,
which works but isn't obvious
2015-11-19 11:14:59 -05:00
Mislav Marohnić
825de5d2e3 Fix argument handling in main rbenv command
- Explicitly asking for help with `-h` or `--help` exits with 0 status
  and displays help on stdout.

- Not providing any arguments to rbenv results in failure status and
  displays version and help on stderr.
2015-11-19 01:52:48 +01:00
Mislav Marohnić
8f87f43e22 Fix broken version-dependent test
Broken in dcca61c0bc
2015-11-14 12:21:16 +00:00
Mislav Marohnić
c30e096a54 Merge branch 'which-fixes' 2015-11-14 10:42:41 +00:00
Mislav Marohnić
3405c4d03c Fix error message when command is not found for "system" version
If `foo` didn't exist and `RBENV_VERSION=system rbenv which foo` was
called, the error message used to be misleading:

    rbenv: version `system' is not installed

Instead, have the error message simply say that the command was not found.

Fixes #770
2015-11-13 23:10:09 -05:00
Mislav Marohnić
09b18cf6f5 Add test for version-origin when version not found in rbenv-exec 2015-11-13 23:09:12 -05:00
Mislav Marohnić
fcedf169fb Merge pull request #819 from blueyed/fix-path_without
tests: fix path_without to handle /bin properly
2015-11-13 18:01:53 -05:00
Mislav Marohnić
14655a43c8 Merge pull request #821 from jasonkarns/help-completion
add completion block for rbenv-help
2015-11-13 17:37:09 -05:00
Jason Karns
8c3cab61c7 add completion block for rbenv-help 2015-11-13 15:06:29 -05:00
Daniel Hahler
6296bf3f8b tests: fix path_without to handle /bin properly
I was seeing /bin being left.  This patch fixes it by anchoring the search
pattern with ':' on both sides.
2015-11-12 21:20:00 +01:00
Mislav Marohnić
c18a3f9042 Merge pull request #814 from m-o-e/never-use-hardlinks
Never use hardlinks. Never.
2015-10-29 17:25:26 +01:00
moe
f6c1e5220a Never use hardlinks. Never. 2015-10-28 21:35:39 +01:00
Mislav Marohnić
d740406daf Merge pull request #812 from sstephenson/skip-aliases
Add `rbenv versions --skip-aliases` option
2015-10-27 21:11:24 +01:00
Mislav Marohnić
7026e529c7 Fix realpath fallback in rbenv hooks
The symlinks weren't correctly resolved if they were pointing to a
single path component, such as `ln -s foo bar`.
2015-10-27 21:05:10 +01:00
Mislav Marohnić
e80886e9be Add rbenv versions --skip-aliases option
Useful in combination with `--bare` to list just the unique version
numbers without the extra directory entries that are symlinks to other
version numbers in the same directory.
2015-10-27 21:05:10 +01:00
Mislav Marohnić
6e02b944f7 Use $BASH_SOURCE instead of $0
BASH_SOURCE might be more reliable.
2015-10-27 20:55:23 +01:00
Mislav Marohnić
bb129a782b Merge branch 'bundler-hook-recursion'
Closes #809, references #806
2015-10-27 10:54:13 +01:00
Roman Sandler
d508822f9a Make sure the alias statement only executes if there is not already an alias in place 2015-10-27 10:53:51 +01:00
Mislav Marohnić
6913fee89a If there is .bashrc but no .bash_profile, recommend the former
This is for Linux desktop platforms that have Terminal application
configured to start shells in interactive but not login mode. Creating a
`~/.bash_profile` would also cause `~/.profile` to not run, which might
be a problem on Ubuntu which ships with a default `~/.profile`.
2015-10-26 15:45:52 +01:00
Mislav Marohnić
074161f9c1 Merge pull request #806 from sstephenson/bundle-rehash
Avoid running `rbenv rehash` multiple times during `bundle install`
2015-10-25 18:36:20 +01:00
Mislav Marohnić
2b0f16757a Only rehash if bundle install actually created new executables
This avoids running `rbenv rehash` after installing libraries that don't
have executables, or after a no-op `bundle install` that didn't install
anything.
2015-10-25 18:31:50 +01:00
Mislav Marohnić
7b289bcee6 Avoid running rbenv rehash multiple times during bundle install
This is an attempt to work around the fact that Rubygems post_install
hooks may happen multiple times per single `bundle install` and ideally
we want `rbenv rehash` to run only once if new gems have been installed.
However, due to Bundler parallelism using `fork` on platforms that
support it, it's impossible for the child processes to communicate with
the master process to signal it to run `rbenv rehash` in the end.

This hooks into Bundler `install` command and runs `rbenv rehash` after
all gems have finished installing, but only if the install location was
system gems location and not a custom path (such as per-project
`vendor/bundle`).

This is limited because we can't tell whether any gems have been
installed at all, let alone do those gems have executables. However it's
better than having multiple `rbenv rehash` being run in parallel and
outputting confusing error messages as a result.
2015-10-25 17:47:01 +01:00
Mislav Marohnić
8dcd715ede Merge branch 'edge-version' 2015-10-25 17:01:04 +01:00
Mislav Marohnić
dcca61c0bc Improve rbenv --version git checkout discovery
When `rbenv --version` is called, this now happens:

1. It changes into the directory where `libexec/rbenv--version` resides
   and checks if it's a checkout of the rbenv repo (as opposed to
   Homebrew checkout or something else). Then it reads the git revision.

2. If that failed, change to `$RBENV_ROOT` directory and repeat step 1.
2015-10-25 16:54:38 +01:00