In attempting to use Bundler with ruby 1.9.3p194 managed with rbenv in the fish shell I receive the error:
> gem install bundler
Fetching: bundler-1.5.1.gem (100%)
> bundle install
fish: Unknown command 'bundle'
Rbenv is being initialized in config.fish like so:
set -x PATH "$HOME/.rbenv/bin" $PATH
. (rbenv init - | psub)
And the output of rbenv init -:
> rbenv init -
setenv RBENV_SHELL fish
. '/Users/nifl/.rbenv/libexec/../completions/rbenv.fish'
rbenv rehash 2>/dev/null
function rbenv
set command $argv[1]
set -e argv[1]
switch "$command"
case rehash shell
eval (rbenv "sh-$command" $argv)
case '*'
command rbenv "$command" $argv
end
end
I don't have fish set up as the default shell and Bundler is working fine in Bash.
Derp. Needed rehash after > gem install bundler
> rbenv rehash
Another issue that can appear is when using rbenv-communal-gems. jruby does not like the communization, it wants this:
rbenv sequester jruby-1.7.12
This allows you to re-run
gem install bundler
rbenv rehash
And then you can use the bundle command again.
Related
I am able to install and execute a gem as follows:
rbenv install 2.4.1
rbenv local 2.4.1 # enter the environment
gem install fpm
fpm --version
I was expecting to be able to execute the gem from outside the environment too, something like:
rbenv local --unset # leave the environment
rbenv rehash # update shims
fpm --version
But instead I get:
rbenv: fpm: command not found
The `fpm' command exists in these Ruby versions:
2.4.1
Have I misunderstood how rbenv shims work? Can I execute a gem from outside an rbenv environment?
From the comments in your Github issue it seems you got the basic idea now; rbenv shims are nothing more than glorified shell scripts that tie a command to a particular currently active Ruby version.
But nothing prevents you from creating your own hard-coded shims. For example, let's say you want this global fpm command that is available outside any particular rbenv environment.
Here's a simple way to do it:
> rbenv local 2.4.1
> ln -s `rbenv which fpm` ~/.rbenv/bin/fpm24
> rbenv local --unset
> fpm24 --version
1.10.2
This will install a "shim" into ~/.rbenv/bin/fpm24 that is a hard-coded pointer to the 2.4.1 gem that rbenv has installed previously. Now this fpm24 command will work anywhere, as long as you have ~/.rbenv/bin in your PATH.
I'm trying to setup rbenv to use with fastlane. I follow the instructions here. I've installed rbenv
rbenv install 2.3.1
Then updated it so the version points to:
rbenv local 2.3.1 => 2.3.1 (set by /Users/pepe/Development/test-ios/.ruby-version)
I then try to install bundler:
gem install bundler and get the following error:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
And running following gives me:
rbenv which gem
/Users/pernillau-ext/.rbenv/versions/2.3.1/bin/gem
which gem
/Users/pernillau-ext/.rbenv/shims/gem
Obviously rbenv points to one installation of gem and the system (Mac OS X 10.116) comes with preinstalled ruby and gems which is installed in /Library/Ruby/Gems/2.0.0 directory. So, what am I missing here? Why is gem command using the wrong version.
EDIT:
My bash_profile:
export ANDROID_HOME=/Users/pepe/Library/Android/sdk
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home
export GEM_PATH=/Users/pepe/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0
export PATH=$PATH:/Users/pernillau-ext/Library/Android/sdk/tools:/Users/pernillau-ext/Library/Android/sdk/platform-tools
PATH="$(perl -e 'print join(":", grep { not $seen{$_}++ } split(/:/, $ENV{PATH}))')"
eval "$(rbenv init -)"
Try mooving things in $PATH a little. Move rbenv to the front of the $PATH.
$PATH in your shell should look roughtly like (pseudocode):
{rbenv shims} : {rbenv bin} : {system paths}
I have a shell script that is changing between different directories, setting up various projects. Each project has a .ruby-version file.
How can I get rbenv to change to the appropriate ruby version in each directory?
I have something like this right now:
Dir.chdir(target) do
run('rbenv install -s')
run('eval "$(rbenv init -)" ' \
'&& gem install bundler ' \
'&& rbenv rehash ' \
'&& bundle install')
end
But I'm getting this error:
Successfully installed bundler-1.12.0
1 gem installed
Your Ruby version is 2.2.2, but your Gemfile specified 2.1.5
Command `eval "$(rbenv init -)" && gem install bundler && rbenv rehash && bundle install` failed with status 18
Any ideas?
I'm on Linux Mint 17.2.
I recently removed ruby with apt-get purge ruby.
I then installed rbenv and then did rbenv install 2.3.0 so now, ~/.rbenv/versions/2.3.0/bin/ruby exists.
But now, I can't do gem install rubocop. I get this:
$ gem install rubocop
rbenv: gem: command not found
The `gem' command exists in these Ruby versions:
2.3.0
But I can do ~/.rbenv/versions/2.3.0/bin/gem install rubocop.
However, once I'm done, I can't use it:
$ rubocop --auto-correct
-bash: /usr/local/bin/rubocop: /usr/bin/ruby1.9.1: bad interpreter: No such file or directory
I also can't find out where this ruby came from:
$ dpkg -S /usr/bin/ruby1.9.1
dpkg-query: no path found matching pattern /usr/bin/ruby1.9.1
It's possible it was installed via RVM a long time ago.
Any idea how I can fix my Ruby?
try run rbenv global 2.3.0 && rbenv rehash
It looks like you haven't run the rbenv shell magic to add bin shims to your path.
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
It's recommended to add that to your .bashrc or .bash_profile so it gets executed on login.
Take a read through this - it covers rbenv and bundler but the initial setup will be what you need to look at.
After installing rbenv, I wanted to switch to the correct Ruby version to work on a project, but there seems to be an issue recognizing it.
$ cd project/
$ bundle install
$ Your Ruby version is 2.0.0, but your Gemfile specified 2.1.1
$ rbenv local
$ rbenv: no local version configured for this directory
$ rbenv global
$ 2.1.1
$ ruby --version
$ ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0]
Am I overlooking something?
There was an issue with my $PATH variable.
This worked for me (in .bash_profile):
export PATH="/usr/local/bin:$PATH"
eval "$(rbenv init -)"