Commit graph

645 commits

Author SHA1 Message Date
Anton Petrov
332772abc5
1.2.24 2021-03-19 10:06:26 +03:00
Anton Petrov
afb14d2072
Merge pull request #1814 from native-api/rm_script_dir
Remove the "Using script's directory as PYENV_DIR if shim is invoked with a script argument" feature
2021-03-09 14:36:12 +03:00
Ville Skyttä
f06fb60b1f Make work in nounset (-u) mode 2021-02-23 22:29:56 +02:00
Anton Petrov
f31a06dc19
Added --nosystem argument
Added --nosystem argument to skip the system environment when searching for an executable.
2021-02-22 12:21:02 +03:00
Josh Friend
5f62ad7680
v1.2.23 2021-02-17 11:32:41 -05:00
tuzi3040
d51999adf5
Fix 'sed: RE error: illegal byte sequence' (#1714)
... by unsetting `LC_ALL` and passing `LC_CTYPE=C` to `sed`.

This commit fixes issue #1454.
2021-02-17 11:12:45 -05:00
Ivan Pozdeev
131e44afcb Remove the "Using script's directory as PYENV_DIR if shim is invoked with a script argument" feature
It's impossible to 100% reliably extract the script argument from the command line for all and unknown Python versions and implementations
2021-02-16 23:59:08 +03:00
Ivan Pozdeev
a6b0a2846e Revert "shims: handle symlinked scripts, via new PYENV_FILE_ARG"
This reverts commit 493f036928.

# Conflicts:
#	libexec/pyenv
2021-02-16 23:53:05 +03:00
Ivan Pozdeev
00f7d6249a Fix not printing asterisk for current version in Bash 3 2021-02-14 15:50:36 +03:00
Ivan Pozdeev
9309050864 Use a better PS4 as recommeneded by Bash Hackers Wiki
it allows to see functions as well as lines, therefore making it possible to see the control flow
2021-02-10 22:42:18 +03:00
Anton Petrov
89d3d0c33d
Merge pull request #1655 from draeath/master
"system" python - support cases where python3, python2 is in PATH but not python
2021-02-10 20:45:41 +03:00
Anton Petrov
50a48764ff
Merge pull request #1797 from rharish101/search_system
Added fallback to system executable
2021-02-07 19:37:26 +03:00
Ville Skyttä
c4e556eded versions: use associative array to hold current versions
"hyperfine pyenv-versions" before with my bash 4.4:

Time (mean ± σ):    81.7 ms ±   2.2 ms  [User: 67.8 ms, System: 15.7 ms]
Range (min … max):  78.3 ms …  87.2 ms  34 runs

After:

Time (mean ± σ):    70.6 ms ±   2.4 ms  [User: 55.6 ms, System: 16.9 ms]
Range (min … max):  67.9 ms …  78.9 ms  41 runs
2021-01-29 19:54:25 +02:00
Ville Skyttä
a804887307 rehash: use associative array to hold registered shims
"hyperfine pyenv-rehash" before on my bash 4.4:

Time (mean ± σ):   172.8 ms ±   8.2 ms [User: 185.0 ms, System: 24.8 ms]
Range (min … max): 164.2 ms … 198.4 ms 15 runs

After:

Time (mean ± σ):   113.8 ms ±   2.8 ms [User: 127.1 ms, System: 26.1 ms]
Range (min … max): 108.0 ms … 117.6 ms 25 runs
2021-01-29 19:54:25 +02:00
Harish Rajagopal
cdecf14535
Added fallback to system executable
If pyenv doesn't find an executable for the current version/virtualenv,
then search the "system" version as a fallback.
2021-01-29 13:01:21 +01:00
Ville Skyttä
b938abdea1 rehash: preserve existing $PYENV_REHASH_TIMEOUT semantics
Try for that long no matter what the sleep step available is.
2021-01-28 16:00:59 +02:00
Ville Skyttä
c0ea15226d rehash: try to sleep in 0.1 sec steps when acquiring lock 2021-01-28 16:00:59 +02:00
Yamashita, Yuu
dc70546565
v1.2.22 (fixes #1760) 2021-01-10 12:52:22 +09:00
Josh Friend
806b30d6ce
v1.2.21 2020-10-08 20:59:02 -04:00
cornfeedhobo
cadebd8e65
Search for plugins in PYENV_DIR and PYENV_ROOT (#1697) 2020-10-01 21:33:34 -04:00
M. Smits
71d2e4549e
Updated documentation pyenv init for fish shell comform to readme. (#1703) 2020-10-01 21:28:29 -04:00
Smiler Lee
592271b86f
Fix 'sed: RE error: illegal byte sequence' (#1670)
... which is caused by `realpath.dylib` containing illegal UTF-8 byte sequence, and `LC_CTYPE` won't take effect if `LC_ALL` happens to be set to something other than `C`.

This commit fixes issue pyenv/pyenv#1454.

Ref: https://stackoverflow.com/a/23584470
2020-10-01 20:16:55 -04:00
Ivan Pozdeev
f77c2d7eab Detect Py2 presence as well 2020-09-21 18:53:09 +03:00
Arcadiy Ivanov
0164e2bd59
CPython 3.9.0b4 (#1654) 2020-07-09 22:14:12 -04:00
Paul Bransford
4d762bca7b fix 'system' python to be present if 'python3' is on path but not 'python' 2020-07-07 18:39:52 -04:00
Josh Friend
86fbc6861d
v1.2.19 2020-06-17 09:59:49 -04:00
Josh Friend
1b6657e751
v1.2.18 2020-04-02 15:28:56 -04:00
Brian Dowling
a8ca63fcc0
Update help docs to clarify multiple version(s) are allowed (#1197)
* Update help docs to clarify multiple version(s) are allowed

* Tweek version(s) help description
2020-03-19 17:35:46 -04:00
Edwin Shin
89786b909f
pyenv-version-file-read: use POSIX character sets (#1554)
Fixes #623
2020-03-13 09:08:18 -04:00
Josh Friend
3005c46643
v1.2.17 2020-03-13 08:38:35 -04:00
adrian-the-git
7097f8204e Remove duplicate help message (#1525)
The pyenv help listing offered the "commands" command twice.
2020-01-22 18:12:29 -05:00
Phil Fernandez
1487135415 fixes sed illegal byte sequence error (#1521) 2020-01-14 13:07:05 -05:00
Josh Friend
ce0be04ad4
v1.2.16 2020-01-06 08:06:57 -05:00
Josh Friend
b5f69fe58a
v1.2.15 2019-10-31 16:06:42 -04:00
wukuan405
fcf539ecef change help message from hard coding to dynamic (#1421)
## before
```Usage: pyenv <command> [<args>]

Some useful pyenv commands are:
   commands    List all available pyenv commands
   local       Set or show the local application-specific Python version
   global      Set or show the global Python version
   shell       Set or show the shell-specific Python version
   install     Install a Python version using python-build
   uninstall   Uninstall a specific Python version
   rehash      Rehash pyenv shims (run this after installing executables)
   version     Show the current Python version and its origin
   versions    List all Python versions available to pyenv
   which       Display the full path to an executable
   whence      List all Python versions that contain the given executable

See `pyenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/pyenv/pyenv#readme
```

## after
```
Usage: pyenv <command> [<args>]

Some useful pyenv commands are:
   commands    List all available pyenv commands
   local       Set or show the local application-specific Python version
   --version   Display the version of pyenv
   commands    List all available pyenv commands
   exec        Run an executable with the selected Python version
   global      Set or show the global Python version
   help        Display help for a command
   hooks       List hook scripts for a given pyenv command
   init        Configure the shell environment for pyenv
   install     Install a Python version using python-build
   local       Set or show the local application-specific Python version
   prefix      Display prefix for a Python version
   rehash      Rehash pyenv shims (run this after installing executables)
   root        Display the root directory where versions and shims are kept
   shell       Set or show the shell-specific Python version
   shims       List existing pyenv shims
   uninstall   Uninstall a specific Python version
   update      update pyenv and plugins
   version     Show the current Python version and its origin
   version-file   Detect the file that sets the current pyenv version
   version-name   Show the current Python version
   version-origin   Explain how the current Python version is set
   versions    List all Python versions available to pyenv
   whence      List all Python versions that contain the given executable
   which       Display the full path to an executable

See `pyenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/pyenv/pyenv#readme
```
2019-10-16 11:47:11 -04:00
Josh Friend
d6d6bc8bb0
v1.2.14 2019-10-15 10:15:56 -04:00
Daniel Hahler
ecd67c8223
pyenv-exec: no -a with exec to keep $PATH with system version (#1169)
Using `exec -a` caused Python to use $PATH to look up the full program name (for
`sys.executable`), which 314937d then tried to fix by changing $PATH
also for the system version.
This is not necessary anymore when not using the short name with `exec`.

This was rejected upstream
(https://github.com/rbenv/rbenv/pull/1089#issuecomment-394531896), since
it is not a problem with Ruby apparently.

Uses $PYENV_ROOT to check if system version is used.

Fixes https://github.com/pyenv/pyenv/issues/98.
Fixes https://github.com/pyenv/pyenv/issues/789.
2019-09-29 00:03:44 +02:00
Josh Friend
17f44b7cd6
v1.2.13 2019-07-09 08:56:34 -04:00
Josh Friend
a10c787f9b
v1.2.12 2019-06-11 10:18:18 -04:00
Maxime Brunet
2b174ab69f List versions starting with a dot 2019-06-02 16:16:52 -04:00
Andrew Rabert
0f596d2504 Revert "Merge pull request #1153 from cmcginty/remove-sbang"
This reverts commit 070e1c859f, reversing
changes made to 3faeda67bb.
2019-04-23 10:23:33 -04:00
Christopher Hunt
070e1c859f
Merge pull request #1153 from cmcginty/remove-sbang
Remove shebang lines from scripts for performance
2019-04-22 20:13:19 -04:00
Christopher Hunt
3faeda67bb
Merge pull request #1216 from blueyed/abs_dirname
Fix abs_dirname for relative symlinks in same directory
2019-04-18 16:34:55 -04:00
Yamashita, Yuu
abd4469920 v1.2.11 2019-04-09 00:50:15 +00:00
Yamashita, Yuu
9a98bfae48 v1.2.10 2019-04-04 01:18:57 +00:00
Daniel Hahler
3768f1d7db Revert "also remove shebang with libexec/pyenv"
This reverts commit d352b4810d.
2019-03-07 22:38:15 +01:00
Daniel Hahler
d352b4810d also remove shebang with libexec/pyenv 2019-03-07 22:35:38 +01:00
Casey McGinty
83e5459cfb Remove shebang lines from scripts for performance
All scripts in libexec/ (excluding pyenv) are called through pyenv,
therefore the shebang lines are not necessary. On some systems this
provides a measurable increase in performance of the shell prompt.

Related to pyenv/pyenv-virtualenv#259
2019-03-07 22:15:14 +01:00
Josh Friend
3f39e8a944
v1.2.9 2019-01-10 08:19:47 -05:00
Josh Friend
80414b1b5b
v1.2.8 2018-10-30 09:42:16 -04:00
Daniel Hahler
4f21d9a2ea Fix abs_dirname for relative symlinks in same directory
Ref (abs_dirname in bats): https://github.com/sstephenson/bats/pull/224
Ref: https://github.com/rbenv/rbenv/pull/868

Fixes https://github.com/pyenv/pyenv/issues/580
2018-09-19 10:18:07 +02:00
Josh Friend
b7eea9003b
v1.2.7 2018-08-11 14:41:04 -04:00
Yamashita, Yuu
97f244fbb5 v1.2.6 2018-07-18 06:39:28 +00:00
Josh Friend
4812e0387b
v1.2.5 2018-06-27 19:21:18 -04:00
Tomoyuki Sahara
9c1d677d23 seq(1) is not available on OpenBSD. 2018-06-01 15:11:01 +09:00
Josh Friend
3faba7d47c
v1.2.4 2018-05-01 13:51:00 -04:00
Yamashita, Yuu
7973e59473 Fix rehash test to give up sooner after lock file's presence 2018-04-24 00:38:01 +00:00
Yamashita, Yuu
b1e3f13a85 Renamed variable; s/PYENV_REHASH_LOCK_TIMEOUT/PYENV_REHASH_TIMEOUT/ 2018-04-24 00:35:55 +00:00
Yamashita, Yuu
a6c15fb242 Experimental implementation to wait rehash until acquiring lock
For now the code is using traditional pseudo locking mechanism
based on `noclobber`.
2018-04-19 01:02:16 +00:00
Yamashita, Yuu
83f97ef2b3 Merge remote-tracking branch 'rbenv/master' into rbenv-20180402 2018-04-02 01:46:48 +00:00
Josh Friend
abbb606041 v1.2.3 2018-03-28 18:22:17 -04:00
Josh Friend
a8e207f330 v1.2.2 2018-02-28 16:32:37 -05:00
Victor Lim
9daf81f16e Fix https://github.com/rbenv/rbenv/issues/1065
Command `rbenv version-name > .ruby-version` will create an empty `.ruby-version` file
before running `rbenv-version-file`. This causes `rbenv-version-file` to return empty
string which in turn causes `rbenv-version-name` to return `system`.

Ensure size of `.ruby-version` is non-zero as a workaround.
2018-02-26 16:49:37 +08:00
Josh Friend
b704c4242c Update changelog for 1.2.1 release 2018-01-10 08:27:34 -05:00
Josh Friend
e71ac9e439 Release v1.2.0 2017-12-10 09:40:49 -05:00
Marco Hinz
af53c790cc
Better error message for rbenv shell
Shell integration is not enabled by default. This means that, from all the
commands from `rbenv commands`, only "shell" won't work right away.

Replace "no such command" with a more descriptive message that points to
`rbenv init` instead.
2017-12-07 02:32:34 +01:00
Daniel Hahler
5f8a4c4d62 Fix some issues reported by shellcheck 2017-11-29 16:20:51 +01:00
Mislav Marohnić
eda952ab08 Merge branch 'cdpath-enable' 2017-11-29 15:53:41 +01:00
Mislav Marohnić
b80ea43e25 Quote directory name in variable assignment 2017-11-29 15:51:03 +01:00
Mislav Marohnić
eab68688dc
Merge pull request #959 from zenspider/fix-dash-u
Fixed `rbenv init -` output to work w/ no args and bash's `set -u`.
2017-11-29 15:40:23 +01:00
Mislav Marohnić
5183e32887
Merge pull request #982 from MartinNowak/issue759
partly resolve #759
2017-11-29 15:37:22 +01:00
Mislav Marohnić
33a5c2495d
Merge pull request #1003 from blueyed/version-file-skip-dirs
rbenv-version-file: ensure that the version file is a file
2017-11-29 15:23:58 +01:00
Yamashita, Yuu
85a66a9640
Merge pull request #1036 from zachriggle/pwd-changes
Fix $PWD changes when executing Python
2017-11-21 10:51:41 +09:00
Zach Riggle
19e2b9588a Fix $PWD changes when executing Python
Specifically, this does not play well with PWD=/proc/self/cwd
2017-11-13 16:04:31 -06:00
Ryan Davis
1a8b5e04a9 Fixed rbenv init - output to work w/ no args and bash's set -u. 2017-11-06 13:59:04 -08:00
Josh Friend
5af8d2fb12 Update changelog for v1.1.5 2017-10-03 19:30:53 -04:00
Yamashita, Yuu
2178fb931c v1.1.4 2017-09-20 01:54:46 +00:00
Josh Friend
0314de0c73
v1.1.3 2017-07-17 09:12:51 -04:00
Yamashita, Yuu
8fa1f43856 v1.1.2 2017-07-07 00:40:21 +00:00
Mislav Marohnić
6cd487db81 rbenv 1.1.1 2017-06-15 16:55:33 +02:00
Roman Bolshakov
01d39850b5 Do not attempt to read .python-version directories (#606) 2017-06-06 13:09:45 +02:00
Daniel Hahler
95b1b05cbe rbenv-version-file: ensure that the version file is a file
Forwarded from https://github.com/pyenv/pyenv/pull/606.
2017-06-05 15:40:59 +02:00
Daniel Hahler
3fd23431af Merge remote-tracking branch 'rbenv/master'
Conflicts:
	README.md
	libexec/pyenv---version
	libexec/pyenv-init
	libexec/rbenv
	libexec/rbenv-sh-shell
	libexec/rbenv-which
	test/init.bats
	test/shell.bats
2017-06-05 15:18:44 +02:00
Jeff Kowalski
a81da8d864 Revert quoting change in previous commit; adjust test to match code
Revert back to original quoting style used before previous commit.
Adjust init.bats to reflect changes for successful tests.
2017-05-16 13:36:06 -07:00
Jeff Kowalski
be2e606fbd Prefer 'set' over 'setenv' for fish shell
The setenv function in fish shell has changed dramatically in
75600b6b53
It now conforms to the csh version, which takes at most two arguments.
In this init script, the form
    setenv PATH prepend_something $PATH
had been used, which had too many arguments.
Since setenv isn't a native command in fish, a suitable replacement is
to use the "set -gx" command, which can consume multiple arguments.
2017-04-06 23:55:48 -07:00
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
Yamashita, Yuu
b3efcc9d15 v1.0.10 (fixes #878) 2017-03-28 02:40:09 +00:00
Martin Nowak
db39044ef6 partly resolve #759
- some versions of bash (e.g. 4.3.11) complain about clobbering
  /dev/null, use bash's explicit >| operator to ignore noclober
- not sure if the original #759 report has the same cause
- https://github.com/rbenv/rbenv/issues/759#issuecomment-289326891
2017-03-27 02:06:13 +02:00
Samuel Villamonte
acfbc96614 V1.0.9 release (#877)
* Update version to 1.0.9
2017-03-24 11:36:21 -05:00
Yamashita, Yuu
d01fa09a7d Migrate project URL to https://github.com/pyenv/pyenv 2017-03-06 04:31:48 +00:00
Yamashita, Yuu
ad8f2886ae v1.0.8 (fixes #841) 2017-02-24 06:09:09 +00:00
Yamashita, Yuu
57f946550a v1.0.7 2017-01-19 00:39:23 +00:00
Josh Friend
2552329dbd
v1.0.6 2016-12-23 08:51:29 -05: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
Josh Friend
095ca59878
v1.0.5 2016-12-17 18:04:50 -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
Josh Friend
30baff8e5d v1.0.4 2016-11-22 23:31:12 -05:00
Yamashita, Yuu
0d1a5b3030 v1.0.3 2016-11-11 05:16:06 +00:00
Yamashita, Yuu
d74daad8f5 v1.0.2 (fixes #709) 2016-09-20 00:52:19 +00: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
a0c5fe42e9 v1.0.1 (#694) 2016-09-09 05:26:49 +00:00
Yamashita, Yuu
7fadd939ad v1.0.0 (fixes #520) 2016-08-15 08:30:01 +00:00
Yamashita, Yuu
fb757053c8 Show meaningful message on missing executable (fixes #610) 2016-08-15 06:01:55 +00:00
Yamashita, Yuu
740fbe4bda Merge pull request #661 from yyuu/workaroud-bin-python
Add workaround for `/bin/python`
2016-08-03 22:48:46 +09:00
Yamashita, Yuu
6030ea51e4 Add a workaround for system executables in /bin 2016-08-01 00:32:50 +00:00
Yamashita, Yuu
7da05ee964 v20160726 2016-07-26 08:06:31 +00:00
Yamashita, Yuu
4df7cf2dd6 Add workaround for /bin/python (#628) 2016-07-21 02:45:27 +00:00
Yamashita, Yuu
e93ae00ca1 Write help message to stdout just like other commands (#650, #651) 2016-07-20 00:25:09 +00:00
Yamashita, Yuu
26ac59fd1d Write help message to stdout 2016-07-04 00:56:08 +00:00
Yamashita, Yuu
c803130a9d Merge pull request #651 from yyuu/sh-help-stderr
Messages should not be written to stdout if the command is `sh-` command
2016-07-01 09:13:42 +09: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
Yamashita, Yuu
727b8b02ac Merge remote-tracking branch 'rbenv/master' into rbenv-20160701 2016-07-01 00:00:35 +00:00
Yamashita, Yuu
25d3ca7fdf Messages should not be written in stdout if the command is sh- command (fixes #650) 2016-06-30 09:48:00 +00:00
Josh Friend
7d709586ee
v20160629 2016-06-28 22:09:39 -04:00
Yamashita, Yuu
9cd200b98c v20160628 (fixes #644) 2016-06-28 00:34:58 +00:00
McTavish McArdle
5f20bc258f "." has been deprecated in the fish shell in favor of explicit "source" 2016-05-28 18:29:45 -04:00
Yamashita, Yuu
2017dd0c25 v20160509 2016-05-09 00:45:51 +00:00
Mike Busch
d246e20764 unset CDPATH if it's set by the user 2016-04-22 10:17:40 -05:00
Josh Friend
78b9cee98e v20160422 2016-04-22 08:56:37 -04:00
Jack Maney
e92a7de031 Fixed version date
`s/2015/2016/`
2016-03-11 09:35:11 -06:00
Josh Friend
8ef30d9e4d v20160310 2016-03-10 20:28:49 -05:00
Yamashita, Yuu
12069a1118 Merge pull request #549 from yyuu/rbenv-1.0
rbenv 1.0+
2016-03-04 09:37:56 +09:00
Yamashita, Yuu
be3fc6d8cb Fix broken pyenv local 2016-03-04 00:00:53 +00:00
Yamashita, Yuu
7467c88780 v20160303 2016-03-03 00:43:07 +00:00
Yamashita, Yuu
41ce3aade2 Merge remote-tracking branch 'rbenv/master' into rbenv-1.0 2016-03-02 01:39:52 +00:00
Donald Merand
8b0b51a166 convert references to '.' to 'source' for fish shell 2016-02-20 10:27:39 -05:00
Yamashita, Yuu
425e44d064 v20160202 2016-02-02 08:43:21 +00: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