Git Product home page Git Product logo

rbenv's Introduction

Seamlessly manage your app’s Ruby environment with rbenv.

rbenv is a version manager tool for the Ruby programming language on Unix-like systems. It is useful for switching between multiple Ruby versions on the same machine and for ensuring that each project you are working on always runs on the correct Ruby version.

How It Works

After rbenv injects itself into your PATH at installation time, any invocation of ruby, gem, bundler, or other Ruby-related executable will first activate rbenv. Then, rbenv scans the current project directory for a file named .ruby-version. If found, that file determines the version of Ruby that should be used within that directory. Finally, rbenv looks up that Ruby version among those installed under ~/.rbenv/versions/.

You can choose the Ruby version for your project with, for example:

cd myproject
# choose Ruby version 3.1.2:
rbenv local 3.1.2

Doing so will create or update the .ruby-version file in the current directory with the version that you've chosen. A different project of yours that is another directory might be using a different version of Ruby altogether—rbenv will seamlessly transition from one Ruby version to another when you switch projects.

Finally, almost every aspect of rbenv's mechanism is customizable via plugins written in bash.

The simplicity of rbenv has its benefits, but also some downsides. See the comparison of version managers for more details and some alternatives.

Installation

On systems with Homebrew package manager, the “Using Package Managers” method is recommended. On other systems, “Basic Git Checkout” might be the easiest way of ensuring that you are always installing the latest version of rbenv.

Using Package Managers

  1. Install rbenv using one of the following approaches.

    Homebrew

    On macOS or Linux, we recommend installing rbenv with Homebrew.

    brew install rbenv ruby-build

    Debian, Ubuntu, and their derivatives

    Note that the version of rbenv that is packaged and maintained in the Debian and Ubuntu repositories is out of date. To install the latest version, it is recommended to install rbenv using git.

    sudo apt install rbenv

    Arch Linux and its derivatives

    Archlinux has an AUR Package for rbenv and you can install it from the AUR using the instructions from this wiki page.

  2. Learn how to load rbenv in your shell.

    # run this and follow the printed instructions:
    rbenv init
  3. Close your Terminal window and open a new one so your changes take effect.

That's it! You are now ready to install some Ruby versions.

Basic Git Checkout

Note

For a more automated install, you can use rbenv-installer. If you do not want to execute scripts downloaded from a web URL or simply prefer a manual approach, follow the steps below.

This will get you going with the latest version of rbenv without needing a system-wide install.

  1. Clone rbenv into ~/.rbenv.

    git clone https://github.com/rbenv/rbenv.git ~/.rbenv
  2. Configure your shell to load rbenv:

    • For bash:

      Ubuntu Desktop users should configure ~/.bashrc:

      echo 'eval "$(~/.rbenv/bin/rbenv init - bash)"' >> ~/.bashrc

      On other platforms, bash is usually configured via ~/.bash_profile:

      echo 'eval "$(~/.rbenv/bin/rbenv init - bash)"' >> ~/.bash_profile
    • For Zsh:

      echo 'eval "$(~/.rbenv/bin/rbenv init - zsh)"' >> ~/.zshrc
    • For Fish shell:

      echo 'status --is-interactive; and ~/.rbenv/bin/rbenv init - fish | source' >> ~/.config/fish/config.fish

    If you are curious, see here to understand what init does.

  3. Restart your shell so that these changes take effect. (Opening a new terminal tab will usually do it.)

Installing Ruby versions

The rbenv install command does not ship with rbenv out-of-the-box, but is provided by the ruby-build plugin.

Before attempting to install Ruby, check that your build environment has the necessary tools and libraries. Then:

# list latest stable versions:
rbenv install -l

# list all local versions:
rbenv install -L

# install a Ruby version:
rbenv install 3.1.2

For troubleshooting BUILD FAILED scenarios, check the ruby-build Discussions section.

Note

If the rbenv install command wasn't found, you can install ruby-build as a plugin:

git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build

Set a Ruby version to finish installation and start using Ruby:

