Commit graph

304 commits

Author SHA1 Message Date
Tim Pope
9d93605e18 Don't unset CDPATH 2017-04-05 17:39:39 -04:00
Tim Pope
1f1e291385 Enforce absolute RBENV_DIR
This prevents CDPATH from becoming an issue.

Closes #866.
2017-04-05 16:54:03 -04:00
Jason Karns
8eb97549e1
Conforms OLD_RBENV_VERSION to RBENV_* convention
Keeping rbenv-controlled variables to RBENV_* "namespace" helps with
discoverability (and tools like rbenv-env) but also consistency and a
very minor degree of safety/isolation from env impact.
2016-12-19 17:21:45 -05:00
Mislav Marohnić
e60ad4a090 rbenv 1.1.0 2016-11-25 21:11:08 +01:00
Mislav Marohnić
6ced4e25de Merge pull request #873 from dmerand/patch-1
Fish shell "." is deprecated in favor of "source"
2016-11-25 20:32:54 +01:00
Mislav Marohnić
2207c27cb4 Merge branch 'shell-undo' 2016-11-25 20:26:24 +01:00
Mislav Marohnić
c4d97ad392 Finalize rbenv shell - implementation
This ensures that OLD_RBENV_VERSION is never exported. This makes the
implementation a little bit more complex, since more logic needs to be
pushed down into eval'd code.
2016-11-25 20:24:16 +01:00
Mislav Marohnić
1b751261ce Merge pull request #914 from yyuu/sh-help-stderr
Help message should not be written to stdout for `sh-` commands
2016-11-25 19:06:01 +01:00
Mislav Marohnić
d0779fc8fb Expand literal tilde in PATH
The literal tilde in a PATH entry (e.g. `~/.rbenv/shims`) doesn't seem
to be supported by system `which` utility, but *does* seem to be
supported by `command -v` (used in `rbenv-which`) and `type -p`.

Therefore, we must strip away `~/.rbenv/shims` from PATH when looking up
executables for system Ruby, lest we risk infinite loop. We do so by
substituting any occurence of `~` in PATH with the value of `HOME`.
2016-09-09 10:29:12 +02:00
Yamashita, Yuu
6030ea51e4 Add a workaround for system executables in /bin 2016-08-01 00:32:50 +00:00
Yamashita, Yuu
26ac59fd1d Write help message to stdout 2016-07-04 00:56:08 +00:00
Yamashita, Yuu
7860ad5268 Help message should not be written to stdout for sh- commands (yyuu/pyenv#650) 2016-07-01 00:08:19 +00:00
Mike Busch
d246e20764 unset CDPATH if it's set by the user 2016-04-22 10:17:40 -05:00
Donald Merand
8b0b51a166 convert references to '.' to 'source' for fish shell 2016-02-20 10:27:39 -05:00
Aaron Patterson
6a912bf104 add support for rbenv shell -
`rbenv shell -` allows you to switch to the previously activated ruby
version.  Similar to `cd -` or `git checkout -`.

This tries to implement `rbenv shell -` as proposed in #854.  However,
adding support seemed to break the "shell change version" test.  I'm not
very good at Bash programming, can someone tell me what is wrong with
what I'm doing?  I'd like to add a bit more functionality to this, but
I'm really just cargo cult programming Bash.

Thank you!

fix tests
2016-01-12 15:32:59 -08:00
Mislav Marohnić
a95ccd09a2 Simplify fallback to global version file 2015-12-29 14:44:32 +01:00
Mislav Marohnić
e199a3d8f7 Merge pull request #850 from jasonkarns/remove-legacy-global-version-file
Remove support for legacy global version files
2015-12-29 14:40:37 +01:00
Jason Karns
fe809ea90d Remove support for legacy global version files
`default` was made legacy back in 2011 with
5be66da9f4 (the command was renamed from
`rbenv-default` to `rbenv-global`, and so the global file was renamed
from `$RBENV_ROOT/default` to `$RBENV_ROOT/global` (the latter taking
precedence)

`global` was then made legacy about a month later in Sep 2011 when the
preferred filename was changed to `$RBENV_ROOT/version`.
2015-12-28 22:05:00 -05:00
Jason Karns
f880dc6d6f Remove support for legacy version file 2015-12-28 21:34:07 -05:00
Mislav Marohnić
3997a394d9 rbenv 1.0.0 2015-12-24 19:12:47 +01:00
Mislav Marohnić
e554cd86c3 Strip leading : from RBENV_HOOK_PATH 2015-12-24 19:12:47 +01:00
Mislav Marohnić
a9a9636d1e Tweak sanitizing shell name
Handles situation when the output is `/bin/shell- args...`. First strip
away the arguments, then the trailing dash.
2015-12-24 13:23:01 +01:00
Daniel Hahler
32030e2ed9 Fix shell version when invoked from a script
When invoked from a shell script, `$(rbenv init -)` did not get the
shell name correct.
It needs to look at the `args` value from `ps`.

Ref: https://github.com/yyuu/pyenv/issues/373
2015-12-24 13:21:22 +01:00
Mislav Marohnić
2c7960102c Simplify reference to realpath.dylib within rbenv-versions
The `../libexec` dance isn't necessary here. It was only necessary in
main `rbenv` command because that one might have been pointed to
directly via a symlink.
2015-12-24 03:54:32 +01:00
Mislav Marohnić
1a0be6f0ad Improve git --version git revision lookup
It doesn't try to chdir into RBENV_ROOT anymore because that might be
a location of an unrelated rbenv install that might have a different
version than the current one that is installed e.g. via a package
manager such as Homebrew.

Now just tries the repo where the source files (`libexec/*`) are
located, and if that isn't a valid rbenv repo, bail out early.
2015-12-24 03:52:33 +01:00
Mislav Marohnić
6481cbb172 Merge branch 'version-hooks'
Closes #739
2015-12-23 17:42:44 +01:00
Mislav Marohnić
4fde4ecbaf Ensure RBENV_VERSION_ORIGIN is not inherited from environment
It's only supposed to be set from `version-origin` hooks, but not
inherited from environment in case it was set.
2015-12-23 17:26:53 +01:00
Mislav Marohnić
40c1d27445 Merge remote-tracking branch 'origin/master' into version-hooks 2015-12-23 17:22:43 +01:00
Jason Karns
97f0499f43 add version-name/version-origin to hooks completion 2015-12-23 17:22:31 +01:00
Jason Karns
c3a5f91ed0 create hook: version-origin
Expose a `version-origin` hook.

It is invoked *before* the traditional `rbenv-version-file` lookup. Because `version-origin` is traditionally run immediately after `version-name`, then any plugin hooks that alter `version-name` would have done so. Thus, running `version-origin` prior to printing the origin gives those plugins a chance to alter the `version-origin` to match.

If any of the hooks set `$RBENV_VERSION_ORIGIN`, then it is used as the return value. Otherwise, the existing logic continues to return "environment variable" or "filename" as appropriate.

This change, in conjunction with the `version-name` hook, makes a clean seam by which plugins can inject their own ruby version setting logic. Using this seam, as opposed to altering `$RBENV_COMMAND_PATH` from the `which` hook, means that the version name and origin are set more reliably and so `version`, `version-name`, `version-origin` and `which` all work as expected. Indeed, even PS1 works now.
2015-12-23 17:22:31 +01:00
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ć
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ć
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
Chulki Lee
df4c16ecb4 update urls to rbenv 2015-12-07 11:03:07 -08: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
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
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
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ć
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