rbenv global 3.1.2   # set the default Ruby version for this machine
# or:
rbenv local 3.1.2    # set the Ruby version for this directory

Alternatively to the rbenv install command, you can download and compile Ruby manually as a subdirectory of ~/.rbenv/versions. An entry in that directory can also be a symlink to a Ruby version installed elsewhere on the filesystem.

Installing Ruby gems

Select a Ruby version for your project using rbenv local 3.1.2, for example. Then, proceed to install gems as you normally would:

gem install bundler

Warning

You should not use sudo to install gems. Typically, the Ruby versions will be installed under your home directory and thus writeable by your user. If you get the “you don't have write permissions” error when installing gems, it's likely that your "system" Ruby version is still a global default. Change that with rbenv global <version> and try again.

Check the location where gems are being installed with gem env:

gem env home
# => ~/.rbenv/versions/<version>/lib/ruby/gems/...

Uninstalling Ruby versions

As time goes on, Ruby versions you install will accumulate in your ~/.rbenv/versions directory.

To remove old Ruby versions, simply rm -rf the directory of the version you want to remove. You can find the directory of a particular Ruby version with the rbenv prefix command, e.g. rbenv prefix 2.7.0.

The ruby-build plugin provides an rbenv uninstall command to automate the removal process.

Command Reference

The main rbenv commands you need to know are:

rbenv versions

Lists all Ruby versions known to rbenv, and shows an asterisk next to the currently active version.

$ rbenv versions
  1.8.7-p352
  1.9.2-p290
* 1.9.3-p327 (set by /Users/sam/.rbenv/version)
  jruby-1.7.1
  rbx-1.2.4
  ree-1.8.7-2011.03

rbenv version

Displays the currently active Ruby version, along with information on how it was set.

$ rbenv version
1.9.3-p327 (set by /Users/sam/.rbenv/version)

rbenv local

Sets a local application-specific Ruby version by writing the version name to a .ruby-version file in the current directory. This version overrides the global version, and can be overridden itself by setting the RBENV_VERSION environment variable or with the rbenv shell command.

rbenv local 3.1.2

When run without a version number, rbenv local reports the currently configured local version. You can also unset the local version:

rbenv local --unset

rbenv global

Sets the global version of Ruby to be used in all shells by writing the version name to the ~/.rbenv/version file. This version can be overridden by an application-specific .ruby-version file, or by setting the RBENV_VERSION environment variable.

rbenv global 3.1.2

The special version name system tells rbenv to use the system Ruby (detected by searching your $PATH).

When run without a version number, rbenv global reports the currently configured global version.

rbenv shell

Sets a shell-specific Ruby version by setting the RBENV_VERSION environment variable in your shell. This version overrides application-specific versions and the global version.

rbenv shell jruby-1.7.1

When run without a version number, rbenv shell reports the current value of RBENV_VERSION. You can also unset the shell version:

rbenv shell --unset

Note that you'll need rbenv's shell integration enabled (step 3 of the installation instructions) in order to use this command. If you prefer not to use shell integration, you may simply set the RBENV_VERSION variable yourself:

export RBENV_VERSION=jruby-1.7.1

rbenv rehash

Installs shims for all Ruby executables known to rbenv (~/.rbenv/versions/*/bin/*). Typically you do not need to run this command, as it will run automatically after installing gems.

rbenv rehash

rbenv which

Displays the full path to the executable that rbenv will invoke when you run the given command.

$ rbenv which irb
/Users/sam/.rbenv/versions/1.9.3-p327/bin/irb

rbenv whence

Lists all Ruby versions that contain the specified executable name.

$ rbenv whence rackup
1.9.3-p327
jruby-1.7.1
ree-1.8.7-2011.03

Environment variables

You can affect how rbenv operates with the following settings:

name default description
RBENV_VERSION Specifies the Ruby version to be used.
Also see rbenv shell
RBENV_ROOT ~/.rbenv Defines the directory under which Ruby versions and shims reside.
Also see rbenv root
RBENV_DEBUG Outputs debug information.
Also as: rbenv --debug <subcommand>
RBENV_HOOK_PATH see wiki Colon-separated list of paths searched for rbenv hooks.
RBENV_DIR $PWD Directory to start searching for .ruby-version files.

How rbenv hooks into your shell

rbenv init is a helper command to bootstrap rbenv into a shell. This helper is part of the recommended installation instructions, but optional, as an advanced user can set up the following tasks manually. Here is what the command does when its output is eval'd:

  1. Adds rbenv executable to PATH if necessary.

  2. Prepends ~/.rbenv/shims directory to PATH. This is basically the only requirement for rbenv to function properly.

  3. Installs shell completion for rbenv commands.

  4. Regenerates rbenv shims. If this step slows down your shell startup, you can invoke rbenv init - with the --no-rehash flag.

  5. Installs the "sh" dispatcher. This bit is also optional, but allows rbenv and plugins to change variables in your current shell, making commands like rbenv shell possible.

You can run rbenv init - for yourself to inspect the generated script.

Uninstalling rbenv

The simplicity of rbenv makes it easy to temporarily disable it, or uninstall from the system.

  1. To disable rbenv managing your Ruby versions, simply comment or remove the rbenv init line from your shell startup configuration. This will remove rbenv shims directory from PATH, and future invocations like ruby will execute the system Ruby version, bypassing rbenv completely.

    While disabled, rbenv will still be accessible on the command line, but your Ruby apps won't be affected by version switching.

  2. To completely uninstall rbenv, perform step (1) and then remove the rbenv root directory. This will delete all Ruby versions that were installed under `rbenv root`/versions/:

    rm -rf "$(rbenv root)"
    

    If you've installed rbenv using a package manager, as a final step perform the rbenv package removal:

    • Homebrew: brew uninstall rbenv
    • Debian, Ubuntu, and their derivatives: sudo apt purge rbenv
    • Archlinux and its derivatives: sudo pacman -R rbenv

Development

Tests are executed using Bats:

$ bats test
$ bats test/<file>.bats

Please feel free to submit pull requests and file bugs on the issue tracker.

rbenv's People

Contributors

blueyed avatar carsomyr avatar dependabot[bot] avatar genezys avatar guilleiguaran avatar hsbt avatar jamacku avatar jamis avatar jasonkarns avatar jeffkowalski avatar jeremy avatar jf avatar jlduran avatar jonathandean avatar josh avatar kevinburke avatar maxnordlund avatar mhinz avatar mislav avatar mlafeldt avatar radar avatar richiethomas avatar romanlevin avatar ryanfb avatar scop avatar sstephenson avatar tmking avatar tpope avatar wakatara avatar yyuu 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  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

rbenv's Issues

rbenv fails to execute system Ruby w/ a fork error

I have a few projects that need OS X Lion's system Ruby, so I put a .rbenv-local file in there with system in it.

However, when I try to execute ruby or any command that uses ruby (like rake), I get errors like this:

/Users/cypher/.rbenv/libexec/rbenv-version-file-read: fork: Resource temporarily unavailable
/Users/cypher/.rbenv/libexec/rbenv: fork: Resource temporarily unavailable
/Users/cypher/.rbenv/libexec/rbenv-version-file: fork: Resource temporarily unavailable

I've run ruby -v with $RBENV_DEBUG=1, and this is the (shortened) output I get: https://gist.github.com/565a7eaf4425a8c60840

The whole output actually takes up 50MB, but I can put it up somewhere if you need it.

It looks like rbenv gets caught in an infinite loop, and keeps adding /Users/cypher/.rbenv/libexec to $PATH.

I use zsh (version 4.3.11), the rbenv repo is at 568cd4b.

rbenv rehash doesn't create shims for commands installed by bundler

I've installed a few gems with bundler, run rbenv rehash but it still can't find them:

╭─haim@sunra  ~ ‹1.8.7-p352› 
╰─$ rbenv rehash
╭─haim@sunra  ~ ‹1.8.7-p352› 
╰─$ rbenv which knife
rbenv: knife: command not found
╭─haim@sunra  ~ ‹1.8.7-p352› 
╰─$ gem contents chef                                                     127 ↵
/Users/haim/.rbenv/versions/1.8.7-p352/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/chef-client
/Users/haim/.rbenv/versions/1.8.7-p352/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/chef-solo
/Users/haim/.rbenv/versions/1.8.7-p352/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/knife
/Users/haim/.rbenv/versions/1.8.7-p352/lib/ruby/gems/1.8/gems/chef-0.10.4/bin/shef

The same goes for other gems (like thor, etc..). I can run them with bundle exec knife without a problem.

BTW, I'm using zsh.

Thanks in advance

Haim

'sudo update --system' error in 'system' version

I've got some trouble when trying update 'system' rubygems under rbenv control.

[space@microb ~]$ rbenv global system
[space@microb ~]$ rbenv version
system (set by /home/space/.rbenv/global)
[space@microb ~]$ sudo gem update --system
Password:
rbenv: version `' is not installed
[space@microb ~]$

Looks like 'system' version isn't considered as full-featured version in rbenv sense. I thought it would be good idea to interprete 'rbenv global system' as switching rbenv off. At least in the current shell context...
The other solution is a processing 'system' as a standard rbenv version and shims exe's to system one in regular way.

Tnx...

How Do You Upgrade rbenv?

As the repo here is updated, how does one keep up to date? Do you just git pull an updated repo and run the init again?

Running gem with JRuby causes error

When running any gem command with JRuby, I get an error. For example:

cboyd@cboyd-imac ~  $> jruby -S gem list
NameError: undefined local variable or method `e' for main:Object
  (root) at /Users/cboyd/.rbenv/shims/gem:2

Let me know if you need more info.

documentation issue: .bash_profile is not cross platform

Hey , very minor issue with the README, but in the installation instructions you echo a couple lines into .bash_profile and then do an exec to load them.

This doesn't work on Ubuntu because it uses .profile instead and xterms use .bashrc. I think it would be clearer if the readme just told you to execute those lines in your terminal and then left it up to the reader to decide if and where they should put them so that they autoload in the future. Or there could be just a note of warning there that .bash_profile might not be the correct place.

Can't execute rake when using ruby 1.9.2

When I try to execute rake on a project that rbenv is set to ruby 1.9.2 I get this error:

Could not find rake-0.9.2 in any of the sources
Run bundle install to install missing gems.

I've already ran 'bundle install' and everything looks fine. Except that the command doesn't work.

$ cd my-project
$ rbenv local
=> 1.9.2-p290
$ ruby --version
=> ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.1.0]
$ which rake
=> /Users/felipecypriano/.rbenv/shims/rake

I've already ran 'rbenv rehash' several times as well.

Any ideas on how to fix this?

rbenv quite slow

I installed rbenv on a new machine (beefy Macbook Pro) and I'm fairly disappointed because it makes all ruby commands (tested with ruby, irb, gem) quite slow.

$ time ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.0.0]

real  0m2.859s
user  0m2.155s
sys 0m0.682s

$ time ~/.rbenv/versions/1.9.2-p290/bin/ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.0.0]

real  0m0.019s
user  0m0.004s
sys 0m0.004s

I did a cursory glance into what rbenv is doing, and it doesn't seem to be one particular slow thing -- just a lot of shell operations.

Nobody seems to be talking about this -- am I doing something completely wrong? I was hoping to replace RVM with my rbenv in my dev environment, but the 2-3 second latency is painful.

shims vs. gem executables

The way shims are currently implemented, rehash wipes the existing shims dir and rebuilds shims for the current ruby. This is problematic: if I have ruby set to (e.g.) 1.8.7 and rehash, it might put "cap" and "bundle" shims there. Then, in another terminal session, I switch to (e.g.) 1.9.2 and rehash. Unless 1.9.2 has the same gems as 1.8.7, I'll lose some (or all) of my shimmed gem executables, so that if I switch back to the first terminal session and try to "cap deploy" (or something), it fails, because the shim is missing.

I'm not sure what the right way to solve this is, aside from maybe never wiping the shims dir, but that has its own problems.

Installing Rails

$ sudo gem install rails
Successfully installed rails-3.0.10
1 gem installed
Installing ri documentation for rails-3.0.10...
file 'lib' not found
Installing RDoc documentation for rails-3.0.10...
file 'lib' not found

Can't fix this by installing rdoc first, as was done in an early pre-release of Rails-3.0.0.
Pretty much everything else works fine.

Using different build locations

It would be nice if rbenv could use other rubies, especially system-wide. Perhaps an environment variable akin to $PATH (perhaps $RBENVS) that includes places to look.

Add support for system Ruby

If RBENV_VERSION is system, then rbenv should remove itself from PATH so that the system Ruby and associated commands have precedence.

Shims are incompatible with `ruby -S`

 -S             Makes Ruby use the PATH environment variable to search for
                script, unless if its name begins with a slash.  This is
                used to emulate #! on machines that don't support it, in
                the following manner:

                      #! /usr/local/bin/ruby
                      # This line makes the next one a comment in Ruby \
                        exec /usr/local/bin/ruby -S $0 $*

When you pass the -S foo flag to Ruby, it finds foo in $PATH, then scans the first line of the file to see if it's a Ruby program and re-execs: https://github.com/ruby/ruby/blob/trunk/ruby.c#L1549-1562

The Rubinius installer uses this:

/Users/sam/.rbenv/versions/1.9.3-preview1/bin/ruby -S rake  -r /private/tmp/ruby-build.10166-13998/rubinius-1.2.4/config.rb -r /private/tmp/ruby-build.10166-13998/rubinius-1.2.4/rakelib/ext_helper.rb -r /private/tmp/ruby-build.10166-13998/rubinius-1.2.4/rakelib/dependency_grapher.rb build:mri
/Users/sam/.rbenv/versions/1.9.3-preview1/bin/ruby: no Ruby script found in input (LoadError)
rake aborted!
Command failed with status (1): [/Users/sam/.rbenv/versions/1.9.3-preview1/...]

One workaround would be to change our shims' shebang to point to another shim in our libexec directory with ruby in the name.

Another workaround would be for rbenv-exec to prepend $PATH with the current version's prefix, so that children of any Ruby process will find the actual binaries in the path before our shims. The downside here is that you wouldn't be able to modify RBENV_VERSION in a Ruby process to spawn a child with a different version, though I'm not sure that's actually useful.

Running ruby command reports command not found after installing rbenv

I have been trying to fix this issue I can't seem to workaround. I followed the installation instructions for rbenv and ruby-build. I used ruby-build to install 1.9.2. I set rbenv to use the system install (1.8.7) as the default. I have a Mac so I'd like to keep that default as I need it currently for a work project that still uses that version. When opening a new tab in Terminal and I type ruby I see the following error

rbenv: ruby: command not found

The `ruby' command exists in these Ruby versions:
  1.9.2-p290

Not sure why its stating rbenv if I set the global default to system. If I run rbenv global it outputs a value of system as expected (from what I understand) but it seems that whenever attempting to use the ruby command in any shell its not working. I set a local version to a specific project and using the ruby command works fine there. Any ideas? I'm sure I'm just missing something.

rbenv on dropbox

Can I install rbenv somewhere on the dropbox folder so that I can share the gems and the versions across my macs? It looks by default it stores the global version in ~/.rbenv/global

"*" shim (again)

Just did a fresh install of rbenv from github. "rbenv rehash" with no Rubies installed at all produced the "*" shim:

% ls -l ~/.rbenv/shims 
total 0

% rbenv rehash        

% ls -l ~/.rbenv/shims
total 4
-rwxr-xr-x 1 wisq wisq 59 2011-08-17 14:29 *

I'm assuming this is the same as #12, i.e. lack of nullglob setting.

Weird behavior with gem cleanup

When running gem cleanup, I get errors like this

Attempting to uninstall rdoc-3.9.1
Unable to uninstall rdoc-3.9.1:
Gem::InstallError: gem "rdoc" is not installed
Attempting to uninstall rails-3.0.3
Unable to uninstall rails-3.0.3:
Gem::InstallError: gem "rails" is not installed
Attempting to uninstall railties-3.0.3
Unable to uninstall railties-3.0.3:
Gem::InstallError: gem "railties" is not installed
Attempting to uninstall newrelic_rpm-3.0.1
Unable to uninstall newrelic_rpm-3.0.1:
Gem::InstallError: gem "newrelic_rpm" is not installed

If I continue running gem cleanup, the gems uninstall one by one, erroring on the gems next in the list. In the event of a Y/N question to uninstall, selecting no causes you to get stuck there on next run because that gem is next in line.

JRuby 1.6.4 shims seem broken

Looks likes it's trying to execute bundle as a bash script

➜  helix git:(develop) ✗ rbenv |&  head -n 1
rbenv 0.2.0-pre
➜  helix git:(develop) ✗ rbenv version       
jruby-1.6.4 (set by RBENV_VERSION environment variable)
➜  helix git:(develop) ✗ bundle
/Users/justin/.rbenv/versions/jruby-1.6.4/bin/bundle: line 9: require: command not found
/Users/justin/.rbenv/versions/jruby-1.6.4/bin/bundle: line 11: version: command not found
/Users/justin/.rbenv/versions/jruby-1.6.4/bin/bundle: line 13: syntax error near unexpected token `('
/Users/justin/.rbenv/versions/jruby-1.6.4/bin/bundle: line 13: `if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then'
➜  helix git:(develop) ✗ 

Add rbenv-whence

Add an rbenv-whence command that takes a single command name as an argument and shows you which versions of Ruby have that command. For example, if you have Bundler installed in 1.9.2-p290 and 1.9.3-preview1, but not 1.8.7-p352, rbenv whence bundle would print

1.9.2-p290
1.9.3-preview1

Set Global System Ruby Broken

I was reading thru issue #8 and noticed that rbenv global system is not working in the master version.

(kencollins@mc1) - (~)
∴ rbenv global system
rbenv: ruby: command not found

The `ruby' command exists in these Ruby versions:
1.9.3
ree

rbenv: rails: command not found

How do you run gem executables without Bundler / bundle exec?

~ $ rbenv rehash
~ $ rbenv global
1.9.2-p290
~ $ gem which rails
/Users/meleyal/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.1.0/lib/rails.rb
~ $ rails new test
rbenv: rails: command not found

The `rails' command exists in these Ruby versions:
  1.8.7-p352

~ $ bundle exec rails new test
Could not locate Gemfile

Maybe related to #40, #61

`rbenv-rehash` + `rbenv-gemsets` produces a spurious shim

I wasn't sure whether to post this bug here or on rbenv-gemsets, so I'm putting it here and cc-ing @jamis.

Once you have rbenv-gemsets installed, rehashing can produce a spurious file in shims called * (no joke). I can't even figure out a way to explain it briefly, so I'm just going to show how I found it:

  1. At the top of make_shims in rbenv-rehash add echo "glob: $@"

  2. Run rbenv rehash

  3. Get this result:

    glob: ../versions/1.9.2-p290/bin/erb ../versions/1.9.2-p290/bin/gem ../versions/1.9.2-p290/bin/irb ../versions/1.9.2-p290/bin/rake ../versions/1.9.2-p290/bin/rdoc ../versions/1.9.2-p290/bin/ri ../versions/1.9.2-p290/bin/ruby ../versions/1.9.2-p290/bin/testrb
    
    glob: /Users/telemachus/.rbenv/versions/*/gemsets/*/bin/*
    

That second item gets truncated to *, a file of that name is created and then treated as a proper shim. At the moment, this isn't a huge deal, but it's worth considering now before the gemsets idea grows.

/usr/bin/env: bash -e: Permission denied

After following the installation instructions, all calls to rbenv die with:

/usr/bin/env: bash -e: Permission denied

Shell versions:

% bash --version
GNU bash, version 4.1.9(2)-release (x86_64-pc-linux-gnu)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
2:10:43 testo@corinth: ~/.rbenv/libexec
% zsh --version
zsh 4.3.10 (x86_64-pc-linux-gnu)

bash -e: No such file or directory

i just cloned the project and added the bin path to PATH, but get an error from env.

$ rbenv
/usr/bin/env: bash -e: No such file or directory
$ head -1 .rbenv/bin/rbenv

!/usr/bin/env bash -e

$ env bash -e
$

Add Option to change the directory where rbenv stores its metadata

Add an option similar to git's --git-dir option for specifying where rbenv looks for the versions and shims directories and where rbenv stores the default file.

The path of this "data dir" would default to $HOME/.rbenv.

Use Cases would be:

  • Switch between a global and a local set of rubies
  • Manage other kinds of executables in parallel with rbenv, e.g. PHP or Python in addtion to Ruby

gem installed binaries require rbenv rehash

It would seem to be simple enough to detect a "gem.*install" command in the shims and then call rbenv rehash afterwards as a default... would their be an objection to a patch doing just this? Seems I keep installing gems with binaries and having to rehash to get them to work...

homebrew doesn't work after switching to rbenv

I keep getting this after switching from rvm to rbenv:

/usr/local/bin/brew: line 4: syntax error near unexpected token (' /usr/local/bin/brew: line 4:HOMEBREW_BREW_FILE = ENV['HOMEBREW_BREW_FILE'] = File.expand_path(FILE)'

I made sure there is only one ruby version installed:

which -a ruby
/Users/tim/.rbenv/shims/ruby

starting debugger on shims

Looks like, gdb does not like shims (which is obvious).

This GDB was configured as "x86_64-apple-darwin"..."/Users/gnufied/.rbenv/shims/ruby": not in executable format: File format not recognized

I am not sure, if this is a bug per-se - but definitely invoking debugger makes harder than needs be.

Check $# Before You Shift

Executing rbenv without arguments gives the following error.

rbenv:shift:2: shift count must be <= $#

Pow compat. - LoadError

I've installed the latest Pow and rbenv. I setup ruby-1.9.2-p290 and Pow is just not seeing it. I ran the rbenv set-local and rbenv set-default commands to enforce the 1.9.2, but it's not being detected correctly. Please help

LoadError: no such file to load -- bundler/setup
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
~/rails/rails-project/config/boot.rb:6
~/rails/rails-project/config/application.rb:1:in `require'
~/rails/rails-project/config/application.rb:1
~/rails/rails-project/config/environment.rb:2:in `require'
~/rails/rails-project/config/environment.rb:2
~/rails/rails-project/config.ru:3:in `require'
~/rails/rails-project/config.ru:3
~/Library/Application Support/Pow/Versions/0.3.1/node_modules/nack/lib/nack/builder.rb:4:in `instance_eval'
~/Library/Application Support/Pow/Versions/0.3.1/node_modules/nack/lib/nack/builder.rb:4:in `initialize'
~/rails/rails-project/config.ru:1:in `new'
~/rails/rails-project/config.ru:1

gem shims not being created

When I install a gem that provides executables the binary shims don't seem to be created, but the gem installs fine and the binaries are in the 'right' place.

I've run rbenv rehash with no luck.

$ rbenv 2>&1 |head -1
rbenv 0.2.0-pre

$ rbenv version
ree-1.8.7-2011.03 (set by /home/test/.rbenv-version)

$ gem list

*** LOCAL GEMS ***

$ gem install rake --no-rdoc --no-ri
Successfully installed rake-0.9.2
1 gem installed

$ rbenv rehash

$ rake
-bash: rake: command not found

$ rbenv shims
/home/test/.rbenv/shims/erb
/home/test/.rbenv/shims/gem
/home/test/.rbenv/shims/irb
/home/test/.rbenv/shims/rdoc
/home/test/.rbenv/shims/ree-version
/home/test/.rbenv/shims/ri
/home/test/.rbenv/shims/ruby
/home/test/.rbenv/shims/testrb

$ gem contents rake
/home/test/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/rake-0.9.2/bin/rake

This last part is odd to me as well why so little is listed with gem contents.

$ find /home/test/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/rake-0.9.2/ | wc -l
181

Discussion: Global config and installs

Since we'll be supporting system wide installs via homebrew, I'd like to establish some conventions for global config and installed files.

I know Sam likes the simplicity of ~/.rbenv, but I don't really like putting compiled programs in my ~.

We already have something for plugins, a global /etc/rbenv.d directory.

RBENV_EXEC_PLUGINS=(/etc/rbenv.d/exec/*.bash ${HOME}/.rbenv/rbenv.d/exec/*.bash)

We should probably look for /etc/rbenv.d/default here too.

As for ~/.rbenv/versions, I'd like to see them under /usr/local/lib/rbenv. Not sure if thats the correct place.

Also don't know where shims would go.

I'd be cool if we supported the unix hierarchy so that ~/.rbenv/default was checked first, then /usr/local/etc/rbenv.d/default, then /etc/rbenv.d/default. Maybe thats unnecessary.

Problems with using tmux

When I use tmux ruby can't find any installed gems. Ruby tells me gem is not installed, and gem list produces nothing. Outside of tmux everything works. Could be some oddity about my setup but I'm not sure. I have zsh + oh-my-zsh and tmux 1.4

Installation instructions seem incorrect

I followed the instructions, but it didn't work right. I'm not even sure what happened. When I subsequently did a bundle install I was instructed to enter my password to install the gems, but they didn't actually install even though it looked like they did. This seems consistent with your warning in the README, but I followed the installation instructions to a T.

I am using OS X Lion.

I got it working after closing and restarting my shell and running rbenv rehash again. I did run exec to restart the shell originally as instructed but that must've not done the trick.

Determining current shell

If the terminal starts with custom shell then
occurs loading rbenv.bash instead rbenv.zsh
Because $1 is empty and $SHELL is just default shell, not current

shell="$1"
if [ -z "$shell" ]; then
  shell="$(basename "$SHELL")"
fi

Gem is installed but not found?

Not exactly sure what's going on here, but when I open something with MacVim, e.g. mvim ., I get an error complaining github-markup isn't installed. So I gem install github-markup. And it installs, but when I open MacVim the error persists. I also noticed I can't require 'github-markup' in irb.

Running rbenv with sudo

gem install rails
=> dont have permissions to write in the gems directory

sudo gem install rails
=> unknow gem command

rbenv must be tested

Personally I found working with rvm to be good until you upgraded rvm itself. It seemed every release would have odd quirks with failures and unpredictable exit codes (ie 0 on error). Personally I found rvm terribile to script against (think chef), as each release it seemed to change its exit codes and/or improperly handle failure. This among many other issues could be mostly eradicated with a proper test suite.

I realize that rbenv is a shell based application, but I strongly suggest cucumber/aruba features that focus on ensuring that rbenv returns proper exit codes and is scriptable, unix style. Simply ensuring the external command line interface behaves consistently across releases.

I would be happy to start on something like this if the approach is agreeable.

Thanks again for rbenv! It is much needed!

gem commands - in shims?

Hi all,
I've installed gems such as rails and bundler (not using sudo), wanting rails and bundle to be omnipresent with rbenv, I copied an existing shim and named it as the executable name.
This way works pretty well for me, however, is this the intended usage?

Update: I'm using zsh and Ubuntu.

Thanks

zsh completion not working

Manually sourcing the script doesn't work, but adding it to my $fpath does (that is, making a symlink named _rbenv in a directory in my $fpath).

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.